Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,14 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
-
|
| 4 |
from gradio import ChatMessage
|
| 5 |
-
|
| 6 |
-
from groq import Groq
|
| 7 |
-
except ImportError:
|
| 8 |
-
os.system('pip install groq')
|
| 9 |
-
from groq import Groq
|
| 10 |
# 從環境變數中獲取 API 密鑰
|
| 11 |
api_key = os.getenv("groq_key")
|
| 12 |
|
| 13 |
# 初始化 groq 客戶端
|
| 14 |
-
client = Groq(
|
|
|
|
| 15 |
|
| 16 |
# 定義回應函數
|
| 17 |
def respond(message, chat_history):
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
from groq import Groq
|
| 4 |
from gradio import ChatMessage
|
| 5 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# 從環境變數中獲取 API 密鑰
|
| 7 |
api_key = os.getenv("groq_key")
|
| 8 |
|
| 9 |
# 初始化 groq 客戶端
|
| 10 |
+
client = Groq()
|
| 11 |
+
client.set_api_key(api_key)
|
| 12 |
|
| 13 |
# 定義回應函數
|
| 14 |
def respond(message, chat_history):
|