Spaces:
Sleeping
Sleeping
Update app.py
Browse files36 unmodified lines373839404142434445464748495036 unmodified lines)# 確保返回結果格式正確if "choices" in completion and len(completion["choices"]) > 0:response = completion["choices"][0]["message"]["content"]return response or "抱歉,我無法生成有效的回應。"else:return "抱歉,我無法解析 API 的回應結果。"except Exception as e:return f"發生錯誤:{e}"# 定義 Gradio 介面def gradio_chatbot():36 unmodified lines373839404142434445464748495036 unmodified lines)# 確保返回結果格式正確if completion.get("choices") and len(completion["choices"]) > 0:response = completion["choices"][0].get("message", {}).get("content", "抱歉,我無法生成有效的回應。")return responseelse:return "抱歉,我無法解析 API 的回應結果。"except Exception as e:return f"發生錯誤:{str(e)}"# 定義 Gradio 介面def gradio_chatbot():
app.py+4-4