Skip to content

Commit

Permalink
support terminal.py for easy debugging (InternLM#10)
Browse files Browse the repository at this point in the history
* support terminal.py for easy debugging

* update readme

* update readme

* update readme

* update readme
  • Loading branch information
liujiangning30 authored Jul 30, 2024
1 parent 577dec5 commit 29bbfe7
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ python -m mindsearch.app --lang en --model_format internlm_server
- `--model_format`: format of the model.
`internlm_server` for InternLM2.5-7b-chat with local server.
`gpt4` for GPT4.
if you want to use other models, please modify [models](mindsearch\agent\models.py)
if you want to use other models, please modify [models](./mindsearch/agent/models.py)

### Step3: Setup MindSearch Frontend

Expand Down Expand Up @@ -93,10 +93,10 @@ python frontend/mindsearch_gradio.py
streamlit run frontend/mindsearch_streamlit.py
```

## 🐞 Debug in Locally
## 🐞 Debug Locally

```bash
python mindsearch/terminal.py
python -m mindsearch.terminal
```

## 📝 License
Expand Down
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ python -m mindsearch.app --lang en --model_format internlm_server
- `--model_format`: 模型的格式。
`internlm_server` 为 InternLM2.5-7b-chat 本地服务器。
`gpt4` 为 GPT4。
如果您想使用其他模型,请修改 [models](mindsearch\agent\models.py)
如果您想使用其他模型,请修改 [models](./mindsearch/agent/models.py)

### 步骤3: 启动 MindSearch 前端

Expand Down
4 changes: 2 additions & 2 deletions frontend/React/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ npm start

#### 接口请求配置

- 如您需要配置的服务支持跨域,可至[cgi.ts](/src/config/cgi.ts)中修改请求链接,请求链接为http://ip:port/path;
- 如您需要配置的服务支持跨域,可至[cgi.ts](./src/config/cgi.ts)中修改请求链接,请求链接为http://ip:port/path;

- 如您需要配置的服务不支持跨域,可至 [vue.config.ts](frontend\React\vite.config.ts) 中配置proxy,示例如下
- 如您需要配置的服务不支持跨域,可至 [vue.config.ts](./vite.config.ts) 中配置proxy,示例如下

```
server: {
Expand Down
50 changes: 50 additions & 0 deletions mindsearch/terminal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from datetime import datetime

from lagent.actions import ActionExecutor, BingBrowser
from lagent.llms import INTERNLM2_META, LMDeployServer

from mindsearch.agent.mindsearch_agent import (MindSearchAgent,
MindSearchProtocol)
from mindsearch.agent.mindsearch_prompt import (
FINAL_RESPONSE_CN, FINAL_RESPONSE_EN, GRAPH_PROMPT_CN, GRAPH_PROMPT_EN,
searcher_context_template_cn, searcher_context_template_en,
searcher_input_template_cn, searcher_input_template_en,
searcher_system_prompt_cn, searcher_system_prompt_en)

lang = 'cn'
llm = LMDeployServer(path='internlm/internlm2_5-7b',
model_name='internlm2',
meta_template=INTERNLM2_META,
top_p=0.8,
top_k=1,
temperature=0,
max_new_tokens=8192,
repetition_penalty=1.02,
stop_words=['<|im_end|>'])

agent = MindSearchAgent(
llm=llm,
protocol=MindSearchProtocol(
meta_prompt=datetime.now().strftime('The current date is %Y-%m-%d.'),
interpreter_prompt=GRAPH_PROMPT_CN
if lang == 'cn' else GRAPH_PROMPT_EN,
response_prompt=FINAL_RESPONSE_CN
if lang == 'cn' else FINAL_RESPONSE_EN),
searcher_cfg=dict(
llm=llm,
plugin_executor=ActionExecutor(
BingBrowser(searcher_type='DuckDuckGoSearch', topk=6)),
protocol=MindSearchProtocol(
meta_prompt=datetime.now().strftime(
'The current date is %Y-%m-%d.'),
plugin_prompt=searcher_system_prompt_cn
if lang == 'cn' else searcher_system_prompt_en,
),
template=dict(input=searcher_input_template_cn
if lang == 'cn' else searcher_input_template_en,
context=searcher_context_template_cn
if lang == 'cn' else searcher_context_template_en)),
max_turn=10)

for agent_return in agent.stream_chat('上海今天适合穿什么衣服'):
pass

0 comments on commit 29bbfe7

Please sign in to comment.