AI-Engineer-Foundation / agent-protocol

Common interface for interacting with AI agents. The protocol is tech stack agnostic - you can use it with any framework for building agents.
https://agentprotocol.ai
MIT License
957 stars 116 forks source link

Added Agent.build() and return `app` for use in serverless environments #99

Closed nalbion closed 6 months ago

nalbion commented 7 months ago

Pull Request

Description

Small refactor to createApi() to return app and optionally not start listening. This allows the JavaScript library to be used from serverless functions in AWS, Google etc.

Checklist

Please review and check the following items to ensure your pull request can be processed smoothly:

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **agentprotocolai** | ⬜️ Ignored ([Inspect](https://vercel.com/ai-engineers-foundation/agentprotocolai/8jP4NH4q3jDBp6fRmoh8XYGSsCJy)) | [Visit Preview](https://agentprotocolai-git-fork-nalbion-main-ai-engineers-foundation.vercel.app) | | Feb 14, 2024 7:31am |
jzanecook commented 6 months ago

Hey @nalbion I'm trying to run this and I'm running into the following error using the minimal example:

❯ ts-node minimal.ts
Agent listening at http://localhost:8000
Internal Server Error: /response must be object
    at ResponseValidator._validate (/mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/middlewares/openapi.response.validator.ts:201:13)
    at /mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/middlewares/openapi.response.validator.ts:73:23
    at ServerResponse.json_hook (/mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/framework/modded.express.mung.ts:39:16)
    at /mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/agent-protocol/src/agent.ts:100:25
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
task: d49ea465-d956-47fe-9ded-2d2753ef065d
step: Write the word 'Washington' to a .txt file
step: y
task: e650d874-7de7-4236-9c0f-20198e605ece
Internal Server Error: /response must be object
    at ResponseValidator._validate (/mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/middlewares/openapi.response.validator.ts:201:13)
    at /mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/middlewares/openapi.response.validator.ts:73:23
    at ServerResponse.json_hook (/mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/framework/modded.express.mung.ts:39:16)
    at /mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/agent-protocol/src/agent.ts:100:25
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
task: 8c7abfce-7f2f-4ee5-8fc3-d7185ecbc8db
Internal Server Error: /response must be object
    at ResponseValidator._validate (/mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/middlewares/openapi.response.validator.ts:201:13)
    at /mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/middlewares/openapi.response.validator.ts:73:23
    at ServerResponse.json_hook (/mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/express-openapi-validator/src/framework/modded.express.mung.ts:39:16)
    at /mnt/sda1/home/z/Documents/Projects/RAW/agent-protocol/packages/sdk/js/node_modules/agent-protocol/src/agent.ts:100:25
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
task: 562e4515-78e0-46de-826c-fc5568f14429

Do you think you could merge in some of the new changes to the js sdk and verify that this is an issue on your side as well?


Nevermind, I didn't use a local import for the minimal example. This is working.