mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-03 12:22:38 +02:00
Allow mocking tools over API and python sdk
This commit is contained in:
parent
c72728bf3d
commit
8ffdb66e0f
8 changed files with 54 additions and 18 deletions
|
|
@ -51,6 +51,7 @@ export async function POST(
|
|||
return Response.json({ error: `Invalid request body: ${result.error.message}` }, { status: 400 });
|
||||
}
|
||||
const reqMessages = result.data.messages;
|
||||
const mockToolOverrides = result.data.mockTools;
|
||||
|
||||
// fetch published workflow id
|
||||
const project = await projectsCollection.findOne({
|
||||
|
|
@ -80,6 +81,11 @@ export async function POST(
|
|||
return Response.json({ error: "Workflow not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
// override mock instructions
|
||||
if (mockToolOverrides) {
|
||||
workflow.mockTools = mockToolOverrides;
|
||||
}
|
||||
|
||||
// check billing authorization
|
||||
if (USE_BILLING && billingCustomerId) {
|
||||
const agentModels = workflow.agents.reduce((acc, agent) => {
|
||||
|
|
|
|||
|
|
@ -797,7 +797,13 @@ async function* emitGreetingTurn(logger: PrefixLogger, workflow: z.infer<typeof
|
|||
function createTools(logger: PrefixLogger, workflow: z.infer<typeof Workflow>, toolConfig: Record<string, z.infer<typeof WorkflowTool>>): Record<string, Tool> {
|
||||
const tools: Record<string, Tool> = {};
|
||||
for (const [toolName, config] of Object.entries(toolConfig)) {
|
||||
if (config.isMcp) {
|
||||
if (workflow.mockTools?.[toolName]) {
|
||||
tools[toolName] = createMockTool(logger, {
|
||||
...config,
|
||||
mockInstructions: workflow.mockTools?.[toolName], // override mock instructions
|
||||
});
|
||||
logger.log(`created mock tool: ${toolName}`);
|
||||
} else if (config.isMcp) {
|
||||
tools[toolName] = createMcpTool(logger, config, workflow.projectId);
|
||||
logger.log(`created mcp tool: ${toolName}`);
|
||||
} else if (config.isComposio) {
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ export const ApiRequest = z.object({
|
|||
state: z.unknown(),
|
||||
workflowId: z.string().nullable().optional(),
|
||||
testProfileId: z.string().nullable().optional(),
|
||||
mockTools: z.record(z.string(), z.string()).nullable().optional(),
|
||||
});
|
||||
|
||||
export const ApiResponse = z.object({
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ export const Workflow = z.object({
|
|||
createdAt: z.string().datetime(),
|
||||
lastUpdatedAt: z.string().datetime(),
|
||||
projectId: z.string(),
|
||||
mockTools: z.record(z.string(), z.string()).optional(), // a dict of toolName => mockInstructions
|
||||
});
|
||||
export const WorkflowTemplate = Workflow
|
||||
.omit({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue