mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-16 18:25:17 +02:00
Context variables (#214)
* move prompts panel to variables * variable shows both name and value * added modal to add variables * removed warning on edits * adding or updating variables only uses the modal * append variable context to agent instructions * add dummy value to the variable values when downloading json * fixed @variable mentions in the instruction editor * change placeholder text for variables when json is imported
This commit is contained in:
parent
981cff3b3f
commit
ab014f788c
8 changed files with 358 additions and 23 deletions
|
|
@ -143,4 +143,24 @@ export const PIPELINE_TYPE_INSTRUCTIONS = (): string => `
|
|||
- Your response should be self-contained and ready to be consumed by the next pipeline step.
|
||||
- Reading the message history will show you the pipeline execution flow up to your step.
|
||||
- These are high level instructions only. The user will provide more specific instructions which will be below.
|
||||
`;
|
||||
`;
|
||||
|
||||
/**
|
||||
* Instructions for providing variable context to agents
|
||||
* Appends variable names and values to agent system prompts
|
||||
*/
|
||||
export const VARIABLES_CONTEXT_INSTRUCTIONS = (variablesList: Array<{name: string, value: string}>): string => {
|
||||
if (!variablesList || variablesList.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const variablesText = variablesList
|
||||
.map(variable => `${variable.name}: ${variable.value}`)
|
||||
.join('\n');
|
||||
|
||||
return `
|
||||
# Variables Context
|
||||
Here is information that is already provided:
|
||||
${variablesText}
|
||||
`;
|
||||
};
|
||||
|
|
@ -9,7 +9,7 @@ import crypto from "crypto";
|
|||
// Internal dependencies
|
||||
import { createTools, createRagTool } from "./agent-tools";
|
||||
import { ConnectedEntity, sanitizeTextWithMentions, Workflow, WorkflowAgent, WorkflowPipeline, WorkflowPrompt, WorkflowTool } from "@/app/lib/types/workflow_types";
|
||||
import { CHILD_TRANSFER_RELATED_INSTRUCTIONS, CONVERSATION_TYPE_INSTRUCTIONS, PIPELINE_TYPE_INSTRUCTIONS, RAG_INSTRUCTIONS, TASK_TYPE_INSTRUCTIONS } from "./agent_instructions";
|
||||
import { CHILD_TRANSFER_RELATED_INSTRUCTIONS, CONVERSATION_TYPE_INSTRUCTIONS, PIPELINE_TYPE_INSTRUCTIONS, RAG_INSTRUCTIONS, TASK_TYPE_INSTRUCTIONS, VARIABLES_CONTEXT_INSTRUCTIONS } from "./agent_instructions";
|
||||
import { PrefixLogger } from "@/app/lib/utils";
|
||||
import { Message, AssistantMessage, AssistantMessageWithToolCalls, ToolMessage } from "@/app/lib/types/types";
|
||||
import { UsageTracker } from "@/app/lib/billing";
|
||||
|
|
@ -99,6 +99,14 @@ function createAgent(
|
|||
): { agent: Agent, entities: z.infer<typeof ConnectedEntity>[] } {
|
||||
const agentLogger = logger.child(`createAgent: ${config.name}`);
|
||||
|
||||
// Extract variables from workflow prompts (variables are stored as prompts with type 'base_prompt')
|
||||
const variables = workflow.prompts
|
||||
.filter(prompt => prompt.type === 'base_prompt')
|
||||
.map(prompt => ({
|
||||
name: prompt.name,
|
||||
value: prompt.prompt
|
||||
}));
|
||||
|
||||
// Combine instructions and examples
|
||||
let instructions = `${RECOMMENDED_PROMPT_PREFIX}
|
||||
|
||||
|
|
@ -122,6 +130,8 @@ ${config.instructions}
|
|||
|
||||
${config.examples ? ('# Examples\n' + config.examples) : ''}
|
||||
|
||||
${VARIABLES_CONTEXT_INSTRUCTIONS(variables)}
|
||||
|
||||
${'-'.repeat(100)}
|
||||
|
||||
${CHILD_TRANSFER_RELATED_INSTRUCTIONS}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue