Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,14 +4,17 @@ from huggingface_hub import InferenceClient
|
|
| 4 |
client = InferenceClient("bigscience/bloom")
|
| 5 |
|
| 6 |
def generate_text(prompt, max_tokens, temperature, top_p):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
demo = gr.Interface(
|
| 17 |
fn=generate_text,
|
|
|
|
| 4 |
client = InferenceClient("bigscience/bloom")
|
| 5 |
|
| 6 |
def generate_text(prompt, max_tokens, temperature, top_p):
|
| 7 |
+
try:
|
| 8 |
+
response = client.chat_completion(
|
| 9 |
+
[{"role": "user", "content": prompt}],
|
| 10 |
+
max_tokens=max_tokens,
|
| 11 |
+
stream=True,
|
| 12 |
+
temperature=temperature,
|
| 13 |
+
top_p=top_p,
|
| 14 |
+
)
|
| 15 |
+
return response
|
| 16 |
+
except Exception as e:
|
| 17 |
+
return str(e)
|
| 18 |
|
| 19 |
demo = gr.Interface(
|
| 20 |
fn=generate_text,
|