ProfessorLeVesseur commited on
Commit
4551af5
·
verified ·
1 Parent(s): d9ff333

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -89,10 +89,10 @@ if uploaded_file is not None and analyze_button:
89
  "content": [
90
  {"type": "text", "text": prompt_text},
91
  {
92
- "type": "image",
93
- "image": {
94
- # Provide the image bytes directly
95
- "bytes": base64.b64decode(base64_image)
96
  },
97
  },
98
  ],
@@ -105,11 +105,11 @@ if uploaded_file is not None and analyze_button:
105
  completion = client.chat.completions.create(
106
  model="meta-llama/Llama-3.2-11B-Vision-Instruct",
107
  messages=messages,
108
- max_tokens=1200
109
  )
110
 
111
  # Extract the assistant's response
112
- assistant_response = completion.get("choices")[0]["message"]["content"]
113
 
114
  # Display the response
115
  st.markdown(assistant_response)
 
89
  "content": [
90
  {"type": "text", "text": prompt_text},
91
  {
92
+ "type": "image_url",
93
+ "image_url": {
94
+ # Since we have the image in base64, we need to use a data URL
95
+ "url": f"data:image/jpeg;base64,{base64_image}"
96
  },
97
  },
98
  ],
 
105
  completion = client.chat.completions.create(
106
  model="meta-llama/Llama-3.2-11B-Vision-Instruct",
107
  messages=messages,
108
+ max_tokens=500 # Adjusted to match the template
109
  )
110
 
111
  # Extract the assistant's response
112
+ assistant_response = completion.choices[0].message['content']
113
 
114
  # Display the response
115
  st.markdown(assistant_response)