Skip to content

Commit

Permalink
Merge branch 'main' into hf/1104
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanbelenky authored Oct 21, 2024
2 parents 60d549a + d51cff2 commit e3efd03
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 70 deletions.
12 changes: 6 additions & 6 deletions docs/concepts/multimodal.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ from openai import OpenAI
from pydantic import BaseModel
import instructor
from instructor.multimodal import Audio
import base64

client = instructor.from_openai(OpenAI())

Expand All @@ -109,20 +108,21 @@ class User(BaseModel):
age: int


with open("./output.wav", "rb") as f:
encoded_string = base64.b64encode(f.read()).decode("utf-8")

resp = client.chat.completions.create(
model="gpt-4o-audio-preview",
response_model=User,
modalities=["text"],
audio={"voice": "alloy", "format": "wav"},
messages=[
{
"role": "user",
"content": [
"Extract the following information from the audio:",
Audio.from_path("./output.wav"),
],
},
}, # type: ignore
],
) # type: ignore
)

print(resp)
# > name='Jason' age=20
Expand Down
Loading

0 comments on commit e3efd03

Please sign in to comment.