Commit 391dc38 1 parent c90fc70 commit 391dc38 Copy full SHA for 391dc38
File tree 2 files changed +55
-0
lines changed
app/components/agent/logic/tools
2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { tool } from 'litlytics' ;
2
+ import { z } from 'zod' ;
3
+ import { ToolDefinition } from '../types' ;
4
+
5
+ const description = `Function description: Execute current pipeline with all documents` ;
6
+
7
+ export const runPipeline : ToolDefinition = {
8
+ name : 'runPipeline' ,
9
+ description,
10
+ create : ( {
11
+ litlytics,
12
+ setPipeline,
13
+ agentMessages,
14
+ messages,
15
+ resolve,
16
+ reject,
17
+ } ) =>
18
+ tool ( {
19
+ description,
20
+ parameters : z . object ( {
21
+ execute : z . boolean ( ) ,
22
+ } ) ,
23
+ execute : async ( ) => {
24
+ try {
25
+ // run pipeline
26
+ const newPipeline = await litlytics . runPipeline ( ) ;
27
+ setPipeline ( newPipeline ) ;
28
+ // generate a response
29
+ const agentMessagesWithResult = agentMessages . concat ( [
30
+ {
31
+ content : `Pipeline executed. Results:
32
+ ${ newPipeline . results ?. map ( ( r ) => '- ' + r . result ) ?. join ( '\n' ) }
33
+
34
+ Notify user. Be brief.` ,
35
+ role : 'system' ,
36
+ } ,
37
+ ] ) ;
38
+ const result = await litlytics . runPromptFromMessages ( {
39
+ messages : agentMessagesWithResult ,
40
+ } ) ;
41
+ resolve (
42
+ messages . concat ( {
43
+ id : String ( messages . length ) ,
44
+ from : 'assistant' ,
45
+ text : result . result ,
46
+ } )
47
+ ) ;
48
+ } catch ( err ) {
49
+ reject ( err as Error ) ;
50
+ }
51
+ } ,
52
+ } ) ,
53
+ } ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { analyzeDocuments } from './analyzeDocs';
3
3
import { createSuggestedPipeline } from './createSuggestedPipeline' ;
4
4
import { editStep } from './editStep' ;
5
5
import { refinePipeline } from './refinePipeline' ;
6
+ import { runPipeline } from './runPipeline' ;
6
7
import { suggestPipeline } from './suggestPipeline' ;
7
8
import { testStep } from './testStep' ;
8
9
@@ -14,4 +15,5 @@ export const agentTools = [
14
15
addNewStep ,
15
16
editStep ,
16
17
testStep ,
18
+ runPipeline ,
17
19
] ;
You can’t perform that action at this time.
0 commit comments