Spaces:
Sleeping
Sleeping
Update app.py
Browse files1234514 unmodified lines20212223242526272829309 unmodified lines404142434445464748495051print(f\"API Key: {api_key}\")import osimport gradio as gr14 unmodified linesclient.api_key = api_keydef chat_with_groq(user_message):"""θ Groq 樑ει²θ‘δΊε"""try:completion = client.chat.completions.create(model="llama-3.1-70b-versatile",messages=[9 unmodified linesstream=False)# η’ΊδΏθΏεη΅ζζ ΌεΌζ£η’Ί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)}"12314 unmodified lines181920212223242526279 unmodified lines373839404142434445464748495051import osimport gradio as gr14 unmodified linesclient.api_key = api_keydef chat_with_groq(user_message):"""θ Groq 樑ει²θ‘δΊε"""try:# θͺΏη¨ APIcompletion = client.chat.completions.create(model="llama-3.1-70b-versatile",messages=[9 unmodified linesstream=False)# ι©θδΈ¦θ§£ζεζif "choices" in completion and len(completion["choices"]) > 0:response = completion["choices"][0].get("message", {}).get("content", None)if response:return responseelse:return "ζ±ζοΌζη‘ζ³ηζζζηεζγ"else:return "ζ±ζοΌAPI εζηη΅ζ§δΈη¬¦ει ζγ"except Exception as e:return f"ηΌηι―θͺ€οΌ{str(e)}"
app.py+9-9