@receptron/graphai_express
TypeScript icon, indicating that this package has built-in type declarations

0.0.23 • Public • Published

GraphAI express middleware.

Install

yarn add @receptron/graphai_express

Usage

import express from "express";
import * as agents from "@graphai/agents";
import { agentDispatcher, nonStreamAgentDispatcher, streamAgentDispatcher, agentsList, agentDoc } from "@receptron/graphai_express";
import { AgentFunctionInfoDictionary } from "graphai";

const agentDictionary: AgentFunctionInfoDictionary = agents;
const hostName = "https://example.net";
const apiPrefix = "/api/agents";

app.get(apiPrefix + "/:agentId", agentDoc(agentDictionary, hostName, apiPrefix)); // each API(agent) document
app.get(apiPrefix + "/", agentsList(agentDictionary, hostName, apiPrefix));  // API(agent) list

// non stream and strwam
app.post(apiPrefix + "/:agentId", agentDispatcher(agentDictionary));

//  non stream
app.post(apiPrefix + "/nonstream/:agentId", nonStreamAgentDispatcher(agentDictionary));

//  stream
app.post(apiPrefix + "/stream/:agentId", streamAgentDispatcher(agentDictionary));

Test from curl

curl -X POST -H "Content-Type: application/json" -d '{"params": {"message" : "hello"}}' http://localhost:8085/api/agents/echoAgent

from GraphAI Client

T.B.D.

for this middleware development

git clone https://github.com/receptron/graphai_utils
cd packages/express
yarn install
yarn run server # then run test express server
yarn run test_stream

Readme

Keywords

none

Package Sidebar

Install

npm i @receptron/graphai_express

Weekly Downloads

152

Version

0.0.23

License

MIT

Unpacked Size

9.73 kB

Total Files

4

Last publish

Collaborators

  • snakajima
  • isamu