Files
wehub-resource-sync 97e91a83f3
Ruff / Ruff (push) Has been cancelled
Test / Core Tests (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.10) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.11) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.12) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.13) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.9) (push) Has been cancelled
Test / Full Coverage (Python 3.11) (push) Has been cancelled
Test / Core Provider Tests (OpenAI) (push) Has been cancelled
Test / Core Provider Tests (Anthropic) (push) Has been cancelled
Test / Core Provider Tests (Google) (push) Has been cancelled
Test / Core Provider Tests (Other) (push) Has been cancelled
Test / Anthropic Tests (push) Has been cancelled
Test / Gemini Tests (push) Has been cancelled
Test / Google GenAI Tests (push) Has been cancelled
Test / Vertex AI Tests (push) Has been cancelled
Test / OpenAI Tests (push) Has been cancelled
Test / Writer Tests (push) Has been cancelled
Test / Auto Client Tests (push) Has been cancelled
ty / type-check (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:36:38 +08:00

52 lines
1.3 KiB
Python

import logging
from pydantic import BaseModel, Field
from instructor import Instructions
import instructor
from openai import OpenAI
client = instructor.from_openai(OpenAI())
logging.basicConfig(level=logging.INFO)
# Usage
instructions = Instructions(
name="three_digit_multiply",
finetune_format="messages",
include_code_body=True,
log_handlers=[
logging.FileHandler("math_finetunes.jsonl"),
],
openai_client=client,
)
class Multiply(BaseModel):
a: int
b: int
result: int = Field(..., description="The result of the multiplication")
@instructions.distil(mode="dispatch", model="ft:gpt-3.5-turbo-0125:personal::9i1JeuxJ")
def fn(a: int, b: int) -> Multiply:
"""Return the result of the multiplication as an integer"""
resp = a * b
return Multiply(a=a, b=b, result=resp)
if __name__ == "__main__":
import random
for _ in range(5):
a = random.randint(100, 999)
b = random.randint(100, 999)
result = fn(a, b)
print(f"{a} * {b} = {result.result}, expected {a * b}")
"""
972 * 508 = 493056, expected 493776
145 * 369 = 53505, expected 53505
940 * 440 = 413600, expected 413600
114 * 213 = 24282, expected 24282
259 * 650 = 168350, expected 168350
"""