Skip to content

Commit 8cd9738

Browse files
committed
Extend agent functionality to allow full pipeline assembly
1 parent 6bf8b9a commit 8cd9738

File tree

3 files changed

+85
-8
lines changed

3 files changed

+85
-8
lines changed

app/components/agent/Agent.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function AgentUI() {
88
<Chat />
99
</div>
1010
<div className="flex flex-1">
11-
<PipelineBuilder className="w-full h-full pt-6 p-3" />
11+
<PipelineBuilder className="w-full h-full overflow-auto pt-6 p-3" />
1212
</div>
1313
</div>
1414
);

app/components/agent/Chat.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ export function Chat() {
5656
}, [messages]);
5757

5858
const sendMessage = async () => {
59-
const inputMessage = input;
59+
const inputMessage = input.trim();
60+
// do nothing if there's no user message
61+
if (!inputMessage.length) {
62+
return;
63+
}
6064
// reset input
6165
setInput('');
6266
// append user message to messages

app/components/agent/agent.ts

+79-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ You are Lit - a friendly assistant and an expert in data science.
77
88
Your task is to help user design a text document processing pipeline using low-code platform called LitLytics.
99
LitLytics allows creating custom text document processing pipelines using custom processing steps.
10+
LitLytics supports text documents and .csv, .doc(x), .pdf, .txt text files.
1011
1112
You have access to following LitLytics functions:
12-
- Suggest a list of possible pipelines that can be applied to user's documents
13-
- Generate a new pipeline for processing documents for given task from user
14-
- Refine suggested pipeline for processing documents
13+
- Suggest a list of possible pipelines that can be applied to user's documents or files
14+
- Suggest a new pipeline for processing documents for given task from user
15+
- Refine suggested pipeline using user request
16+
- Assemble suggested pipeline
1517
- Add a new step to pipeline
1618
- Edit a step in the pipeline
1719
- Test a step in the pipeline
@@ -57,7 +59,7 @@ export const askAgent = async ({
5759
// generate tools
5860
const tools: LLMArgs['tools'] = {
5961
analyzeDocuments: tool({
60-
description: `Suggest a list of possible pipelines that can be applied to user's documents.`,
62+
description: `Suggest a list of possible pipelines that can be applied to user's documents`,
6163
parameters: z.object({
6264
suggest: z.boolean(),
6365
}),
@@ -87,8 +89,8 @@ Generate a text description for user.`,
8789
);
8890
},
8991
}),
90-
generatePipeline: tool({
91-
description: `Generate a new pipeline for processing documents for given task from user.`,
92+
suggestPipeline: tool({
93+
description: `Suggest a new pipeline for processing documents for given task from user`,
9294
parameters: z.object({
9395
task: z.string(),
9496
}),
@@ -121,6 +123,77 @@ Ask a user if that look fine.`,
121123
);
122124
},
123125
}),
126+
refinePipeline: tool({
127+
description: `Refine suggested pipeline using user request`,
128+
parameters: z.object({
129+
refineRequest: z.string(),
130+
}),
131+
execute: async ({ refineRequest }) => {
132+
// run task
133+
const newPipeline = await litlytics.refinePipeline({
134+
refineRequest: refineRequest,
135+
});
136+
setPipeline(newPipeline);
137+
// generate a response
138+
const agentMessagesWithResult = agentMessages.concat([
139+
{
140+
content: `Refined pipeline from function execution:
141+
${newPipeline.pipelinePlan}
142+
143+
Ask a user if that look fine.`,
144+
role: 'system',
145+
},
146+
]);
147+
const result = await litlytics.runPromptFromMessages({
148+
messages: agentMessagesWithResult,
149+
});
150+
resolve(
151+
messages.concat({
152+
id: String(messages.length),
153+
from: 'assistant',
154+
text: result.result,
155+
})
156+
);
157+
},
158+
}),
159+
createSuggestedPipeline: tool({
160+
description: `Assemble suggested pipeline`,
161+
parameters: z.object({
162+
assemble: z.boolean(),
163+
}),
164+
execute: async () => {
165+
// run task
166+
// generate plan from LLM
167+
const newPipeline = await litlytics.pipelineFromText(
168+
({ step, totalSteps }) => {
169+
if (step > totalSteps) {
170+
// setProgress('');
171+
return;
172+
}
173+
174+
// setProgress(`Generating steps: ${step} / ${totalSteps}`);
175+
}
176+
);
177+
setPipeline(newPipeline);
178+
// generate a response
179+
const agentMessagesWithResult = agentMessages.concat([
180+
{
181+
content: `Pipeline assembled. Notify user. Be brief.`,
182+
role: 'system',
183+
},
184+
]);
185+
const result = await litlytics.runPromptFromMessages({
186+
messages: agentMessagesWithResult,
187+
});
188+
resolve(
189+
messages.concat({
190+
id: String(messages.length),
191+
from: 'assistant',
192+
text: result.result,
193+
})
194+
);
195+
},
196+
}),
124197
};
125198

126199
// execute request

0 commit comments

Comments
 (0)