agooaa commited on
Commit
1f642f9
·
verified ·
1 Parent(s): 972df60

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from dotenv import load_dotenv
3
+ import requests
4
+
5
+ # تحميل متغيرات البيئة من ملف .env
6
+ load_dotenv()
7
+
8
+ API_URL = "https://api-inference.huggingface.co/models/deepseek-ai/DeepSeek-Prover-V2-7B"
9
+ API_TOKEN = os.getenv("HF_API_TOKEN")
10
+
11
+ if not API_TOKEN:
12
+ raise ValueError("Please set HF_API_TOKEN in your .env file")
13
+
14
+ headers = {"Authorization": f"Bearer {API_TOKEN}"}
15
+
16
+ def query_deepseek(input_text):
17
+ payload = {"inputs": input_text}
18
+ response = requests.post(API_URL, headers=headers, json=payload)
19
+ response.raise_for_status()
20
+ output = response.json()
21
+ if isinstance(output, list) and 'generated_text' in output[0]:
22
+ return output[0]['generated_text']
23
+ else:
24
+ return str(output)