Spaces:
Sleeping
Sleeping
Update app.py
Browse files29 unmodified lines3031323334353637383940411 unmodified line43444546474849501 unmodified line52535455565758596061626329 unmodified linestemperature=1,max_tokens=1024,top_p=1,stream=True)response = ""for chunk in completion:response += chunk.get('choices', [{}])[0].get('delta', {}).get('content', "")return responseexcept 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 linereturn history, historywith gr.Blocks() as demo:with gr.Row():gr.Markdown("### 成語遊戲 Chatbot")chatbot = gr.Chatbot()with gr.Row():user_input = gr.Textbox(placeholder="輸入你的訊息...")submit_button = gr.Button("送出")submit_button.click(respond, [user_input, chatbot], [chatbot, chatbot])return demo29 unmodified lines30313233343536373839401 unmodified line4243444546471 unmodified line495051525354555657585929 unmodified linestemperature=1,max_tokens=1024,top_p=1,stream=False)# 處理非流式輸出response = completion["choices"][0]["message"]["content"]return responseexcept Exception as e:1 unmodified line# 定義 Gradio 介面def gradio_chatbot():def respond(message, history):response = chat_with_groq(message)history = history or []1 unmodified linereturn history, historywith gr.Blocks() as demo:gr.Markdown("### 成語遊戲 Chatbot")chatbot = gr.Chatbot()user_input = gr.Textbox(placeholder="輸入你的訊息...")submit_button = gr.Button("送出")submit_button.click(respond, [user_input, chatbot], [chatbot, chatbot])return demo
app.py+7-11