mgokg commited on
Commit
9e26823
1 Parent(s): a1b6671

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -1,8 +1,13 @@
 
 
1
  from huggingface_hub import InferenceClient
2
  import os
3
- os.system("pip install gradio==4.33.0")
4
  import gradio as gr
5
 
 
 
 
 
6
  client = InferenceClient(
7
  "mistralai/Mistral-7B-Instruct-v0.3"
8
  )
@@ -83,6 +88,23 @@ additional_inputs=[
83
  )
84
  ]
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
 
87
  gr.ChatInterface(
88
  fn=generate,
 
1
+ from flask import Flask, request
2
+ from threading import Thread
3
  from huggingface_hub import InferenceClient
4
  import os
 
5
  import gradio as gr
6
 
7
+ app = Flask(__name__)
8
+
9
+
10
+
11
  client = InferenceClient(
12
  "mistralai/Mistral-7B-Instruct-v0.3"
13
  )
 
88
  )
89
  ]
90
 
91
+ @app.route('/api/generate', methods=['GET'])
92
+ def api_generate():
93
+ message = request.args.get('message')
94
+ history = request.args.get('history')
95
+ # Parse other parameters from the GET request if needed
96
+
97
+ result = generate(message, history)
98
+ return {'result': result}
99
+
100
+ def run_flask_app():
101
+ app.run(debug=True,port=5000)
102
+
103
+ if __name__ == '__main__':
104
+ # Start the Flask app in a separate thread
105
+ flask_thread = Thread(target=run_flask_app)
106
+ flask_thread.start()
107
+
108
 
109
  gr.ChatInterface(
110
  fn=generate,