Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,23 +18,22 @@ user_input = st.chat_input("Enter a text prompt:")
|
|
18 |
client = InferenceClient(token=hf_token)
|
19 |
|
20 |
# Button to trigger the inference
|
21 |
-
if
|
22 |
-
|
23 |
-
with st.spinner(f"Generating text using {model_id}..."):
|
24 |
# Perform inference using the selected model
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
|
39 |
|
40 |
|
|
|
18 |
client = InferenceClient(token=hf_token)
|
19 |
|
20 |
# Button to trigger the inference
|
21 |
+
if user_input:
|
22 |
+
with st.spinner(f"Generating text using {model_id}..."):
|
|
|
23 |
# Perform inference using the selected model
|
24 |
+
response = client.chat.completions.create(
|
25 |
+
model=model_id,
|
26 |
+
messages=[
|
27 |
+
{"role": "system", "content": "You are a question answering assistant."},
|
28 |
+
{"role": "user", "content": user_input}
|
29 |
+
],
|
30 |
+
max_tokens=500,
|
31 |
+
stream=False
|
32 |
+
)
|
33 |
+
st.success("Text generated!")
|
34 |
+
st.write(response['choices'][0]['message']['content'])
|
35 |
+
else:
|
36 |
+
st.warning("Please enter a prompt to generate text.")
|
37 |
|
38 |
|
39 |
|