Spaces:
Running
Running
Update model_api.py
Browse files- model_api.py +6 -6
model_api.py
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
|
|
| 1 |
from huggingface_hub import InferenceClient
|
| 2 |
-
import os
|
| 3 |
|
| 4 |
def query_model(prompt):
|
|
|
|
| 5 |
try:
|
| 6 |
-
HF_TOKEN =
|
| 7 |
|
| 8 |
client = InferenceClient(
|
| 9 |
-
model="llama-3
|
| 10 |
token=HF_TOKEN
|
| 11 |
)
|
| 12 |
|
| 13 |
response = client.chat_completion(
|
| 14 |
messages=[
|
| 15 |
-
{"role": "system", "content": "You are a certified
|
| 16 |
{"role": "user", "content": prompt}
|
| 17 |
],
|
| 18 |
-
max_tokens=
|
| 19 |
-
temperature=0.7
|
| 20 |
)
|
| 21 |
|
| 22 |
return response.choices[0].message.content
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
from huggingface_hub import InferenceClient
|
|
|
|
| 3 |
|
| 4 |
def query_model(prompt):
|
| 5 |
+
|
| 6 |
try:
|
| 7 |
+
HF_TOKEN = st.secrets["HF_TOKEN"]
|
| 8 |
|
| 9 |
client = InferenceClient(
|
| 10 |
+
model="meta-llama/Meta-Llama-3-8B-Instruct",
|
| 11 |
token=HF_TOKEN
|
| 12 |
)
|
| 13 |
|
| 14 |
response = client.chat_completion(
|
| 15 |
messages=[
|
| 16 |
+
{"role": "system", "content": "You are a certified fitness trainer."},
|
| 17 |
{"role": "user", "content": prompt}
|
| 18 |
],
|
| 19 |
+
max_tokens=800
|
|
|
|
| 20 |
)
|
| 21 |
|
| 22 |
return response.choices[0].message.content
|