Spaces:
Sleeping
Sleeping
Switch baseline to required OpenAI client format
Browse files- inference.py +11 -5
- pyproject.toml +2 -1
inference.py
CHANGED
|
@@ -34,9 +34,12 @@ Rules:
|
|
| 34 |
5. close_ticket when the ticket is fully addressed. YOU MUST ACT (reply, escalate, classify) BEFORE CLOSING.
|
| 35 |
"""
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
total_reward = 0.0
|
| 42 |
step_count = 0
|
|
@@ -53,8 +56,11 @@ Rules:
|
|
| 53 |
|
| 54 |
try:
|
| 55 |
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}]
|
| 56 |
-
response = client.
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
| 58 |
)
|
| 59 |
action_json = response.choices[0].message.content
|
| 60 |
|
|
|
|
| 34 |
5. close_ticket when the ticket is fully addressed. YOU MUST ACT (reply, escalate, classify) BEFORE CLOSING.
|
| 35 |
"""
|
| 36 |
|
| 37 |
+
API_BASE_URL = os.getenv("API_BASE_URL", "https://router.huggingface.co/v1/")
|
| 38 |
+
MODEL_NAME = os.getenv("MODEL_NAME", "meta-llama/Llama-3.3-70B-Instruct")
|
| 39 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 40 |
+
|
| 41 |
+
from openai import OpenAI
|
| 42 |
+
client = OpenAI(base_url=API_BASE_URL, api_key=HF_TOKEN)
|
| 43 |
|
| 44 |
total_reward = 0.0
|
| 45 |
step_count = 0
|
|
|
|
| 56 |
|
| 57 |
try:
|
| 58 |
messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}]
|
| 59 |
+
response = client.chat.completions.create(
|
| 60 |
+
model=MODEL_NAME,
|
| 61 |
+
messages=messages,
|
| 62 |
+
max_tokens=250,
|
| 63 |
+
response_format={"type": "json_object"}
|
| 64 |
)
|
| 65 |
action_json = response.choices[0].message.content
|
| 66 |
|
pyproject.toml
CHANGED
|
@@ -14,7 +14,8 @@ dependencies = [
|
|
| 14 |
"huggingface_hub",
|
| 15 |
"fastapi",
|
| 16 |
"uvicorn",
|
| 17 |
-
"python-dotenv"
|
|
|
|
| 18 |
]
|
| 19 |
|
| 20 |
[project.scripts]
|
|
|
|
| 14 |
"huggingface_hub",
|
| 15 |
"fastapi",
|
| 16 |
"uvicorn",
|
| 17 |
+
"python-dotenv",
|
| 18 |
+
"openai"
|
| 19 |
]
|
| 20 |
|
| 21 |
[project.scripts]
|