andreska's picture
Second try
54bb289 verified
raw
history blame
619 Bytes
import os
import streamlit as st
from huggingface_hub import InferenceClient
api_key = os.getenv("HF_API_KEY")
client = InferenceClient(api_key=api_key)
user_input = st.text_input('Ask me a question')
messages = [{"role": "user","content": user_input}]
completion = client.chat.completions.create(
model="Qwen/Qwen2.5-Coder-32B-Instruct",
messages=messages,
max_tokens=500
)
if st.button("Submit"):
if user_input:
response = completion.choices[0].message
st.write(f"Adrega AI: {response}")
else:
st.write("Please enter a question.")
print(completion.choices[0].message)