@@ -27,6 +27,8 @@ You do not need to explain the steps taken, only provide the result to the given
27
27
You are referred to as a tool.
28
28
`
29
29
30
+ var completionID int64
31
+
30
32
func init () {
31
33
if p := os .Getenv ("GPTSCRIPT_INTERNAL_SYSTEM_PROMPT" ); p != "" {
32
34
InternalSystemPrompt = p
@@ -142,8 +144,27 @@ func (c *Context) getTool(name string) (types.Tool, error) {
142
144
return tool , nil
143
145
}
144
146
145
- func (e * Engine ) runCommand (ctx context.Context , tool types.Tool , input string ) (string , error ) {
147
+ func (e * Engine ) runCommand (ctx context.Context , tool types.Tool , input string ) (cmdOut string , cmdErr error ) {
148
+ id := fmt .Sprint (atomic .AddInt64 (& completionID , 1 ))
149
+
150
+ defer func () {
151
+ e .Progress <- openai.Status {
152
+ CompletionID : id ,
153
+ Response : map [string ]any {
154
+ "output" : cmdOut ,
155
+ "err" : cmdErr ,
156
+ },
157
+ }
158
+ }()
159
+
146
160
if tool .BuiltinFunc != nil {
161
+ e .Progress <- openai.Status {
162
+ CompletionID : id ,
163
+ Request : map [string ]any {
164
+ "command" : []string {tool .ID },
165
+ "input" : input ,
166
+ },
167
+ }
147
168
return tool .BuiltinFunc (ctx , e .Env , input )
148
169
}
149
170
@@ -200,6 +221,14 @@ func (e *Engine) runCommand(ctx context.Context, tool types.Tool, input string)
200
221
return "" , err
201
222
}
202
223
224
+ e .Progress <- openai.Status {
225
+ CompletionID : id ,
226
+ Request : map [string ]any {
227
+ "command" : args ,
228
+ "input" : input ,
229
+ },
230
+ }
231
+
203
232
output := & bytes.Buffer {}
204
233
205
234
cmd := exec .Command (args [0 ], append (args [1 :], f .Name ())... )
0 commit comments