KeyError: 'environment' when generating response with MindSearch on macOS Python 3.12

Open
#292 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
ai, backend

Research direction

Reproduce the failure with the stated macOS, Python 3.12, GPT-4o command and DuckDuckGoSearch setup. Trace from mindsearch/agent/streaming.py and mindsearch/agent/mindsearch_agent.py into lagent/llms/openai.py and lagent/llms/base_api.py, where the traceback shows the role mapping failure; done means the query completes without the KeyError.

Written by the indexing model from the issue text.

Description

Description:
When deploying MindSearch on macOS with Python 3.12, I encounter an error where the system pauses after partially outputting text during a query. The backend throws a KeyError: 'environment' related to the role mapping in the OpenAI API integration. Below are the details of the error and environment setup.


Environment Details:

  • Operating System: macOS
  • Python Version: 3.12
  • Command Used to Start Backend:
    python -m mindsearch.app --lang cn --model_format gpt4 --search_engine DuckDuckGoSearch --asy
    
  • API Used: GPT-4o API

Error Traceback:

ERROR:root:An error occurred while generating the response.
Traceback (most recent call last):  
  File "/Users/kt/Downloads/MindSearch/mindsearch/app.py", line 142, in generate
    async for message in agent(inputs, session_id=session_id):  
  File "/Users/kt/Downloads/MindSearch/mindsearch/agent/streaming.py", line 50, in __call__    
    async for response_message in self.forward(*message, session_id=session_id, **kwargs):  
  File "/Users/kt/Downloads/MindSearch/mindsearch/agent/mindsearch_agent.py", line 156, in forward    
    async for message in self.agent(message, session_id=session_id, **kwargs):  
  File "/Users/kt/Downloads/MindSearch/mindsearch/agent/streaming.py", line 50, in __call__    
    async for response_message in self.forward(*message, session_id=session_id, **kwargs):  
  File "/Users/kt/Downloads/MindSearch/mindsearch/agent/streaming.py", line 99, in forward    
    async for model_state, response, _ in self.llm.stream_chat(  
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/lagent/llms/openai.py", line 597, in stream_chat    
    messages = self.template_parser._prompt2api(inputs)               
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/lagent/llms/base_api.py", line 114, in _prompt2api    
    api_role = self._role2api_role(prompt)               
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/lagent/llms/base_api.py", line 119, in _role2api_role    
    merged_prompt = self.roles[role_prompt['role']]                    
KeyError: 'environment'
Dominant language
JavaScript
Stars
7k
Forks
684
PR merge metrics
No merged PRs in 30d

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from InternLM/MindSearch

All issues in InternLM/MindSearch

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.