Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -40,20 +40,8 @@ model = OpenAIModel(
|
|
40 |
base_url='http://localhost:1234/v1',
|
41 |
api_key='your-local-api-key',
|
42 |
)
|
43 |
-
model11 = OpenAIModel(
|
44 |
-
'mistral-7b-instruct-v0.3',
|
45 |
-
base_url='http://localhost:1234/v1',
|
46 |
-
api_key='your-local-api-key',
|
47 |
-
)
|
48 |
-
|
49 |
-
#DeepSeek Key: sk-694660c67c3947e4853019473f30240d https://api.deepseek.com
|
50 |
# Model Pydantic untuk Sales Order
|
51 |
-
|
52 |
-
ds_productCode: Optional[str] = "" #str = Field(..., min_length=1, max_length=20)
|
53 |
-
ds_productName: str = Field(..., min_length=1, max_length=100)
|
54 |
-
ds_quantity: int = Field(..., ge=1)
|
55 |
-
ds_unitPrice: float = Field(..., ge=0)
|
56 |
-
ds_itemAmt: Optional[float] = 0
|
57 |
|
58 |
# 'if-token-present' means nothing will be sent (and the example will work) if you don't have logfire configured
|
59 |
logfire.configure(send_to_logfire='if-token-present')
|
@@ -75,19 +63,17 @@ class SalesOrder(BaseModel):
|
|
75 |
ds_shippingAddress: Optional[str] = ""
|
76 |
ds_totalAmount:Optional[float] = 0
|
77 |
#ds_paymentTerms: Optional[str] = ""
|
|
|
|
|
|
|
78 |
os.environ['GEMINI_API_KEY'] = 'AIzaSyAsVIHsPIIfDBTb2K6VNdNlMt05t8x3mtE'
|
79 |
-
#agent= Agent('gemini-1.5-flash', result_type=SalesOrder)
|
80 |
|
81 |
# # Create a system prompt to guide the model
|
82 |
-
|
83 |
-
Anda adalah asisten yang ahli melakukan ekstrak data SalesOrder dari teks user. Format output yang diinginkan hanya berupa JSON saja sesuai class SalesOrder. Tidak usah ada penjelasan lain. Sekali lagi: Output hanya JSON saja. Untuk Nomor Sales Order pasangkan dengan key ds_salesOrderId, untuk Tanggal Sales pasangkan dengan key ds_salesDate, untuk Nama Customer pasangkan dengan Key ds_customerName, untuk Alamat Customer pasangkan dengan key ds_customerAddress, untuk Daftar Item Barang pasangkan dengan key ds_items, untuk Kode Barang pasangkan dengan key ds_productCode, untuk Nama Barang pasangkan dengan key ds_productName, untuk Quantity pasangkan dengan key ds_quantity, untuk Unit Price pasangkan dengan key ds_unitPrice, untuk Total Nilai Per Baris Barang pasangkan dengan key ds_itemAmt, untuk Ongkos Kirim pasangkan dengan key ds_shippingCost, untuk Alamat Pengiriman pasangkan dengan key ds_shippingAddress, untuk Total Nilai Sales Order pasangkan dengan key ds_totalAmount
|
84 |
-
"""
|
85 |
-
#agent3 = Agent(model=ollama_model, result_type=PetList, retries=3, system_prompt=SYSTEM_PROMPT)
|
86 |
-
#agent3 = Agent(model=ollama_model, retries=3, system_prompt=SYSTEM_PROMPT)
|
87 |
|
88 |
|
89 |
#INI SAJA. SALAH SATU
|
90 |
-
agent = Agent('gemini-1.5-flash', system_prompt=
|
91 |
#agent = Agent(model) # OK-Lokal
|
92 |
|
93 |
|
@@ -449,12 +435,12 @@ async def post_chat(
|
|
449 |
nn = len(prompt)
|
450 |
prompt = prompt[1:nn]
|
451 |
print(">>>", prompt, "<<<")
|
452 |
-
return StreamingResponse(
|
453 |
elif prompt[0] != "@" :
|
454 |
#print("biasa")
|
455 |
-
return StreamingResponse(
|
456 |
print("** selesai **")
|
457 |
-
return StreamingResponse(
|
458 |
|
459 |
P = ParamSpec('P')
|
460 |
R = TypeVar('R')
|
|
|
40 |
base_url='http://localhost:1234/v1',
|
41 |
api_key='your-local-api-key',
|
42 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
# Model Pydantic untuk Sales Order
|
44 |
+
system_prompt="Anda adalah asisten medis yang membantu mengekstrak informasi dari catatan klinis. Gunakan alat extract_entities untuk memproses teks."
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
# 'if-token-present' means nothing will be sent (and the example will work) if you don't have logfire configured
|
47 |
logfire.configure(send_to_logfire='if-token-present')
|
|
|
63 |
ds_shippingAddress: Optional[str] = ""
|
64 |
ds_totalAmount:Optional[float] = 0
|
65 |
#ds_paymentTerms: Optional[str] = ""
|
66 |
+
class ClinicalNoteResult(BaseModel):
|
67 |
+
entities: list
|
68 |
+
message: str
|
69 |
os.environ['GEMINI_API_KEY'] = 'AIzaSyAsVIHsPIIfDBTb2K6VNdNlMt05t8x3mtE'
|
|
|
70 |
|
71 |
# # Create a system prompt to guide the model
|
72 |
+
system_prompt="Anda adalah asisten medis yang membantu mengekstrak informasi dari catatan klinis. Gunakan alat extract_entities untuk memproses teks."
|
|
|
|
|
|
|
|
|
73 |
|
74 |
|
75 |
#INI SAJA. SALAH SATU
|
76 |
+
agent = Agent('gemini-1.5-flash', system_prompt=system_prompt) # OK-Gemini
|
77 |
#agent = Agent(model) # OK-Lokal
|
78 |
|
79 |
|
|
|
435 |
nn = len(prompt)
|
436 |
prompt = prompt[1:nn]
|
437 |
print(">>>", prompt, "<<<")
|
438 |
+
return StreamingResponse(stream_messages(prompt), media_type='text/plain')
|
439 |
elif prompt[0] != "@" :
|
440 |
#print("biasa")
|
441 |
+
return StreamingResponse(stream_messages(prompt), media_type='text/plain')
|
442 |
print("** selesai **")
|
443 |
+
return StreamingResponse(stream_messages(prompt), media_type='text/plain')
|
444 |
|
445 |
P = ParamSpec('P')
|
446 |
R = TypeVar('R')
|