Spaces:
Sleeping
Sleeping
Create run_model.py
Browse files- run_model.py +34 -0
run_model.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import openai
|
3 |
+
|
4 |
+
from prompt import system_instruction, user_prompt
|
5 |
+
|
6 |
+
client = openai.OpenAI(
|
7 |
+
base_url="https://api.cerebras.ai/v1",
|
8 |
+
api_key=os.environ.get("CEREBRAS_API_KEY")
|
9 |
+
)
|
10 |
+
|
11 |
+
def run(input_text):
|
12 |
+
completion = client.chat.completions.create(
|
13 |
+
model="llama-4-scout-17b-16e-instruct",
|
14 |
+
temperature=0.0,
|
15 |
+
seed=42,
|
16 |
+
messages=[
|
17 |
+
{
|
18 |
+
"role": "system",
|
19 |
+
"content": system_instruction
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"role": "user",
|
23 |
+
"content": user_prompt
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"role": "user",
|
27 |
+
"content": f"Time Entry Input: `{input_text}`"
|
28 |
+
}
|
29 |
+
]
|
30 |
+
)
|
31 |
+
|
32 |
+
print(completion)
|
33 |
+
|
34 |
+
return completion.choices[0].message.content
|