vansin commited on
Commit
ee14c58
1 Parent(s): 07a745c

feat: update

Browse files
Files changed (2) hide show
  1. app.py +2 -169
  2. requirements.txt +11 -13
app.py CHANGED
@@ -5,14 +5,14 @@
5
 
6
  import os
7
 
8
- os.system("pip install transformers==4.43.2")
9
 
10
  # # # os.system("python -m mindsearch.app --lang en --model_format internlm_server")
11
- os.system("python -m mindsearch.app --lang en --model_format internlm_hf &")
12
 
13
  # os.system("bash install.sh")
14
 
15
 
 
16
  from flask import Flask, send_from_directory, request, jsonify
17
 
18
  import requests
@@ -28,25 +28,6 @@ def serve_index():
28
  def helloworld():
29
  return "Hello World"
30
 
31
- @app.route('/solve', methods=['GET', 'POST', 'PUT', 'DELETE'])
32
- def solve():
33
- # 根据请求方法转发到本地 http://127.0.0.1:8002/solve
34
- if request.method == 'GET':
35
- response = requests.get('http://127.0.0.1:8002/solve')
36
- elif request.method == 'POST':
37
- data = request.get_json()
38
- response = requests.post('http://127.0.0.1:8002/solve', json=data)
39
- elif request.method == 'PUT':
40
- data = request.get_json()
41
- response = requests.put('http://127.0.0.1:8002/solve', json=data)
42
- elif request.method == 'DELETE':
43
- response = requests.delete('http://127.0.0.1:8002/solve')
44
-
45
- # 检查响应状态码
46
- if response.status_code == 200:
47
- return response.json()
48
- else:
49
- return jsonify({'error': 'Error calling local API'}), response.status_code
50
 
51
  @app.route('/<path:path>')
52
  def serve_file(path):
@@ -57,151 +38,3 @@ if __name__ == '__main__':
57
 
58
  app.run(debug=False, port=7860, host="0.0.0.0")
59
 
60
-
61
- # import json
62
-
63
- # import gradio as gr
64
- # import requests
65
- # from lagent.schema import AgentStatusCode
66
-
67
- # PLANNER_HISTORY = []
68
- # SEARCHER_HISTORY = []
69
-
70
-
71
- # def rst_mem(history_planner: list, history_searcher: list):
72
- # '''
73
- # Reset the chatbot memory.
74
- # '''
75
- # history_planner = []
76
- # history_searcher = []
77
- # if PLANNER_HISTORY:
78
- # PLANNER_HISTORY.clear()
79
- # return history_planner, history_searcher
80
-
81
-
82
- # def format_response(gr_history, agent_return):
83
- # if agent_return['state'] in [
84
- # AgentStatusCode.STREAM_ING, AgentStatusCode.ANSWER_ING
85
- # ]:
86
- # gr_history[-1][1] = agent_return['response']
87
- # elif agent_return['state'] == AgentStatusCode.PLUGIN_START:
88
- # thought = gr_history[-1][1].split('```')[0]
89
- # if agent_return['response'].startswith('```'):
90
- # gr_history[-1][1] = thought + '\n' + agent_return['response']
91
- # elif agent_return['state'] == AgentStatusCode.PLUGIN_END:
92
- # thought = gr_history[-1][1].split('```')[0]
93
- # if isinstance(agent_return['response'], dict):
94
- # gr_history[-1][
95
- # 1] = thought + '\n' + f'```json\n{json.dumps(agent_return["response"], ensure_ascii=False, indent=4)}\n```' # noqa: E501
96
- # elif agent_return['state'] == AgentStatusCode.PLUGIN_RETURN:
97
- # assert agent_return['inner_steps'][-1]['role'] == 'environment'
98
- # item = agent_return['inner_steps'][-1]
99
- # gr_history.append([
100
- # None,
101
- # f"```json\n{json.dumps(item['content'], ensure_ascii=False, indent=4)}\n```"
102
- # ])
103
- # gr_history.append([None, ''])
104
- # return
105
-
106
-
107
- # def predict(history_planner, history_searcher):
108
-
109
- # def streaming(raw_response):
110
- # for chunk in raw_response.iter_lines(chunk_size=8192,
111
- # decode_unicode=False,
112
- # delimiter=b'\n'):
113
- # if chunk:
114
- # decoded = chunk.decode('utf-8')
115
- # if decoded == '\r':
116
- # continue
117
- # if decoded[:6] == 'data: ':
118
- # decoded = decoded[6:]
119
- # elif decoded.startswith(': ping - '):
120
- # continue
121
- # response = json.loads(decoded)
122
- # yield (response['response'], response['current_node'])
123
-
124
- # global PLANNER_HISTORY
125
- # PLANNER_HISTORY.append(dict(role='user', content=history_planner[-1][0]))
126
- # new_search_turn = True
127
-
128
- # url = 'http://localhost:8002/solve'
129
- # headers = {'Content-Type': 'application/json'}
130
- # data = {'inputs': PLANNER_HISTORY}
131
- # raw_response = requests.post(url,
132
- # headers=headers,
133
- # data=json.dumps(data),
134
- # timeout=20,
135
- # stream=True)
136
-
137
- # for resp in streaming(raw_response):
138
- # agent_return, node_name = resp
139
- # if node_name:
140
- # if node_name in ['root', 'response']:
141
- # continue
142
- # agent_return = agent_return['nodes'][node_name]['detail']
143
- # if new_search_turn:
144
- # history_searcher.append([agent_return['content'], ''])
145
- # new_search_turn = False
146
- # format_response(history_searcher, agent_return)
147
- # if agent_return['state'] == AgentStatusCode.END:
148
- # new_search_turn = True
149
- # yield history_planner, history_searcher
150
- # else:
151
- # new_search_turn = True
152
- # format_response(history_planner, agent_return)
153
- # if agent_return['state'] == AgentStatusCode.END:
154
- # PLANNER_HISTORY = agent_return['inner_steps']
155
- # yield history_planner, history_searcher
156
- # return history_planner, history_searcher
157
-
158
-
159
- # with gr.Blocks() as demo:
160
- # gr.HTML("""<h1 align="center">WebAgent Gradio Simple Demo</h1>""")
161
- # with gr.Row():
162
- # with gr.Column(scale=10):
163
- # with gr.Row():
164
- # with gr.Column():
165
- # planner = gr.Chatbot(label='planner',
166
- # height=700,
167
- # show_label=True,
168
- # show_copy_button=True,
169
- # bubble_full_width=False,
170
- # render_markdown=True)
171
- # with gr.Column():
172
- # searcher = gr.Chatbot(label='searcher',
173
- # height=700,
174
- # show_label=True,
175
- # show_copy_button=True,
176
- # bubble_full_width=False,
177
- # render_markdown=True)
178
- # with gr.Row():
179
- # user_input = gr.Textbox(show_label=False,
180
- # placeholder='inputs...',
181
- # lines=5,
182
- # container=False)
183
- # with gr.Row():
184
- # with gr.Column(scale=2):
185
- # submitBtn = gr.Button('Submit')
186
- # with gr.Column(scale=1, min_width=20):
187
- # emptyBtn = gr.Button('Clear History')
188
-
189
- # def user(query, history):
190
- # return '', history + [[query, '']]
191
-
192
- # submitBtn.click(user, [user_input, planner], [user_input, planner],
193
- # queue=False).then(predict, [planner, searcher],
194
- # [planner, searcher])
195
- # emptyBtn.click(rst_mem, [planner, searcher], [planner, searcher],
196
- # queue=False)
197
-
198
- # # subprocess.Popen(["python", "-m", "mindsearch.app", "--lang", "en", "--model_format", "internlm_server"], shell=True, stdout=sys.stdout, stderr=sys.stderr)
199
-
200
-
201
- # demo.queue()
202
- # demo.launch(server_name='0.0.0.0',
203
- # server_port=7860,
204
- # inbrowser=True,
205
- # share=True)
206
-
207
- # pass
 
5
 
6
  import os
7
 
 
8
 
9
  # # # os.system("python -m mindsearch.app --lang en --model_format internlm_server")
10
+ # os.system("python -m mindsearch.app --lang en --model_format internlm_server &")
11
 
12
  # os.system("bash install.sh")
13
 
14
 
15
+
16
  from flask import Flask, send_from_directory, request, jsonify
17
 
18
  import requests
 
28
  def helloworld():
29
  return "Hello World"
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  @app.route('/<path:path>')
33
  def serve_file(path):
 
38
 
39
  app.run(debug=False, port=7860, host="0.0.0.0")
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,14 +1,12 @@
1
  flask
2
- duckduckgo_search==5.3.1b1
3
- einops
4
- fastapi
5
- git+https://github.com/InternLM/lagent.git
6
- gradio
7
- janus
8
- pyvis
9
- sse-starlette
10
- termcolor
11
- uvicorn
12
- transformers==4.43.2
13
- sentencepiece
14
- accelerate
 
1
  flask
2
+ # duckduckgo_search==5.3.1b1
3
+ # einops
4
+ # fastapi
5
+ # git+https://github.com/InternLM/lagent.git
6
+ # gradio
7
+ # janus
8
+ # lmdeploy==0.2.3
9
+ # pyvis
10
+ # sse-starlette
11
+ # termcolor
12
+ # uvicorn