Spaces:
Runtime error
Runtime error
Delete app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051import osimport gradio as gr
# 安裝 groq 套件os.system('pip install groq')
# 從 groq 導入 Groqfrom groq import Groq
# 設定 API Keygroq_key = os.getenv("groq_key")
# 初始化 Groq 客戶端client = Groq(api_key=groq_key)
# 定義 Chatbot 回應函數def chatbot_response(user_input): completion = client.chat.completions.create( model="llama-3.1-70b-versatile", messages=[ { "role": "system", "content": "You have a humorous temperament, and are capable of discussing serious matters with a sense of humor.\nYou speak Traditional Chinese(zh-tw)." }, { "role": "user", "content": user_input } ], temperature=1.14, max_tokens=1024, top_p=1, stream=False, stop=None, )
response = "".join(chunk.choices[0].delta.content or "" for chunk in completion) return response
# 設定 Gradio Chatbot 介面iface = gr.Interface( fn=chatbot_response, inputs="text", outputs="text", title="Groq Chatbot", description="一個用於與 Groq API 互動的 Chatbot",)
# 啟動 Gradio 應用程式if __name__ == "__main__": iface.launch()app.pyDeleted-51