Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,19 @@
|
|
1 |
-
import os
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
#
|
5 |
-
os.environ["groq_key"] = "your_groq_api_key"
|
6 |
-
|
7 |
-
# 确保 groq 套件已安装
|
8 |
try:
|
9 |
from groq import Groq
|
10 |
except ImportError:
|
11 |
os.system('pip install groq')
|
12 |
from groq import Groq
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
if
|
17 |
-
raise ValueError("
|
18 |
|
19 |
-
|
20 |
-
client = Groq(api_key=api_key)
|
21 |
|
22 |
# 定义聊天机器人的响应函数
|
23 |
def chatbot_response(messages):
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
|
4 |
+
# Install the groq package if it is not installed
|
|
|
|
|
|
|
5 |
try:
|
6 |
from groq import Groq
|
7 |
except ImportError:
|
8 |
os.system('pip install groq')
|
9 |
from groq import Groq
|
10 |
|
11 |
+
# Set up the Groq client with the secret key
|
12 |
+
groq_key = os.getenv('groq_key')
|
13 |
+
if not groq_key:
|
14 |
+
raise ValueError("groq_key environment variable is not set")
|
15 |
|
16 |
+
client = Groq(api_key=groq_key)
|
|
|
17 |
|
18 |
# 定义聊天机器人的响应函数
|
19 |
def chatbot_response(messages):
|