我想要用 gradio 的 gr.chatbot() 做一個 chatbot 我要用 groq 這個套件,API key name 我存在 secret 叫做:groq_key,用os.getenv 設定 groq 安裝請用: try: from groq import Groq except ImportError: os.system('pip install groq') from groq import Groq from groq import Groq client = Groq() completion = client.chat.completions.create( model="llama-3.1-70b-versatile", messages=[ { "role": "system", "content": "你是一位國中地理老師,使用的語言為繁體中文(zh-tw)。你的興趣是繪製等高線圖,熱愛講冷笑話。無論學生問你什麼問題,你都會把話題引導到地理相關的討論上。" } ], temperature=1, max_tokens=1024, top_p=1, stream=True, stop=None, ) for chunk in completion: print(chunk.choices[0].delta.content or "", end="") 加上 role: system 的設定 這是 gradio chatbot 的 document ,請遵循 import gradio as gr def load(): return [ ("Here's an audio", gr.Audio("https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav")), ("Here's an video", gr.Video("https://github.com/gradio-app/gradio/raw/main/demo/video_component/files/world.mp4")) ] with gr.Blocks() as demo: chatbot = gr.Chatbot() button = gr.Button("Load audio and video") button.click(load, None, chatbot) demo.launch( 全部寫在同一份檔案,給我一份 app.py 的 code 就好