File size: 856 Bytes
1c09a5c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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() |