MetaGPT
MetaGPT copied to clipboard
data analysis fails to work with gemini pro due to temperature parameter
Bug description data analysis example fail to work with gemini pro. as of now only web search researcher role working with gemini pro
Bug solved method python3 data_analysis.py
Environment information
- LLM type and model name: Gemini pro
- System version:
- Python version: 3.9
Screenshots or logs
python3 data_analysis.py
2024-03-25 18:02:03.871 | INFO | metagpt.const:get_metagpt_package_root:29 - Package root set to /Users/samsaha2
[
{
"task_id": "1",
"dependent_task_ids": [],
"instruction": "Download the TruthfulQA dataset from GitHub."
},
{
"task_id": "2",
"dependent_task_ids": [
"1"
],
"instruction": "Load the dataset into a data analysis tool."
},
{
"task_id": "3",
"dependent_task_ids": [
"2"
],
"instruction": "Perform data analysis on the dataset."
},
{
"task_id": "4",
"dependent_task_ids": [
"3"
],
"instruction": "Create plots to visualize the results of the data analysis."
},
{
"task_id": "5",
"dependent_task_ids": [
"4"
],
"instruction": "Share the analysis and plots with others."
}
]
2024-03-25 18:02:15.630 | INFO | metagpt.utils.cost_manager:update_cost:52 - Total running cost: $0.000 | Max budget: $10.000 | Current cost: $0.000, prompt_tokens: 255, completion_tokens: 245 2024-03-25 18:02:15.632 | INFO | metagpt.roles.role:_plan_and_act:494 - ready to take on task task_id='1' dependent_task_ids=[] instruction='Download the TruthfulQA dataset from GitHub.' task_type='' code='' result='' is_success=False is_finished=False 2024-03-25 18:02:15.632 | INFO | metagpt.roles.di.data_interpreter:_write_code:79 - ready to WriteCodeWithoutTools 2024-03-25 18:02:15.640 | WARNING | metagpt.utils.common:wrapper:572 - There is a exception in role's execution, in order to resume, we delete the newest role communication message in the role's memory. Traceback (most recent call last): File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/site-packages/metagpt/utils/common.py", line 563, in wrapper return await func(self, *args, **kwargs) File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/site-packages/metagpt/roles/role.py", line 558, in run rsp = await self.react() File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/site-packages/metagpt/roles/role.py", line 529, in react rsp = await self._plan_and_act() File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/site-packages/metagpt/roles/role.py", line 497, in _plan_and_act task_result = await self._act_on_task(task) File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/site-packages/metagpt/roles/di/data_interpreter.py", line 46, in _act_on_task code, result, is_success = await self._write_and_exec_code() File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/site-packages/metagpt/roles/di/data_interpreter.py", line 56, in _write_and_exec_code code, cause_by = await self._write_code() File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/site-packages/metagpt/roles/di/data_interpreter.py", line 83, in _write_code code = await todo.run(context=context, plan=self.planner.plan, temperature=0.0) File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/site-packages/metagpt/actions/di/write_analysis_code.py", line 52, in run rsp = await self.llm.aask_code(messages, **kwargs) TypeError: aask_code() got an unexpected keyword argument 'temperature'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/samsaha2/data_analysis.py", line 17, in
What is the command you used to install metagpt?
Hello @geekan , I have used "pip install --upgrade metagpt" to install for google search etc I had to install other bunch of packages. I downloaded the data_analysis.py from GitHub and running as below.
python3 data_analysis.py
My requirement is little different as below. " requirement = "Run data analysis on https://github.com/sylinrl/TruthfulQA dataset, share your analysis and include plots" "
This issue has been fixed in main
branch.
I did a git pull following is my version.
5e789715..02e0eb0a code_interpreter -> origin/code_interpreter
data analysis still does not run. here is the error.
`[
{
"task_id": "1",
"dependent_task_ids": [],
"instruction": "Load the TruthfulQA dataset and examine the data",
"task_type": "eda"
},
{
"task_id": "2",
"dependent_task_ids": ["1"],
"instruction": "Analyze the data to identify trends and patterns",
"task_type": "eda"
},
{
"task_id": "3",
"dependent_task_ids": ["2"],
"instruction": "Create visualizations and plots to highlight key insights",
"task_type": "other"
}
]
2024-03-27 11:32:18.321 | WARNING | metagpt.utils.common:wrapper:649 - There is a exception in role's execution, in order to resume, we delete the newest role communication message in the role's memory.
Traceback (most recent call last):
File "/Users/samsaha2/MetaGPT/metagpt/utils/common.py", line 640, in wrapper
return await func(self, *args, **kwargs)
File "/Users/samsaha2/MetaGPT/metagpt/roles/role.py", line 550, in run
rsp = await self.react()
File "/Users/samsaha2/MetaGPT/metagpt/roles/role.py", line 521, in react
rsp = await self._plan_and_act()
File "/Users/samsaha2/MetaGPT/metagpt/roles/di/data_interpreter.py", line 89, in _plan_and_act
rsp = await super()._plan_and_act()
File "/Users/samsaha2/MetaGPT/metagpt/roles/role.py", line 481, in _plan_and_act
await self.planner.update_plan(goal=goal)
File "/Users/samsaha2/MetaGPT/metagpt/strategy/planner.py", line 89, in update_plan
update_plan_from_rsp(rsp=rsp, current_plan=self.plan)
File "/Users/samsaha2/MetaGPT/metagpt/actions/di/write_plan.py", line 55, in update_plan_from_rsp
rsp = json.loads(rsp)
File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Users/samsaha2/miniconda3/envs/metagpt/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:`
how about try to use main branch?
I recommend using main, too. From your log, the original temperature issue is fixed, which is good. The problem is Gemini did not follow the instruction to generate response in a valid json-format string. Maybe close this issue and raise a different issue asking for auto repairing Gemini response if Gemini fails to adhere to instruction?
I ran data analysis with claude and the above error occurred.
Here is the branch details.
git branch
- main
MetaGPT % git status On branch main Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
` #llm: #api_type: "gemini" #api_key: "" #model: "gemini-pro" #base_url: "https://generativelanguage.googleapis.com/v1beta/models/"
llm: api_type: "anthropic" api_key: "" model: "claude-3-opus-20240229" base_url: "https://api.anthropic.com" `