mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-06 05:42:37 +02:00
agents: add sse scaffolding
This commit is contained in:
parent
e725fc6276
commit
b131c1768e
6 changed files with 64 additions and 8 deletions
|
|
@ -66,17 +66,14 @@ export async function scrapeWebpage(url: string): Promise<z.infer<typeof Webpage
|
|||
};
|
||||
}
|
||||
|
||||
export async function getAssistantResponse(
|
||||
projectId: string,
|
||||
request: z.infer<typeof AgenticAPIChatRequest>,
|
||||
): Promise<{
|
||||
export async function getAssistantResponse(request: z.infer<typeof AgenticAPIChatRequest>): Promise<{
|
||||
messages: z.infer<typeof apiV1.ChatMessage>[],
|
||||
state: unknown,
|
||||
rawRequest: unknown,
|
||||
rawResponse: unknown,
|
||||
}> {
|
||||
await projectAuthCheck(projectId);
|
||||
if (!await check_query_limit(projectId)) {
|
||||
await projectAuthCheck(request.projectId);
|
||||
if (!await check_query_limit(request.projectId)) {
|
||||
throw new QueryLimitError();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ export async function POST(
|
|||
// get assistant response
|
||||
const { agents, tools, prompts, startAgent } = convertWorkflowToAgenticAPI(workflow);
|
||||
const request: z.infer<typeof AgenticAPIChatRequest> = {
|
||||
projectId,
|
||||
messages: convertFromApiToAgenticApiMessages(reqMessages),
|
||||
state: currentState,
|
||||
agents,
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ export async function POST(
|
|||
let state: unknown = chat.agenticState ?? { last_agent_name: startAgent };
|
||||
|
||||
const request: z.infer<typeof AgenticAPIChatRequest> = {
|
||||
projectId: session.projectId,
|
||||
messages: convertToAgenticAPIChatMessages([systemMessage, ...messages, ...unsavedMessages]),
|
||||
state,
|
||||
agents,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export const AgenticAPITool = WorkflowTool
|
|||
})
|
||||
|
||||
export const AgenticAPIChatRequest = z.object({
|
||||
projectId: z.string(),
|
||||
messages: z.array(AgenticAPIChatMessage),
|
||||
state: z.unknown(),
|
||||
agents: z.array(AgenticAPIAgent),
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ export function Chat({
|
|||
setFetchResponseError(null);
|
||||
const { agents, tools, prompts, startAgent } = convertWorkflowToAgenticAPI(workflow);
|
||||
const request: z.infer<typeof AgenticAPIChatRequest> = {
|
||||
projectId,
|
||||
messages: convertToAgenticAPIChatMessages([{
|
||||
role: 'system',
|
||||
content: systemMessage || '',
|
||||
|
|
@ -116,7 +117,7 @@ export function Chat({
|
|||
setLastAgenticResponse(null);
|
||||
|
||||
try {
|
||||
const response = await getAssistantResponse(projectId, request);
|
||||
const response = await getAssistantResponse(request);
|
||||
if (ignore) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue