Skip to content

Commit bb815de

Browse files
authored
Change the toolcall. (#890)
* Needed to support custom actions #873 * We want the AI to be able to generate code that will be executed by different kernels. * We will use language of the code generated to indicate why type of code it is and pick the executor. * We need to update the tool description to allow the AI to specify the language. Fix a couple bugs in assets.go --------- Signed-off-by: Jeremy Lewi <[email protected]>
1 parent 05eb2ab commit bb815de

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

pkg/agent/ai/agent.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ func (a *Agent) ProcessWithOpenAI(ctx context.Context, req *agentv1.GenerateRequ
261261
}
262262

263263
shellArgs := &ShellArgs{
264-
Shell: c.Value,
264+
Code: c.Value,
265+
Language: c.LanguageId,
265266
}
266267

267268
shellArgsJSON, err := json.Marshal(shellArgs)

pkg/agent/ai/cells.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ func (b *CellsBuilder) ProcessEvent(ctx context.Context, e responses.ResponseStr
252252
log.Error(err, "Failed to unmarshal shell arguments", "delta", e.Arguments)
253253
cell.Value = e.Arguments
254254
} else {
255-
cell.Value = shellArgs.Shell
255+
cell.Value = shellArgs.Code
256+
cell.LanguageId = shellArgs.Language
256257
}
257258
resp.Cells = append(resp.Cells, cell)
258259
case responses.ResponseOutputItemDoneEvent:

pkg/agent/ai/tools.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package ai
22

33
type ShellArgs struct {
4-
Shell string `json:"shell"`
4+
Code string `json:"code"`
5+
Language string `json:"language"`
56
}

pkg/agent/server/assets.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"net/url"
1010
"os"
1111

12+
"github.com/jlewi/monogo/helpers"
13+
1214
"github.com/runmedev/runme/v3/pkg/agent/logs"
1315

1416
agentv1 "github.com/runmedev/runme/v3/api/gen/proto/go/agent/v1"
@@ -105,11 +107,13 @@ func (s *Server) singlePageAppHandler() (http.Handler, error) {
105107

106108
// If path is empty, file doesn't exist, or it's index.html, serve processed index
107109
if path == "/" || path == "index.html" || os.IsNotExist(func() error {
108-
_, err := s.assetsFS.Open(path)
110+
f, err := s.assetsFS.Open(path)
111+
helpers.DeferIgnoreError(f.Close)
109112
return err
110113
}()) {
111114
// Read and process index.html
112115
s.serveIndexHTML(w, r)
116+
return
113117
}
114118

115119
fileServer.ServeHTTP(w, r)

0 commit comments

Comments
 (0)