Spaces:
Sleeping
Sleeping
Update app.py
Browse files29 unmodified lines3031323333343536373836373839401 unmodified line42434446474546471 unmodified line4950515556525358596054555657585929 unmodified lines temperature=1, max_tokens=1024, top_p=1, stream=True stream=False )
response = "" for chunk in completion: response += chunk.get('choices', [{}])[0].get('delta', {}).get('content', "") # 處理非流式輸出 response = completion["choices"][0]["message"]["content"] return response
except Exception as e:1 unmodified line
# 定義 Gradio 介面def gradio_chatbot(): chatbot = gr.Chatbot()
def respond(message, history): response = chat_with_groq(message) history = history or []1 unmodified line return history, history
with gr.Blocks() as demo: with gr.Row(): gr.Markdown("### 成語遊戲 Chatbot") gr.Markdown("### 成語遊戲 Chatbot") chatbot = gr.Chatbot() with gr.Row(): user_input = gr.Textbox(placeholder="輸入你的訊息...") submit_button = gr.Button("送出") user_input = gr.Textbox(placeholder="輸入你的訊息...") submit_button = gr.Button("送出")
submit_button.click(respond, [user_input, chatbot], [chatbot, chatbot])
return demoapp.py+7-11