Spaces:
Sleeping
Sleeping
vansin
commited on
Commit
·
154195a
1
Parent(s):
ba4f256
feat: update
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ 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 |
|
|
@@ -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
|
|
|
|
| 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 |
|
|
|
|
| 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dist/assets/{index-33b9caaa.js → index-327d01f5.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/{index-legacy-15e8503d.js → index-legacy-f2aa4b0e.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title></title>
|
| 8 |
-
<script type="module" crossorigin src="/assets/index-
|
| 9 |
<link rel="stylesheet" href="/assets/index-ab4095ce.css">
|
| 10 |
<script type="module">import.meta.url;import("_").catch(()=>1);async function* g(){};if(location.protocol!="file:"){window.__vite_is_modern_browser=true}</script>
|
| 11 |
<script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>
|
|
@@ -16,6 +16,6 @@
|
|
| 16 |
|
| 17 |
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
|
| 18 |
<script nomodule crossorigin id="vite-legacy-polyfill" src="/assets/polyfills-legacy-0b55db5f.js"></script>
|
| 19 |
-
<script nomodule crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-
|
| 20 |
</body>
|
| 21 |
</html>
|
|
|
|
| 5 |
<link rel="icon" type="image/svg+xml" href="" />
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
<title></title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/index-327d01f5.js"></script>
|
| 9 |
<link rel="stylesheet" href="/assets/index-ab4095ce.css">
|
| 10 |
<script type="module">import.meta.url;import("_").catch(()=>1);async function* g(){};if(location.protocol!="file:"){window.__vite_is_modern_browser=true}</script>
|
| 11 |
<script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>
|
|
|
|
| 16 |
|
| 17 |
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
|
| 18 |
<script nomodule crossorigin id="vite-legacy-polyfill" src="/assets/polyfills-legacy-0b55db5f.js"></script>
|
| 19 |
+
<script nomodule crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-f2aa4b0e.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
|
| 20 |
</body>
|
| 21 |
</html>
|