Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,15 +11,11 @@ generator = InferenceApi(repo_id=model_id, token=api_key)
|
|
11 |
# 驻讜谞拽爪讬讬转 讬爪讬专转 讛讟拽住讟
|
12 |
def chat_with_model(history):
|
13 |
prompt = history[-1]["content"]
|
14 |
-
|
15 |
-
|
16 |
-
"
|
17 |
-
|
18 |
-
"
|
19 |
-
"top_p": 0.92,
|
20 |
-
"temperature": 0.9
|
21 |
-
})
|
22 |
-
result = response["generated_text"]
|
23 |
return history + [{"role": "bot", "content": result}]
|
24 |
|
25 |
# 讬爪讬专转 诪诪砖拽 诪转拽讚诐 注诐 Gradio 讘爪讜专转 爪'讟-讘讜讟 讘住讙谞讜谉 讗拽讚诪讬
|
|
|
11 |
# 驻讜谞拽爪讬讬转 讬爪讬专转 讛讟拽住讟
|
12 |
def chat_with_model(history):
|
13 |
prompt = history[-1]["content"]
|
14 |
+
try:
|
15 |
+
response = generator(prompt)
|
16 |
+
result = response["generated_text"] if "generated_text" in response else response
|
17 |
+
except Exception as e:
|
18 |
+
result = f"Error: {str(e)}"
|
|
|
|
|
|
|
|
|
19 |
return history + [{"role": "bot", "content": result}]
|
20 |
|
21 |
# 讬爪讬专转 诪诪砖拽 诪转拽讚诐 注诐 Gradio 讘爪讜专转 爪'讟-讘讜讟 讘住讙谞讜谉 讗拽讚诪讬
|