in gollm/azopenai.go [141:172]
func (c *AzureOpenAIChat) Send(ctx context.Context, contents ...any) (ChatResponse, error) {
for _, content := range contents {
switch v := content.(type) {
case string:
message := azopenai.ChatRequestUserMessage{
Content: azopenai.NewChatRequestUserMessageContent(v),
}
c.history = append(c.history, &message)
case FunctionCallResult:
message := azopenai.ChatRequestUserMessage{
Content: azopenai.NewChatRequestUserMessageContent(fmt.Sprintf("Function call result: %s", v.Result)),
}
c.history = append(c.history, &message)
default:
return nil, fmt.Errorf("unsupported content type: %T", v)
}
}
resp, err := c.client.GetChatCompletions(ctx, azopenai.ChatCompletionsOptions{
DeploymentName: &c.model,
Messages: c.history,
Tools: c.tools,
}, nil)
if err != nil {
return nil, err
}
if len(resp.Choices) == 0 {
return nil, fmt.Errorf("no response from Azure OpenAI: %v", resp)
}
return &AzureOpenAIChatResponse{azureOpenAIResponse: resp}, nil
}