andreska commited on
Commit
108d2a7
·
verified ·
1 Parent(s): d86d1b6

Try to update using Flask

Browse files
Files changed (1) hide show
  1. app.py +12 -20
app.py CHANGED
@@ -1,27 +1,19 @@
1
  import os
2
- import gradio as gr
3
  from huggingface_hub import InferenceClient
4
 
5
- def analyze_project(project_data, question):
6
- #api_key = os.getenv("HF_API_KEY")
7
- #client = InferenceClient(api_key=api_key)
8
-
9
- #prompt = f"Analyze this project: {project_data}\n\nQuestion: {question}"
10
- ## inputs = client.encoding("text", prompt)
11
 
12
- #outputs = client.generate(
13
- # model="Qwen/Qwen2.5-72B-Instruct",
14
- # inputs=inputs,
15
- # max_new_tokens=100
16
- #)
17
-
18
- #return outputs["generated_text"][0]
19
  return f"Project: {project_data}, Query: {question}"
20
 
21
- iface = gr.Interface(
22
- analyze_project,
23
- inputs=["text", "text"],
24
- outputs="text"
25
- )
 
 
26
 
27
- iface.launch(share=True)
 
 
1
  import os
2
+ from flask import Flask, request, jsonify
3
  from huggingface_hub import InferenceClient
4
 
5
+ app = Flask(__name__)
 
 
 
 
 
6
 
7
+ def analyze_project(project_data, question):
 
 
 
 
 
 
8
  return f"Project: {project_data}, Query: {question}"
9
 
10
+ @app.route('/analyze', methods=['POST'])
11
+ def analyze_endpoint():
12
+ data = request.json
13
+ project_data = data['project_data']
14
+ question = data['question']
15
+ result = analyze_project(project_data, question)
16
+ return jsonify({'result': result})
17
 
18
+ if __name__ == '__main__':
19
+ app.run(debug=True)