flâneur

jxnl/instructor: openai function calls for humans

github.com · 717 words · saved by 1 readers

openai function calls for humans

Get reliable JSON from any LLM. Built on Pydantic for validation, type safety, and IDE support. import instructor from pydantic import BaseModel # Define what you want class User(BaseModel): name: str age: int # Extract it from natural language client = instructor.from_provider("openai/gpt-4o-mini") user = client.chat.completions.create( response_model=User, messages=[{"role": "user", "content": "John is 25 years old"}], ) print(user) # User(name='John', age=25) That's it. No JSON parsing, no error handling, no retries. Just define a model and get structured data. Use Instructor for…

saved by

related reading