RSS Amplifier

BLOG.MOIKAS · Oct 8, 2024

A Simple Rest API for the Agent

0
Sign in to vote or save

Moikapy · BLOG.MOIKAS

Last, I left off. We created our Agent. It was simple but enough to give you something to start with.

In this episode, we create a simple Rest API for our Agent. Not enough for production, but enough to point you in the right direction. For the remainder of the article, I assume you know how to use JavaScript or TypeScript and briefly cover what I changed in the project.

Finished Example:

https://github.com/Moikapy/xander/tree/api

For this implementation, we will use Express and Body-parser. Our server will use Express, and Body-parser will process body data sent via HTTP.

bash

# Dependencies
npm i express body-parser --save

I started by creating the chat route.

The bulk of this logic comes from the main.ts file from the last example.

You can update the routes to suit your use case; in this example, mine will be: '/api/v1/chat'. I will request the model, temperature, system_mesage, max_tokens, and prompt via the body of our rest call.

You can alw…

Read the original on moikas.substack.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.