Spaces:
Sleeping
Sleeping
Update app.py
Browse files1212314 unmodified lines1819202324212223242526279 unmodified lines3738394344454640414243444546474848495051print(f\"API Key: {api_key}\") import osimport gradio as gr
14 unmodified lines
client.api_key = api_key
def chat_with_groq(user_message): """θ Groq 樑ει²θ‘δΊε""" try: # θͺΏη¨ API completion = client.chat.completions.create( model="llama-3.1-70b-versatile", messages=[9 unmodified lines stream=False )
# η’ΊδΏθΏεη΅ζζ ΌεΌζ£η’Ί if completion.get("choices") and len(completion["choices"]) > 0: response = completion["choices"][0].get("message", {}).get("content", "ζ±ζοΌζη‘ζ³ηζζζηεζγ") return response # ι©θδΈ¦θ§£ζεζ if "choices" in completion and len(completion["choices"]) > 0: response = completion["choices"][0].get("message", {}).get("content", None) if response: return response else: return "ζ±ζοΌζη‘ζ³ηζζζηεζγ" else: return "ζ±ζοΌζη‘ζ³θ§£ζ API ηεζη΅ζγ" return "ζ±ζοΌAPI εζηη΅ζ§δΈη¬¦ει ζγ"
except Exception as e: return f"ηΌηι―θͺ€οΌ{str(e)}"app.py+9-9