diff --git a/apps/rowboat/app/actions/copilot.actions.ts b/apps/rowboat/app/actions/copilot.actions.ts index 94550b16..06634353 100644 --- a/apps/rowboat/app/actions/copilot.actions.ts +++ b/apps/rowboat/app/actions/copilot.actions.ts @@ -2,10 +2,10 @@ import { CopilotAPIRequest, CopilotChatContext, CopilotMessage, + DataSourceSchemaForCopilot, } from "../lib/types/copilot_types"; import { Workflow} from "../lib/types/workflow_types"; -import { DataSource } from "@/src/entities/models/data-source"; import { z } from 'zod'; import { projectAuthCheck } from "./project.actions"; import { redisClient } from "../lib/redis"; @@ -23,7 +23,7 @@ export async function getCopilotResponseStream( messages: z.infer[], current_workflow_config: z.infer, context: z.infer | null, - dataSources?: z.infer[] + dataSources?: z.infer[] ): Promise<{ streamId: string; } | { billingError: string }> { diff --git a/apps/rowboat/app/lib/copilot/copilot.ts b/apps/rowboat/app/lib/copilot/copilot.ts index e2313a75..7eec120d 100644 --- a/apps/rowboat/app/lib/copilot/copilot.ts +++ b/apps/rowboat/app/lib/copilot/copilot.ts @@ -2,8 +2,7 @@ import z from "zod"; import { createOpenAI } from "@ai-sdk/openai"; import { generateObject, streamText, tool } from "ai"; import { Workflow, WorkflowTool } from "../types/workflow_types"; -import { CopilotChatContext, CopilotMessage } from "../types/copilot_types"; -import { DataSource } from "@/src/entities/models/data-source"; +import { CopilotChatContext, CopilotMessage, DataSourceSchemaForCopilot } from "../types/copilot_types"; import { PrefixLogger } from "../utils"; import zodToJsonSchema from "zod-to-json-schema"; import { COPILOT_INSTRUCTIONS_EDIT_AGENT } from "./copilot_edit_agent"; @@ -101,7 +100,7 @@ ${JSON.stringify(workflow)} `; } -function getDataSourcesPrompt(dataSources: z.infer[]): string { +function getDataSourcesPrompt(dataSources: z.infer[]): string { let prompt = ''; if (dataSources.length > 0) { const simplifiedDataSources = dataSources.map(ds => ({ @@ -273,7 +272,7 @@ export async function* streamMultiAgentResponse( context: z.infer | null, messages: z.infer[], workflow: z.infer, - dataSources: z.infer[] + dataSources: z.infer[] ): AsyncIterable> { const logger = new PrefixLogger('copilot /stream'); logger.log('context', context); diff --git a/apps/rowboat/app/lib/types/copilot_types.ts b/apps/rowboat/app/lib/types/copilot_types.ts index 19fdb6d4..7758a620 100644 --- a/apps/rowboat/app/lib/types/copilot_types.ts +++ b/apps/rowboat/app/lib/types/copilot_types.ts @@ -3,6 +3,13 @@ import { Workflow } from "./workflow_types"; import { Message } from "./types"; import { DataSource } from "@/src/entities/models/data-source"; +export const DataSourceSchemaForCopilot = DataSource.pick({ + id: true, + name: true, + description: true, + data: true, +}); + export const CopilotUserMessage = z.object({ role: z.literal('user'), content: z.string(), @@ -52,7 +59,7 @@ export const CopilotAPIRequest = z.object({ messages: z.array(CopilotMessage), workflow: Workflow, context: CopilotChatContext.nullable(), - dataSources: z.array(DataSource).optional(), + dataSources: z.array(DataSourceSchemaForCopilot).optional(), }); export const CopilotAPIResponse = z.union([ z.object({