# /skills/image_analysis.py import base64 from groq import Groq # Function to encode the image def encode_image(image_file): return base64.b64encode(image_file.read()).decode('utf-8') def get_chat_completion(query, image_file=None): client = Groq() messages = [ { "role": "user", "content": [ {"type": "text", "text": query}, ], } ] if image_file: base64_image = encode_image(image_file) messages[0]["content"].append( { "type": "image_url", "image_url": { "url": f"data:image/jpeg;base64,{base64_image}", }, } ) chat_completion = client.chat.completions.create( messages=messages, model="llama-3.2-11b-vision-preview", ) return chat_completion.choices[0].message.content