Spaces:
Configuration error
Configuration error
Commit History
-
Upload app.py
Verified signatureb64f597 -
app. py
Verified signatureimport gradio as gr from litellm import completion TITLE = "🤖 هاب AI شخصی من" AVATAR = "https://i.imgur.com/4z7v3.gif" def chat(message, history, model, api_key): if not api_key: return "ابتدا Gemini API Key را وارد کنید!", history try: # تبدیل history به فرمت درست messages = [] for human, assistant in history: messages.append({"role": "user", "content": human}) if assistant: messages.append({"role": "assistant", "content": assistant}) messages.append({"role": "user", "content": message}) response = completion(model=model, messages=messages, api_key=api_key) reply = response.choices[0].message.content history.append((message, reply)) return "", history except Exception as e: return f"خطا: {str(e)}", history with gr.Blocks(title=TITLE) as demo: gr.Markdown(f"# {TITLE}") with gr.Row(): with gr.Column(scale=1): gr…d4d1b07 -
Rename app (1).py to app.py
Verified signaturecbc5ae2