Skip to content

Commit

Permalink
fix: ordered arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
bcho committed Oct 13, 2024
1 parent fcc26c2 commit 4be0ad5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sg/internal/llm/swarm/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func goFunctionToAgentFunction(
var (
hasCtxArg bool
hasAgentCtxArg bool
argNames []string
)
argSchemas := map[string]map[string]any{}
for i := 0; i < fType.NumIn(); i++ {
Expand Down Expand Up @@ -119,7 +120,8 @@ func goFunctionToAgentFunction(
}
}

argName := fmt.Sprintf("arg%d", len(argSchemas))
argName := fmt.Sprintf("arg%d", len(argNames))
argNames = append(argNames, argName)
argSchemas[argName] = map[string]any{
"type": goTypeToJSONSchemaType(arg),
// TODO: add description...
Expand Down Expand Up @@ -160,7 +162,8 @@ func goFunctionToAgentFunction(
if hasAgentCtxArg {
invokeArgs = append(invokeArgs, reflect.ValueOf(agentCtx))
}
for argName, argSchema := range argSchemas {
for _, argName := range argNames {
argSchema := argSchemas[argName]
v := gjson.GetBytes(arguments, argName)
var argValue reflect.Value
switch argSchema["type"] {
Expand Down

0 comments on commit 4be0ad5

Please sign in to comment.