File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -262,7 +262,9 @@ export abstract class Agent extends BaseSingleActionAgent {
262
262
/**
263
263
* Construct a scratchpad to let the agent continue its thought process
264
264
*/
265
- constructScratchPad ( steps : AgentStep [ ] ) : string | BaseChatMessage [ ] {
265
+ async constructScratchPad (
266
+ steps : AgentStep [ ]
267
+ ) : Promise < string | BaseChatMessage [ ] > {
266
268
return steps . reduce (
267
269
( thoughts , { action, observation } ) =>
268
270
thoughts +
@@ -280,7 +282,7 @@ export abstract class Agent extends BaseSingleActionAgent {
280
282
inputs : ChainValues ,
281
283
suffix ?: string
282
284
) : Promise < AgentAction | AgentFinish > {
283
- const thoughts = this . constructScratchPad ( steps ) ;
285
+ const thoughts = await this . constructScratchPad ( steps ) ;
284
286
const newInputs : ChainValues = {
285
287
...inputs ,
286
288
agent_scratchpad : suffix ? `${ thoughts } ${ suffix } ` : thoughts ,
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ export class ChatAgent extends Agent {
65
65
return new ChatAgentOutputParser ( ) ;
66
66
}
67
67
68
- constructScratchPad ( steps : AgentStep [ ] ) : string {
69
- const agentScratchpad = super . constructScratchPad ( steps ) ;
68
+ async constructScratchPad ( steps : AgentStep [ ] ) : Promise < string > {
69
+ const agentScratchpad = await super . constructScratchPad ( steps ) ;
70
70
if ( agentScratchpad ) {
71
71
return `This was your previous work (but I haven't seen any of it! I only see what you return as final answer):\n${ agentScratchpad } ` ;
72
72
}
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export class ChatConversationalAgent extends Agent {
75
75
}
76
76
}
77
77
78
- constructScratchPad ( steps : AgentStep [ ] ) : BaseChatMessage [ ] {
78
+ async constructScratchPad ( steps : AgentStep [ ] ) : Promise < BaseChatMessage [ ] > {
79
79
const thoughts : BaseChatMessage [ ] = [ ] ;
80
80
for ( const step of steps ) {
81
81
thoughts . push ( new AIChatMessage ( step . action . log ) ) ;
You can’t perform that action at this time.
0 commit comments