MCPcopy Create free account
hub / github.com/cxcscmu/AutoGEO / main

Function main

LLaMA-Factory/scripts/api_example/test_image.py:24–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22
23
24def main():
25 client = OpenAI(
26 api_key="{}".format(os.getenv("API_KEY", "0")),
27 base_url="http://localhost:{}/v1".format(os.getenv("API_PORT", 8000)),
28 )
29 messages = []
30 messages.append(
31 {
32 "role": "user",
33 "content": [
34 {"type": "text", "text": "Output the color and number of each box."},
35 {
36 "type": "image_url",
37 "image_url": {"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-VL/boxes.png"},
38 },
39 ],
40 }
41 )
42 result = client.chat.completions.create(messages=messages, model="test")
43 messages.append(result.choices[0].message)
44 print("Round 1:", result.choices[0].message.content)
45 # The image shows a pyramid of colored blocks with numbers on them. Here are the colors and numbers of ...
46 messages.append(
47 {
48 "role": "user",
49 "content": [
50 {"type": "text", "text": "What kind of flower is this?"},
51 {
52 "type": "image_url",
53 "image_url": {"url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-VL/flowers.jpg"},
54 },
55 ],
56 }
57 )
58 result = client.chat.completions.create(messages=messages, model="test")
59 messages.append(result.choices[0].message)
60 print("Round 2:", result.choices[0].message.content)
61 # The image shows a cluster of forget-me-not flowers. Forget-me-nots are small ...
62
63
64if __name__ == "__main__":

Callers 1

test_image.pyFile · 0.70

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected