Downloads · 30 days
0
Alijnqnd23/Ali.ai
Ali.ai is a machine learning model from Alijnqnd23. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
import gradio as gr import google.generativeai as genai
Downloads · 30 days
0
Access
Public
Updated Dec 26, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md1.9 KB · 55%
From the Hugging Face model README
import gradio as gr import google.generativeai as genai
MY_API_KEY = "AIzaSyAANSYG92b8P9fd_uutX4vWZVfFhV-T1cU" genai.configure(api_key=MY_API_KEY)
generation_config = { "temperature": 0.9, "top_p": 0.95, "top_k": 40, "max_output_tokens": 8192, }
system_instruction = "تو یک دستیار هوشمند و بسیار کاربردی هستی که به زبان فارسی پاسخ میدهی."
model = genai.GenerativeModel( model_name="gemini-1.5-flash", generation_config=generation_config, system_instruction=system_instruction, )
def predict(message, history): # تبدیل تاریخچه چت به فرمت قابل فهم برای گوگل history_gemini = [] for human, assistant in history: history_gemini.append({"role": "user", "parts": [human]}) history_gemini.append({"role": "model", "parts": [assistant]})
chat_session = model.start_chat(history=history_gemini)
response = chat_session.send_message(message)
return response.text
demo = gr.ChatInterface( fn=predict, title="اپلیکیشن هوشمند من 🚀", description="این برنامه با استفاده از مدل Gemini ساخته شده است.", textbox=gr.Textbox(placeholder="پیام خود را اینجا بنویسید...", container=False, scale=7), theme="soft", # میتوانی از "ocean" یا "glass" هم استفاده کنی submit_btn="ارسال", stop_btn="توقف", retry_btn="تلاش مجدد", undo_btn="پاک کردن آخرین پیام", clear_btn="پاک کردن کل چت", )
if name == "main": demo.launch()