| import gradio as gr | |
| import requests | |
| API_TOKEN = "توکن Hugging Face خودت رو اینجا بذار" | |
| API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-2-7b-chat-hf" | |
| headers = {"Authorization": f"Bearer {API_TOKEN}"} | |
| def query_llama(prompt): | |
| payload = {"inputs": prompt, "parameters": {"max_new_tokens": 300}} | |
| response = requests.post(API_URL, headers=headers, json=payload) | |
| return response.json()[0]["generated_text"] | |
| iface = gr.Interface( | |
| fn=query_llama, | |
| inputs=gr.Textbox(lines=2, placeholder="سؤال خود را وارد کنید..."), | |
| outputs="text", | |
| title="پاسخگوی هوشمند مشاورین املاک", | |
| description="یک مدل زبان بزرگ بر اساس Llama 2 برای پاسخ به سؤالات حقوقی در حوزه املاک و مستغلات." | |
| ) | |
| iface.launch() |