-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for llama3.2-vision #368
Comments
@chaos369 This is possible now using using Ollama via the ollama pull llama3.2-vision import requests
from pydantic import BaseModel, Field
from magentic import chatprompt, UserMessage, Placeholder, OpenaiChatModel
from magentic.vision import UserImageMessage
IMAGE_URL_WOODEN_BOARDWALK = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
def url_to_bytes(url: str) -> bytes:
"""Get the content of a URL as bytes."""
# A custom user-agent is necessary to comply with Wikimedia user-agent policy
# https://meta.wikimedia.org/wiki/User-Agent_policy
headers = {"User-Agent": "MagenticExampleBot (https://magentic.dev/)"}
return requests.get(url, headers=headers, timeout=10).content
@chatprompt(
UserMessage("Describe the following image in one sentence."),
UserImageMessage(Placeholder(bytes, "image_bytes")),
model=OpenaiChatModel("llama3.2-vision", base_url="http://localhost:11434/v1/")
)
def describe_image(image_bytes: bytes) -> str: ...
image_bytes = url_to_bytes(IMAGE_URL_WOODEN_BOARDWALK)
describe_image(image_bytes) |
Cool! I'll try it. Thank you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
llama3.2-vision is good enough in many scenarios, would you please add it to magentic?
The text was updated successfully, but these errors were encountered: