mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	fixed bug for function call error None is not of type 'array'
This commit is contained in:
		@@ -24,5 +24,4 @@ type Function struct {
 | 
			
		||||
	Name        string                 `json:"name"`
 | 
			
		||||
	Description string                 `json:"description"`
 | 
			
		||||
	Parameters  map[string]interface{} `json:"parameters"`
 | 
			
		||||
	Required    interface{}            `json:"required,omitempty"`
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -241,8 +241,6 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session *types.ChatSessio
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			required := parameters["required"]
 | 
			
		||||
			delete(parameters, "required")
 | 
			
		||||
			tool := types.Tool{
 | 
			
		||||
				Type: "function",
 | 
			
		||||
				Function: types.Function{
 | 
			
		||||
@@ -251,10 +249,8 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session *types.ChatSessio
 | 
			
		||||
					Parameters:  parameters,
 | 
			
		||||
				},
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// Fixed: compatible for gpt4-turbo-xxx model
 | 
			
		||||
			if !strings.HasPrefix(req.Model, "gpt-4-turbo-") {
 | 
			
		||||
				tool.Function.Required = required
 | 
			
		||||
			if v, ok := parameters["required"]; v == nil || !ok {
 | 
			
		||||
				tool.Function.Parameters["required"] = []string{}
 | 
			
		||||
			}
 | 
			
		||||
			tools = append(tools, tool)
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user