MindSearch icon indicating copy to clipboard operation
MindSearch copied to clipboard

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

Open kintong3000 opened this issue 1 year ago • 0 comments

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'

kintong3000 avatar Feb 07 '25 04:02 kintong3000