MetaGPT
MetaGPT copied to clipboard
azure openai api error
I configure the key.yaml as follows:
OPENAI_API_TYPE: "azure"
OPENAI_API_BASE: "https://xxx.openai.azure.com"
OPENAI_API_KEY: "xxx"
OPENAI_API_VERSION: "2023-03-15"
DEPLOYMENT_ID: "gpt-35-turbo"
and run as:
docker run --rm --privileged -v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml -v /opt/metagpt/workspace:/app/metagpt/workspace metagpt/metagpt:v0.3.1 python startup.py "Write a cli snake game"
but run into this error in Windows 11 WSL:
2023-08-18 10:49:24.774 | INFO | metagpt.software_company:invest:39 - Investment: $3.0.
2023-08-18 10:49:24.775 | INFO | metagpt.roles.role:_act:166 - Alice(Product Manager): ready to WritePRD
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 50, in __call__
result = await fn(*args, **kwargs)
File "/app/metagpt/metagpt/actions/action.py", line 57, in _aask_v1
content = await self.llm.aask(prompt, system_msgs)
File "/app/metagpt/metagpt/provider/base_gpt_api.py", line 44, in aask
rsp = await self.acompletion_text(message, stream=True)
File "/app/metagpt/metagpt/provider/openai_api.py", line 32, in wrapper
return await f(*args, **kwargs)
File "/app/metagpt/metagpt/provider/openai_api.py", line 218, in acompletion_text
return await self._achat_completion_stream(messages)
File "/app/metagpt/metagpt/provider/openai_api.py", line 151, in _achat_completion_stream
response = await openai.ChatCompletion.acreate(
File "/usr/local/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 45, in acreate
return await super().acreate(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 217, in acreate
response, _, api_key = await requestor.arequest(
File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 382, in arequest
resp, got_stream = await self._interpret_async_response(result, stream)
File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 726, in _interpret_async_response
self._interpret_response_line(
File "/usr/local/lib/python3.9/site-packages/openai/api_requestor.py", line 763, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: Resource not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/metagpt/startup.py", line 36, in <module>
fire.Fire(main)
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/usr/local/lib/python3.9/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/app/metagpt/startup.py", line 32, in main
asyncio.run(startup(idea, investment, n_round, code_review))
File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/app/metagpt/startup.py", line 20, in startup
await company.run(n_round=n_round)
File "/app/metagpt/metagpt/software_company.py", line 60, in run
await self.environment.run()
File "/app/metagpt/metagpt/environment.py", line 56, in run
await asyncio.gather(*futures)
File "/app/metagpt/metagpt/roles/role.py", line 239, in run
rsp = await self._react()
File "/app/metagpt/metagpt/roles/role.py", line 208, in _react
return await self._act()
File "/app/metagpt/metagpt/roles/role.py", line 167, in _act
response = await self._rc.todo.run(self._rc.important_memory)
File "/app/metagpt/metagpt/actions/write_prd.py", line 145, in run
prd = await self._aask_v1(prompt, "prd", OUTPUT_MAPPING)
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
return await fn(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 47, in __call__
do = self.iter(retry_state=retry_state)
File "/usr/local/lib/python3.9/site-packages/tenacity/__init__.py", line 326, in iter
raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x7f07ad0de670 state=finished raised InvalidRequestError>]
did you actually deploy an model instance named "gpt-35-turbo" in your account? in azure you need to deploy them before you can use them, the name can be anything you want
did you actually deploy an model instance named "gpt-35-turbo" in your account? in azure you need to deploy them before you can use them, the name can be anything you want
Yes, thanks for your reply. It's the key to this error. And after I correct it, and run into this error:
2023-08-20 11:58:51.660 | INFO | metagpt.software_company:invest:39 - Investment: $3.0.
2023-08-20 11:58:51.661 | INFO | metagpt.roles.role:_act:166 - Alice(Product Manager): ready to WritePRD
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/tenacity/_asyncio.py", line 50, in __call__
result = await fn(*args, **kwargs)
File "/app/metagpt/metagpt/actions/action.py", line 62, in _aask_v1
instruct_content = output_class(**parsed_data)
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
## Original Requirements:
The boss wants you to create a command-line interface (CLI) snake game.
## Product Goals:
- Create a fun and engaging snake game that can be played on the command-line interface.
- Provide a simple and intuitive user interface that allows users to easily control the snake.
- Ensure that the game is challenging enough to keep users engaged and coming back for more.
## User Stories:
- As a player, I want to be able to control the snake using simple keyboard commands so that I can focus on playing the game.
- As a player, I want the game to be challenging enough to keep me engaged, but not so difficult that it becomes frustrating.
- As a player, I want to be able to see my score and high score so that I can track my progress.
- As a player, I want the game to be visually appealing so that it is more enjoyable to play.
- As a player, I want the game to have sound effects so that it is more immersive.
## Competitive Analysis:
- Python Snake Game: A simple snake game that can be played on the command-line interface.
- Snake VS Block: A popular mobile game where players control a snake and try to break blocks to score points.
- Slither.io: A multiplayer online game where players control a snake and try to eat as many pellets as possible while avoiding other snakes.
- Snake Game: A classic snake game that can be played on a web browser.
- Snake '97: A mobile game that emulates the classic snake game from the Nokia 3310.
- Snake Mania: A mobile game that adds power-ups and other features to the classic snake game.
- Snake Rattle 'n' Roll: A classic snake game for the Nintendo Entertainment System.
## Competitive Quadrant Chart:
```mermaid
quadrantChart
title Reach and engagement of command-line snake games
x-axis Low Reach --> High Reach
y-axis Low Engagement --> High Engagement
quadrant-1 Nostalgia
quadrant-2 Classic
quadrant-3 Innovative
quadrant-4 Experimental
"Python Snake Game": [0.3, 0.6]
"Our Target Product": [0.5, 0.8]
"Snake Game": [0.4, 0.4]
"Snake '97": [0.6, 0.3]
"Snake Mania": [0.7, 0.5]
"Snake Rattle 'n' Roll": [0.2, 0.2]
"Slither.io": [0.9, 0.9]
Requirement Analysis:
The product should be a command-line interface (CLI) snake game that is fun and engaging to play. It should have simple and intuitive controls, and be challenging enough to keep players engaged. The game should have a visual design that is appealing to players, and should include sound effects to enhance the playing experience.
Requirement Pool:
- End game screen that displays the player's score and high score (P0)
- Simple and intuitive keyboard controls for the snake (P0)
- Randomly generated food for the snake to eat (P0)
- Snake collision detection with walls and itself (P1)
- Sound effects for eating food and colliding with walls or the snake's tail (P1)
UI Design draft:
The game will have a simple layout with the game board taking up most of the screen. The snake will be represented by a series of characters that move across the board. The food will be represented by a different character that appears randomly on the board. The player's score and high score will be displayed at the top of the screen. The game will have a simple color scheme with contrasting colors for the snake, food, and background. The controls will be displayed at the bottom of the screen and will be simple arrow keys for movement.
Anything UNCLEAR:
There are no unclear points.
Original Requirements:
The boss wants you to create a command-line interface (CLI) snake game.
Product Goals:
- Develop a fun and engaging snake game that users can play on the command line.
- Provide a simple and intuitive interface that allows users to control the snake easily.
- Ensure that the game is challenging enough to keep users engaged and coming back for more.
User Stories:
- As a player, I want to be able to control the snake using simple keyboard commands so that I can focus on playing the game.
- As a player, I want the game to be challenging enough to keep me engaged and interested in playing.
- As a player, I want to be able to see my score and progress as I play the game.
- As a player, I want the game to be visually appealing and easy to understand.
- As a player, I want to be able to start a new game easily and quickly.
Competitive Analysis:
- Python Snake Game: A simple snake game written in Python that can be played on the command line.
- Snake CLI: A snake game written in Rust that can be played on the command line.
- Snake Game CLI: A snake game written in C++ that can be played on the command line.
- Snake Game: A classic snake game that can be played on a web browser.
- Snake Zone: A mobile game that allows users to control a snake and eat food to grow longer.
- Snake VS Block: A mobile game that combines snake gameplay with block-breaking mechanics.
- Slither.io: An online multiplayer game that allows users to control a snake and compete against other players.
Competitive Quadrant Chart:
quadrantChart
title Reach and engagement of CLI snake games
x-axis Low Reach --> High Reach
y-axis Low Engagement --> High Engagement
quadrant-1 Rust Snake CLI
quadrant-2 C++ Snake Game CLI
quadrant-3 Python Snake Game
quadrant-4 Our Target Product
"Snake Game": [0.8, 0.8]
"Snake Zone": [0.7, 0.6]
"Snake VS Block": [0.6, 0.5]
"Slither.io": [0.9, 0.9]
Requirement Analysis:
The product should be a CLI snake game that is easy to play and challenging enough to keep users engaged. The game should have a simple interface that allows users to control the snake using keyboard commands. The game should also keep track of the user's score and progress and allow them to start a new game easily.
Requirement Pool:
- End game screen that displays the user's score and allows them to start a new game (P0)
- Keyboard controls for moving the snake (P0)
- Random generation of food for the snake to eat (P0)
- Snake dies if it collides with the wall or its own body (P1)
- Snake grows longer when it eats food (P1)
UI Design draft:
The game will be displayed in the command line interface. The snake will be represented by a series of characters, and the food will be represented by a different character. The user will control the snake using the arrow keys on their keyboard. The score and game status will be displayed at the top of the screen. The game will have a simple and clean design, with a black background and white characters.
Anything UNCLEAR:
There are no unclear points. pydantic.error_wrappers.ValidationError: 5 validation errors for prd Requirement Pool -> 0 value is not a valid tuple (type=type_error.tuple) Requirement Pool -> 1 value is not a valid tuple (type=type_error.tuple) Requirement Pool -> 2 value is not a valid tuple (type=type_error.tuple) Requirement Pool -> 3 value is not a valid tuple (type=type_error.tuple) Requirement Pool -> 4 value is not a valid tuple (type=type_error.tuple)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/metagpt/startup.py", line 36, in
For key.yaml
OPENAI_API_TYPE: "azure"
OPENAI_API_BASE: "https://****.openai.azure.com/"
OPENAI_API_KEY: "*****"
OPENAI_API_VERSION: "0613"
DEPLOYMENT_ID: "gpt-35-turbo"
run python examples/llm_hello_world.py
(ml-env) β MetaGPT git:(main) β python examples/llm_hello_world.py
2023-08-23 10:38:18.759 | INFO | metagpt.config:__init__:44 - Config loading done.
Traceback (most recent call last):
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/examples/llm_hello_world.py", line 31, in <module>
asyncio.run(main())
File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/examples/llm_hello_world.py", line 17, in main
logger.info(await claude.aask('δ½ ε₯½οΌθ―·θΏθ‘θͺζδ»η»'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/metagpt-0.1-py3.11.egg/metagpt/provider/anthropic_api.py", line 29, in aask
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/anthropic/_utils/_utils.py", line 253, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/anthropic/resources/completions.py", line 225, in create
return self._post(
^^^^^^^^^^^
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/anthropic/_base_client.py", line 925, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/anthropic/_base_client.py", line 724, in request
return self._request(
^^^^^^^^^^^^^^
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/anthropic/_base_client.py", line 742, in _request
request = self._build_request(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/anthropic/_base_client.py", line 394, in _build_request
headers = self._build_headers(options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/anthropic/_base_client.py", line 368, in _build_headers
self._validate_headers(headers_dict, custom_headers)
File "/Users/elvizlai/workspace/elvizlai/MetaGPT/ml-env/lib/python3.11/site-packages/anthropic/_client.py", line 159, in _validate_headers
raise TypeError(
TypeError: "Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted"
DEPLOYMENT_ID: "gpt-35-turbo"
check it, make sure your deployment id is "gpt-35-turbo"
This problem actually comes from the poor Instruction Following of gpt-3.5-turbo. gpt-4 basically does not have this problem
(metagpt) D:\AI\metagpt>python startup.py "Write a cli snake game based on pygame" --code_review True 2023-09-19 16:54:26.078 | INFO | metagpt.config:init:44 - Config loading done. 2023-09-19 16:54:28.107 | INFO | metagpt.software_company:invest:39 - Investment: $3.0. 2023-09-19 16:54:28.108 | INFO | metagpt.roles.role:_act:167 - Alice(Product Manager): ready to WritePRD
Original Requirements
The boss has requested the creation of a command-line interface (CLI) snake game based on pygame.
Product Goals
[
"Create a simple and fun CLI snake game using pygame",
"Ensure the game runs smoothly and efficiently",
"Make the game easy to install and play"
]
User Stories
[
"As a user, I want to be able to easily install the game so that I can start playing quickly",
"As a player, I want the game to run smoothly so that I can enjoy the gameplay",
"As a player, I want the controls to be intuitive and responsive so that I can effectively control the snake",
"As a player, I want to be able to see my score so that I can track my progress",
"As a player, I want the game to increase in difficulty as my score increases so that the game remains challenging"
]
Competitive Analysis
[
"Python Snake Game: A simple CLI snake game. It lacks smooth gameplay and advanced features",
"Pygame Snake: A more advanced snake game with a graphical interface. It may be too complex for our target audience",
"CLI Snake: A CLI snake game with a high score feature. It lacks the smooth gameplay we aim for",
"Snake Game: A popular online snake game with a graphical interface. It may be too complex and not CLI-based",
"Terminal Snake: A CLI snake game with smooth gameplay but lacks advanced features"
]
Competitive Quadrant Chart
quadrantChart
title Reach and engagement of campaigns
x-axis Low Reach --> High Reach
y-axis Low Engagement --> High Engagement
quadrant-1 We should expand
quadrant-2 Need to promote
quadrant-3 Re-evaluate
quadrant-4 May be improved
"Python Snake Game": [0.2, 0.3]
"Pygame Snake": [0.7, 0.6]
"CLI Snake": [0.3, 0.4]
"Snake Game": [0.8, 0.7]
"Terminal Snake": [0.4, 0.5]
"Our Target Product": [0.5, 0.6]
Requirement Analysis
The product should be a CLI-based snake game developed using pygame. It should offer smooth gameplay, intuitive controls, and a scoring system. The game should also increase in difficulty as the player's score increases. The game should be easy to install and play.
Requirement Pool
[
("Develop a CLI-based snake game using pygame", "P0"),
("Ensure smooth and responsive gameplay", "P0"),
("Implement intuitive controls for the snake", "P0"),
("Include a scoring system", "P0"),
("Increase game difficulty as score increases", "P1"),
("Ensure easy installation and play", "P0")
]
UI Design draft
The game will be a CLI-based application. The game area will be represented as a grid in the terminal. The snake will be represented by a line of characters that moves around the grid. The food for the snake will be represented by a different character. The score will be displayed at the top of the terminal. The controls will be the arrow keys.
Anything UNCLEAR
There are no unclear points. Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613. 2023-09-19 16:54:50.546 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.068 | Max budget: $3.000 | Current cost: $0.068, prompt_tokens: 845, completion_tokens: 717 2023-09-19 16:54:50.577 | INFO | metagpt.roles.role:_act:167 - Bob(Architect): ready to WriteDesign
Implementation approach
We will use the open-source library pygame for creating the game. The game will be developed in a modular manner with separate classes for the game, the snake, and the food. The game will be controlled via the keyboard arrow keys. The game will start with a single food item and a snake of length one. The snake will grow in length each time it eats food. The game will end when the snake hits the boundary or itself. The score will be displayed on the terminal and will increase each time the snake eats food. The difficulty level will increase as the score increases by reducing the delay between each move of the snake.
Python package name
"cli_snake_game"
File list
[
"main.py",
"game.py",
"snake.py",
"food.py"
]
Data structures and interface definitions
classDiagram
class Game{
+int score
+int level
+bool game_over
+Snake snake
+Food food
+start_game()
+end_game()
+increase_difficulty()
}
class Snake{
+list body
+str direction
+move()
+grow()
+check_collision()
}
class Food{
+tuple position
+generate_food()
}
Game "1" -- "1" Snake: has
Game "1" -- "1" Food: has
Program call flow
sequenceDiagram
participant M as Main
participant G as Game
participant S as Snake
participant F as Food
M->>G: create game
G->>S: create snake
G->>F: create food
M->>G: start game
loop game not over
G->>S: move snake
G->>S: check collision
G->>F: check if food eaten
G->>G: increase score
G->>G: increase difficulty
end
G->>M: end game
Anything UNCLEAR
The requirement is clear to me.
Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613.
2023-09-19 16:55:08.392 | INFO | metagpt.provider.openai_api:update_cost:89 - Total running cost: $0.133 | Max budget: $3.000 | Current cost: $0.065, prompt_tokens: 1240, completion_tokens: 463
C:\Program Files\nodejs\mmdc
C:\Program Files\nodejs\mmdc.cmd
2023-09-19 16:55:08.472 | INFO | metagpt.utils.mermaid:mermaid_to_file:44 - Generating D:\AI\metagpt\workspace\cli_snake_game\resources\competitive_analysis.pdf..
Traceback (most recent call last):
File "D:\AI\metagpt\startup.py", line 72, in
I getting this type of error
i have tested with gpt 4 and gpt 4-32k