ykhli / cat-town

A custom AI-town with cats. Based on https://github.com/a16z-infra/AI-town
https://cat-town.fly.dev/
MIT License
118 stars 10 forks source link

Add delay function to slow down conversations in agent.ts #4

Open sweep-ai[bot] opened 1 year ago

sweep-ai[bot] commented 1 year ago

Description

This PR adds a delay function to slow down conversations in the agent.ts file. The delay function pauses the execution of the conversation for a specified period of time after each message is sent.

Summary of Changes

Fixes #2.


To checkout this PR branch, run the following command in your terminal:

git checkout sweep/add-delay-function

To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.

wwzeng1 commented 1 year ago

./lib/utils does not exist, please create a new delay function and use that instead

sweep-ai[bot] commented 1 year ago

./lib/utils does not exist, please create a new delay function and use that instead

Hi @wwzeng1,

I decided to make the following changes:

File Path Proposed Changes
convex/agent.ts Modify convex/agent.ts with contents:
* Remove the import statement for the sleep function from the utils file in the lib directory.
• Create a new function named "delay" at the top of the file. This function should take a single parameter, "ms", which represents the number of milliseconds to delay. The function should return a new Promise that resolves after the specified number of milliseconds using the setTimeout method.
• Replace the call to the sleep function after each message is sent in the handleAgentInteraction function with a call to the new delay function.