INNER CODE UNIT · Python

compose_classification_prompt

roboflow/awesome-openai-vision-api-experiments · experiments/hot-dog-not-hot-dog/app.py:65

def compose_classification_prompt(classes: list) -> str:
    return (f"What is in the image? Return the class of the object in the image. Here "
            f"are the classes: {', '.join(classes)}. You can only return one class "
            f"from that list.")


def compose_headers(api_key: str) -> dict:
    return {
        "Content-Type": "application/json",
        "Authorization": f"Bearer {api_key}"
    }


def prompt_image(api_key: str, image: np.ndarray, prompt: str) -> str:
    headers = compose_headers(api_key=api_key)
    payload = compose_payload(image=image, prompt=prompt)
    response = requests.post(url=API_URL, headers=headers, json=payload).json()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…