Skip to content

feat: add runAgent functionality to execute agent commands and update…#6

Open
ducheharsh wants to merge 1 commit into
mainfrom
feat/agent-gallery
Open

feat: add runAgent functionality to execute agent commands and update…#6
ducheharsh wants to merge 1 commit into
mainfrom
feat/agent-gallery

Conversation

@ducheharsh

Copy link
Copy Markdown
Contributor

This pull request introduces support for tracking and updating user credit balances when interacting with agents, as well as a new endpoint for running agents. The main changes include schema updates for user credits, a new API route and controller method for running agents, and logic to decrement user credits based on agent usage.

User credit management:

  • Added creditBalance and creditBalanceLastUpdated fields to the user table and Prisma schema, with defaults set for new users. [1] [2]

Agent execution and credit deduction:

  • Implemented runAgent method in AgentService to execute an agent, calculate credit usage based on agent costs and token usage, and update the user's credit balance accordingly.
  • Added runAgent method to AgentController and exposed a new POST endpoint /agents/:id/run in agent.route.ts for running agents. [1] [2]

Agent CRUD improvements:

  • Updated agent deletion and lookup logic to ensure operations are only performed by the agent's owner by matching both id and userId. [1] [2]

Type consistency and validation:

  • Improved handling of agent cost fields by ensuring numeric conversion and string consistency in controller logic. [1] [2]… user credit balance

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants