Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,6 @@ except ImportError:
|
|
| 13 |
from groq import Groq
|
| 14 |
|
| 15 |
import gradio as gr
|
| 16 |
-
import random
|
| 17 |
|
| 18 |
# 從環境變量中獲取 API 密鑰
|
| 19 |
api_key = os.getenv('groq_key')
|
|
@@ -45,9 +44,9 @@ def groq_chatbot(messages):
|
|
| 45 |
return response
|
| 46 |
|
| 47 |
def respond(message, history):
|
| 48 |
-
history.append(
|
| 49 |
-
bot_response = groq_chatbot(history)
|
| 50 |
-
history.append(
|
| 51 |
return history, history
|
| 52 |
|
| 53 |
# 創建 Gradio 界面
|
|
|
|
| 13 |
from groq import Groq
|
| 14 |
|
| 15 |
import gradio as gr
|
|
|
|
| 16 |
|
| 17 |
# 從環境變量中獲取 API 密鑰
|
| 18 |
api_key = os.getenv('groq_key')
|
|
|
|
| 44 |
return response
|
| 45 |
|
| 46 |
def respond(message, history):
|
| 47 |
+
history.append(("user", message))
|
| 48 |
+
bot_response = groq_chatbot([{"role": role, "content": content} for role, content in history])
|
| 49 |
+
history.append(("assistant", bot_response))
|
| 50 |
return history, history
|
| 51 |
|
| 52 |
# 創建 Gradio 界面
|