mirror of
https://github.com/kennethreitz/instructor.git
synced 2026-06-05 22:50:18 +00:00
ruff
This commit is contained in:
@@ -64,7 +64,7 @@ def load_json_schema(json_schema_path: str) -> dict:
|
||||
|
||||
def generate_pydantic_model(json_schema_path: str):
|
||||
input_path = Path(json_schema_path)
|
||||
output_path = Path(f"./models.py")
|
||||
output_path = Path("./models.py")
|
||||
generate(
|
||||
input_=input_path, input_file_type=InputFileType.JsonSchema, output=output_path
|
||||
)
|
||||
|
||||
@@ -11,9 +11,9 @@ from pydantic import BaseModel
|
||||
|
||||
|
||||
class Type(Enum):
|
||||
home = 'home'
|
||||
work = 'work'
|
||||
mobile = 'mobile'
|
||||
home = "home"
|
||||
work = "work"
|
||||
mobile = "mobile"
|
||||
|
||||
|
||||
class PhoneNumber(BaseModel):
|
||||
|
||||
@@ -10,14 +10,14 @@ from jinja2 import Template
|
||||
from models import ExtractPerson
|
||||
|
||||
import openai
|
||||
import instructor
|
||||
import instructor
|
||||
|
||||
instructor.patch()
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
class TemplateVariables(BaseModel):
|
||||
|
||||
class TemplateVariables(BaseModel):
|
||||
biography: str
|
||||
|
||||
|
||||
@@ -26,7 +26,11 @@ class RequestSchema(BaseModel):
|
||||
model: str
|
||||
temperature: int
|
||||
|
||||
PROMPT_TEMPLATE = Template("""Extract the person from the following: {{biography}}""".strip())
|
||||
|
||||
PROMPT_TEMPLATE = Template(
|
||||
"""Extract the person from the following: {{biography}}""".strip()
|
||||
)
|
||||
|
||||
|
||||
@app.post("/api/v1/extract_person", response_model=ExtractPerson)
|
||||
async def extract_person(input: RequestSchema) -> ExtractPerson:
|
||||
@@ -35,7 +39,5 @@ async def extract_person(input: RequestSchema) -> ExtractPerson:
|
||||
model=input.model,
|
||||
temperature=input.temperature,
|
||||
response_model=ExtractPerson,
|
||||
messages=[
|
||||
{"role": "user", "content": rendered_prompt}
|
||||
]
|
||||
) # type: ignore
|
||||
messages=[{"role": "user", "content": rendered_prompt}],
|
||||
) # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user