MCPcopy Index your code
hub / github.com/Hrishikesh332/Image-Analysis / get_image_description

Function get_image_description

utils.py:3–23  ·  view source on GitHub ↗
(client, uploaded_file, prompt)

Source from the content-addressed store, hash-verified

1import base64
2
3def get_image_description(client, uploaded_file, prompt):
4 encoded_image = base64.b64encode(uploaded_file.getvalue()).decode('utf-8')
5
6 response = client.chat.completions.create(
7 model="gpt-4o",
8 messages=[
9 {
10 "role": "user",
11 "content": [
12 {"type": "text", "text": prompt},
13 {
14 "type": "image_url",
15 "image_url": {"url": f"data:image/png;base64,{encoded_image}"}
16 },
17 ],
18 }
19 ],
20 max_tokens=300,
21 )
22
23 return response.choices[0].message.content

Callers 1

app.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected