Spaces:
Sleeping
Sleeping
Update model_api.py
Browse files- model_api.py +2 -6
model_api.py
CHANGED
|
@@ -4,22 +4,18 @@ import os
|
|
| 4 |
def query_model(prompt):
|
| 5 |
try:
|
| 6 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 7 |
-
|
| 8 |
client = InferenceClient(
|
| 9 |
-
model="
|
| 10 |
token=HF_TOKEN
|
| 11 |
)
|
| 12 |
-
|
| 13 |
response = client.chat_completion(
|
| 14 |
messages=[
|
| 15 |
-
{"role": "system", "content": "You are a
|
| 16 |
{"role": "user", "content": prompt}
|
| 17 |
],
|
| 18 |
max_tokens=1500,
|
| 19 |
temperature=0.7
|
| 20 |
)
|
| 21 |
-
|
| 22 |
return response.choices[0].message.content
|
| 23 |
-
|
| 24 |
except Exception as e:
|
| 25 |
return f"Error: {str(e)}"
|
|
|
|
| 4 |
def query_model(prompt):
|
| 5 |
try:
|
| 6 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
|
|
|
| 7 |
client = InferenceClient(
|
| 8 |
+
model="mistralai/Mistral-7B-Instruct-v0.2",
|
| 9 |
token=HF_TOKEN
|
| 10 |
)
|
|
|
|
| 11 |
response = client.chat_completion(
|
| 12 |
messages=[
|
| 13 |
+
{"role": "system", "content": "You are a professional fitness trainer."},
|
| 14 |
{"role": "user", "content": prompt}
|
| 15 |
],
|
| 16 |
max_tokens=1500,
|
| 17 |
temperature=0.7
|
| 18 |
)
|
|
|
|
| 19 |
return response.choices[0].message.content
|
|
|
|
| 20 |
except Exception as e:
|
| 21 |
return f"Error: {str(e)}"
|