Spaces:
Sleeping
Sleeping
Carina1025
commited on
Commit
•
97d0683
1
Parent(s):
3246582
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,19 @@
|
|
1 |
import os
|
2 |
-
import
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# 從環境變量中獲取 API 密鑰
|
9 |
api_key = os.getenv('groq_key')
|
|
|
1 |
import os
|
2 |
+
import subprocess
|
3 |
+
import sys
|
4 |
+
|
5 |
+
# 確保 groq 套件已安裝
|
6 |
+
def install(package):
|
7 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
8 |
|
9 |
+
try:
|
10 |
+
from groq import Groq
|
11 |
+
except ImportError:
|
12 |
+
install("groq")
|
13 |
+
from groq import Groq
|
14 |
+
|
15 |
+
import gradio as gr
|
16 |
+
import random
|
17 |
|
18 |
# 從環境變量中獲取 API 密鑰
|
19 |
api_key = os.getenv('groq_key')
|