MindSearch icon indicating copy to clipboard operation
MindSearch copied to clipboard

子问题不继续推理回答停止

Open JansonChenQ opened this issue 1 year ago • 5 comments

版本:v0.2.0 现象:运行terminal.py,只返回根节点回答,子问题不继续执行了。 image

JansonChenQ avatar Nov 13 '24 05:11 JansonChenQ

WebBrowser设置了搜索引擎的api_key吗

braisedpork1964 avatar Nov 13 '24 06:11 braisedpork1964

WebBrowser设置了搜索引擎的api_key吗

search_engine="BingSearch",在.env中配置了WEB_SEARCH_API_KEY

JansonChenQ avatar Nov 13 '24 06:11 JansonChenQ

lagent版本是0.5以上吗,不显式传api_key会报参数缺失

WebBrowser(
    searcher_type="BingSearch",
    api_key=os.getenv("WEB_SEARCH_API_KEY"),
    topk=6
)

braisedpork1964 avatar Nov 13 '24 06:11 braisedpork1964

lagent版本是0.5以上吗,不显式传api_key会报参数缺失

WebBrowser(
    searcher_type="BingSearch",
    api_key=os.getenv("WEB_SEARCH_API_KEY"),
    topk=6
)

lagent==0.5.0rc1,这三个参数都是给了的。 image

JansonChenQ avatar Nov 13 '24 06:11 JansonChenQ

这个格式internlm-2.5外的模型难follow上,拼一下planner和searcher的fewshot提示词(可能还要进一步调整),然后InterpreterParser和PluginParser解析工具的begin和end模式放宽松一点

from mindsearch.agent.mindsearch_prompt import (
    fewshot_example_cn,
    fewshot_example_en,
    graph_fewshot_example_cn,
    graph_fewshot_example_en,
)

agent = MindSearchAgent(
    llm=llm,
    template=date,
    output_format=InterpreterParser(
        begin="<|action_start|><|interpreter|>",
        end="<|action_end|>",
        template=(
            GRAPH_PROMPT_CN + graph_fewshot_example_cn
            if lang == "cn"
            else GRAPH_PROMPT_EN + graph_fewshot_example_en
        ),
    ),
    searcher_cfg=dict(
        llm=llm,
        plugins=plugins,
        template=date,
        output_format=PluginParser(
            begin="<|action_start|><|plugin|>",
            end="<|action_end|>",
            template=(
                searcher_system_prompt_cn + fewshot_example_cn
                if lang == "cn"
                else searcher_system_prompt_en + fewshot_example_en
            ),
            tool_info=get_plugin_prompt(plugins),
        ),
        user_input_template=(
            searcher_input_template_cn if lang == "cn" else searcher_input_template_en
        ),
        user_context_template=(
            searcher_context_template_cn if lang == "cn" else searcher_context_template_en
        ),
    ),
    summary_prompt=FINAL_RESPONSE_CN if lang == "cn" else FINAL_RESPONSE_EN,
    max_turn=10,
)

braisedpork1964 avatar Nov 13 '24 07:11 braisedpork1964