Spaces:
Running
Running
File size: 731 Bytes
d8de767 11b81fb a497f10 11b81fb d8de767 c06dc28 f5efa25 d8de767 aa75006 d8de767 038cb96 aa75006 038cb96 c06dc28 f5efa25 c06dc28 f5efa25 c06dc28 aa75006 038cb96 aa75006 c06dc28 038cb96 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import streamlit as st
from huggingface_hub import InferenceClient
def query_model(prompt):
try:
# Read token from Streamlit secrets
HF_TOKEN = st.secrets["HF_TOKEN"]
client = InferenceClient(
model="meta-llama/Meta-Llama-3-8B-Instruct",
token=HF_TOKEN
)
response = client.chat_completion(
messages=[
{"role": "system", "content": "You are a certified professional fitness trainer."},
{"role": "user", "content": prompt}
],
max_tokens=800,
temperature=0.7
)
return response.choices[0].message.content
except Exception as e:
return f"Error: {str(e)}" |