teoo33 commited on
Commit
1c09a5c
·
verified ·
1 Parent(s): 2f78dec

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +21 -0
App.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ API_TOKEN = "توکن Hugging Face خودت رو اینجا بذار"
5
+ API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-2-7b-chat-hf"
6
+ headers = {"Authorization": f"Bearer {API_TOKEN}"}
7
+
8
+ def query_llama(prompt):
9
+ payload = {"inputs": prompt, "parameters": {"max_new_tokens": 300}}
10
+ response = requests.post(API_URL, headers=headers, json=payload)
11
+ return response.json()[0]["generated_text"]
12
+
13
+ iface = gr.Interface(
14
+ fn=query_llama,
15
+ inputs=gr.Textbox(lines=2, placeholder="سؤال خود را وارد کنید..."),
16
+ outputs="text",
17
+ title="پاسخگوی هوشمند مشاورین املاک",
18
+ description="یک مدل زبان بزرگ بر اساس Llama 2 برای پاسخ به سؤالات حقوقی در حوزه املاک و مستغلات."
19
+ )
20
+
21
+ iface.launch()