-
Couldn't load subscription status.
- Fork 1
PR for KingHan韩尚典 #JlG0oiq3uWMWcGGUr2HC #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Logging: initLogging: initLogging: on_chain_startSerialized:{ inputs:{ Logging: on_chat_model_startSerialized:{ message:[[SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), HumanMessage(content='You can use the ability with id Logging: on_llm_endgenerations=[[ChatGeneration(text='', generation_info={'finish_reason': 'function_call'}, message=AIMessage(content='', additional_kwargs={'function_call': {'name': 'run_ability', 'arguments': '{\n "ability_id": "gpt_engineer",\n "ability_args": "Write me a fun snake game in Python."\n}'}}, example=False))]] llm_output={'token_usage': <OpenAIObject at 0x7f579c6109b0> JSON: { Logging: on_agent_actionTool used:run_ability Tool input:{ Additional log:Invoking: Logging: on_chat_model_startSerialized:{ message:[[SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), HumanMessage(content='You can use the ability with id Logging: on_llm_endgenerations=[[ChatGeneration(text='', generation_info={'finish_reason': 'function_call'}, message=AIMessage(content='', additional_kwargs={'function_call': {'name': 'run_ability', 'arguments': '{\n "ability_id": "8x5joFx3uMt4CcLnoc8s",\n "ability_args": "Design the software of a fun snake game in Python."\n}'}}, example=False))]] llm_output={'token_usage': <OpenAIObject at 0x7f579c611d30> JSON: { Logging: on_agent_actionTool used:run_ability Tool input:{ Additional log:Invoking: Logging: on_chat_model_startSerialized:{ message:[[SystemMessage(content='You are a helpful AI assistant.', additional_kwargs={}), HumanMessage(content='You can use the ability with id Logging: on_llm_endgenerations=[[ChatGeneration(text='Here is the Python code for a simple snake game:\n\n Logging: on_agent_finishReturn values:{ Additional logs:Here is the Python code for a simple snake game: import random
import curses
class Snake:
def __init__(self, window, start_pos):
self.body = [start_pos]
self.window = window
def move(self, direction):
head = self.body[0]
new_head = (head[0] + direction[0], head[1] + direction[1])
self.body.insert(0, new_head)
def eat(self, food):
if self.body[0] == food.pos:
return True
else:
self.body.pop()
return False
def hit_itself(self):
return self.body[0] in self.body[1:]
class Food:
def __init__(self, window, pos=None):
self.window = window
if pos is None:
self.pos = self.random_pos()
else:
self.pos = pos
def random_pos(self):
return (random.randint(1, self.window.getmaxyx()[0]-2), random.randint(1, self.window.getmaxyx()[1]-2))
class Game:
def __init__(self, window):
self.window = window
self.snake = Snake(window, (10, 10))
self.food = Food(window)
def game_loop(self):
key = curses.KEY_RIGHT
while True:
self.window.clear()
self.window.border(0)
self.snake.move(self.key_to_direction(key))
self.window.addch(self.food.pos[0], self.food.pos[1], '#')
for idx, pos in enumerate(self.snake.body):
self.window.addch(pos[0], pos[1], '*' if idx == 0 else 'o')
if self.snake.hit_itself():
break
if self.snake.eat(self.food):
self.food = Food(self.window)
key = self.window.getch()
if key == -1:
continue
new_direction = self.key_to_direction(key)
if new_direction[0]*self.key_to_direction(key)[0] + new_direction[1]*self.key_to_direction(key)[1] != 0:
key = key
def key_to_direction(self, key):
return {
curses.KEY_UP: (-1, 0),
curses.KEY_DOWN: (1, 0),
curses.KEY_LEFT: (0, -1),
curses.KEY_RIGHT: (0, 1)
}.get(key, (0, 0))
def main(stdscr):
curses.curs_set(0)
stdscr.nodelay(1)
stdscr.timeout(100)
game = Game(stdscr)
game.game_loop()
if __name__ == "__main__":
curses.wrapper(main)To run the game, you need to install the curses library and then run the Python file: # a) Install dependencies
pip install --user curses
# b) Run all necessary parts of the codebase
python snake_game.pyThe software design of the snake game includes the following components:
The game is implemented in a single Python file for simplicity. The game uses the curses library to handle the terminal graphics and user input. The game is started by calling the The software design also includes a competitive analysis, user stories, product goals, requirement analysis, UI design draft, implementation approach, Python package name, file list, data structures and interface definitions, and program call flow.## Logging: on_chain_end |
You can use the ability with id
gpt_engineeras an AI software engineer, theability_argsfor this ability must be non-empty. Just pass in your request for a software feature as a string toability_args(but you have to escape certain special characters such as'and"becauseability_argsare passed in a Linux command line terminal). Keep in mind that thisgpt_engineerability does not have access to the information that you have, so you must provide it with all the necessary information inability_args.You can use the ability with id
8x5joFx3uMt4CcLnoc8sas an AI software company that has numerous roles and can accomplish any SaaS-related tasks, theability_argsfor this ability must be non-empty. Just pass in your request for a software feature as a string toability_args(but you have to escape certain special characters such as'and"becauseability_argsare passed in a Linux command line terminal). Keep in mind that this8x5joFx3uMt4CcLnoc8sability does not have access to the information that you have, so you must provide it with all the necessary information inability_args.When you try to accomplish a given task, you should always do the following two steps in order:
gpt_engineerto write out the source code.8x5joFx3uMt4CcLnoc8sto first design the software of the product.mdfiles andmmd(nmermaid) files.Now do the following task:
Write me a fun snake game in Python.
Gothub's Answer: Here is the Python code for a simple snake game:
To run the game, you need to install the curses library and then run the Python file:
The software design of the snake game includes the following components:
Snake: This class represents the snake, which moves in a certain direction and can eat food to grow longer.Food: This class represents the food that the snake can eat.Game: This class handles the game logic, including the game loop, user input, and game over condition.The game is implemented in a single Python file for simplicity. The game uses the curses library to handle the terminal graphics and user input. The game is started by calling the
mainfunction, which sets up the curses environment and starts the game loop.The software design also includes a competitive analysis, user stories, product goals, requirement analysis, UI design draft, implementation approach, Python package name, file list, data structures and interface definitions, and program call flow.