Add support for integers and tool configuration in schema handling
This update introduces support for `jsonschema.Integer` types and updates the logic to handle nested items in schemas. Added a new default error log for unknown types using `slog.Error`. Also, integrated tool configuration with a `FunctionCallingConfig` when `dontRequireTool` is false.
This commit is contained in:
20
request.go
20
request.go
@@ -1,6 +1,8 @@
|
||||
package go_llm
|
||||
|
||||
import "github.com/sashabaranov/go-openai"
|
||||
import (
|
||||
"github.com/openai/openai-go"
|
||||
)
|
||||
|
||||
type rawAble interface {
|
||||
toRaw() map[string]any
|
||||
@@ -8,13 +10,13 @@ type rawAble interface {
|
||||
}
|
||||
|
||||
type Input interface {
|
||||
toChatCompletionMessages() []openai.ChatCompletionMessage
|
||||
toChatCompletionMessages(model string) []openai.ChatCompletionMessageParamUnion
|
||||
}
|
||||
type Request struct {
|
||||
Conversation []Input
|
||||
Messages []Message
|
||||
Toolbox *ToolBox
|
||||
Temperature *float32
|
||||
Temperature *float64
|
||||
}
|
||||
|
||||
// NextRequest will take the current request's conversation, messages, the response, and any tool results, and
|
||||
@@ -33,16 +35,8 @@ func (req Request) NextRequest(resp ResponseChoice, toolResults []ToolCallRespon
|
||||
res.Conversation = append(res.Conversation, msg)
|
||||
}
|
||||
|
||||
// if there are tool calls, then we need to add those to the conversation
|
||||
for _, call := range resp.Calls {
|
||||
res.Conversation = append(res.Conversation, call)
|
||||
}
|
||||
|
||||
if resp.Content != "" || resp.Refusal != "" {
|
||||
res.Conversation = append(res.Conversation, Message{
|
||||
Role: RoleAssistant,
|
||||
Text: resp.Content,
|
||||
})
|
||||
if resp.Content != "" || resp.Refusal != "" || len(resp.Calls) > 0 {
|
||||
res.Conversation = append(res.Conversation, resp)
|
||||
}
|
||||
|
||||
// if there are tool results, then we need to add those to the conversation
|
||||
|
Reference in New Issue
Block a user