Skip to content

Instantly share code, notes, and snippets.

@fsndzomga
Created March 11, 2024 20:15
Show Gist options
  • Save fsndzomga/c5653ed8b27692b641c1538690d76ba1 to your computer and use it in GitHub Desktop.
Save fsndzomga/c5653ed8b27692b641c1538690d76ba1 to your computer and use it in GitHub Desktop.
from pydantic import BaseModel
from anonLLM.llm import OpenaiLanguageModel
from dotenv import load_dotenv
load_dotenv()
llm = OpenaiLanguageModel(anonymize=False, temperature=1)
class Person(BaseModel):
name: str
sex: str
age: int
email: str
response = llm.generate(
prompt="Generate a person",
output_format=Person
)
print(response)
# Returns: {'name': 'Alex', 'sex': 'Male', 'age': 32, 'email': '[email protected]'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment