yarn add @receptron/graphai_express
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));
curl -X POST -H "Content-Type: application/json" -d '{"params": {"message" : "hello"}}' http://localhost:8085/api/agents/echoAgent
T.B.D.
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