DanilNikolin commited on
Commit
8bfe2f6
·
verified ·
1 Parent(s): 8a1fce5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -17
app.py CHANGED
@@ -1,22 +1,18 @@
1
- import gradio as gr
 
2
  import requests
3
- import os
4
 
5
- # Замените URL модели на подходящий URL модели Gemini
6
- API_URL = "https://api-inference.huggingface.co/models/EleutherAI/gpt-neo-2.7B"
7
- API_KEY = os.getenv('Sec1') # Используем переменную окружения
8
 
9
- def query(payload):
10
- response = requests.post(API_URL, headers={"Authorization": f"Bearer {API_KEY}"}, json=payload)
11
- return response.json()
 
 
12
 
13
- def chatbot(input_text):
14
- response = query({"inputs": input_text})
15
- print(response) # Выводим ответ от API в консоль для отладки
16
- try:
17
- return response[0]['generated_text']
18
- except (KeyError, IndexError):
19
- return "Error: Unable to generate text. Please try again."
20
 
21
- demo = gr.Interface(fn=chatbot, inputs="text", outputs="text")
22
- demo.launch()
 
1
+ # app.py
2
+ from flask import Flask, request, jsonify
3
  import requests
 
4
 
5
+ app = Flask(__name__)
 
 
6
 
7
+ @app.route('/proxy', methods=['POST'])
8
+ def proxy():
9
+ url = request.json.get('url')
10
+ headers = request.json.get('headers')
11
+ data = request.json.get('data')
12
 
13
+ response = requests.post(url, headers=headers, json=data)
14
+
15
+ return jsonify(response.json())
 
 
 
 
16
 
17
+ if __name__ == '__main__':
18
+ app.run(host='0.0.0.0', port=5000)