-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllm.py
More file actions
32 lines (28 loc) · 839 Bytes
/
llm.py
File metadata and controls
32 lines (28 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import lmstudio as lms
from pydantic import BaseModel
# A class based schema for a book
class AddressSchema(BaseModel):
house_number: str
street_name: str
district: str
city: str
state: str
postal_code: str
country: str
prompt = """
Find the address in the following text.
Return the address as a JSON structure with attributes for house number, street name, district, city, state, postcode and country
"""
text = """
Compound Code(s): ASP8062
Trial Phase: Phase I
Sponsor Name and Address: Astellas Pharma
Global Development Inc.
1 Astellas Way Northbrook, IL 60062, US
Regulatory Agency Identifier Number(s):
IND 146215
"""
model = lms.llm("openai/gpt-oss-20b")
result = model.respond(f"{prompt} '{text}'", response_format=AddressSchema)
address = result.parsed
print(address)