File tree Expand file tree Collapse file tree 2 files changed +26
-10
lines changed
Expand file tree Collapse file tree 2 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ import { compose } from "../../packages/compose/dist/main"
22import { forceAgent } from "../../packages/copilot/dist/main"
33import { inspector } from "../../packages/inspector/dist/main"
44
5- export const main = compose ( [ forceAgent ( ) , inspector ( ) ] )
5+ export const main = compose ( [ inspector ( ) , forceAgent ( ) ] )
Original file line number Diff line number Diff line change @@ -5,13 +5,12 @@ interface ForceAgentOptions {
55}
66
77const DEFAULT_SELF_MESSAGE : ForceAgentOptions [ "selfMessage" ] = ( original ) =>
8- `
9- <query>
10- ${ original }
11- </query>
8+ `<query>${ original } </query>
129
13- I will now answer the query
14- ` . trim ( )
10+ I will now answer the query:
11+
12+
13+ `
1514
1615export const forceAgent = ( options : ForceAgentOptions = { } ) : Plugin => {
1716 const selfMessage = options . selfMessage ?? DEFAULT_SELF_MESSAGE
@@ -62,10 +61,27 @@ export const forceAgent = (options: ForceAgentOptions = {}): Plugin => {
6261 }
6362
6463 output . message . role = "assistant"
65- const textPart = output . parts . find ( ( part ) => part . type === "text" )
6664
67- if ( ! textPart ) return
68- textPart . text = selfMessage ( textPart . text )
65+ const textParts = output . parts . filter ( ( part ) => part . type === "text" )
66+ const nonTextParts = output . parts . filter ( ( part ) => part . type !== "text" )
67+
68+ const newPart = textParts . at ( 0 )
69+ if ( ! newPart ) {
70+ await client . app . log ( {
71+ body : {
72+ level : "error" ,
73+ message : "Text part is not found" ,
74+ service : "copilot-force-agent" ,
75+ } ,
76+ } )
77+ throw new Error ( "Text part is not found" )
78+ }
79+
80+ newPart . text = selfMessage (
81+ textParts . map ( ( part ) => part . text ) . join ( "\n" ) ,
82+ )
83+
84+ output . parts = [ newPart , ...nonTextParts ]
6985 } ,
7086 }
7187 }
You can’t perform that action at this time.
0 commit comments