CoolFace
Apppublic

Coder19/interview_system

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
test.py38 linesDownload Raw Back to root
1import base642from openai import OpenAI3import os4from dotenv import load_dotenv5 6load_dotenv()7 8SAMBANOVA_API_KEY = os.getenv("SAMBANOVA_API_KEY")9client = OpenAI(api_key=SAMBANOVA_API_KEY, base_url="https://api.sambanova.ai/v1")10 11# Load your image and encode it in base6412with open(r"C:\Users\ayush\OneDrive\Pictures\1.jpg", "rb") as f:13    image_bytes = f.read()14image_b64 = base64.b64encode(image_bytes).decode("utf-8")15 16# Prepend proper data URI17image_data_uri = f"data:image/png;base64,{image_b64}"18 19response = client.chat.completions.create(20    model="Llama-4-Maverick-17B-128E-Instruct",21    messages=[{22        "role": "user",23        "content": [24            {"type": "text", "text": "What do you see in this image"},25            {"type": "image_url", "image_url": {"url": image_data_uri}}26        ]27    }],28    temperature=0.1,29    top_p=0.130)31 32# Safely print response33if response and response.choices:34    print(response.choices[0].message.content)35else:36    print("No choices returned. Full response:")37    print(response)38