InternLM / InternLM/MindSearch

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

Open
#292 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
6.9k
Forks
692
PR merge metrics
No merged PRs in 30d

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:**
```bash
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'
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.