Mise à jour du titre (imparfait)
This commit is contained in:
1 parent
345129c7bf
commit
509a3b14c8
14 files changed
+451
-18
No files matched your search
@@ -203,6 +203,40 @@ func (e *AnyLLMEngine) Stream(
|
||||
}
|
||||
}
|
||||
|
||||
func (e *AnyLLMEngine) Generate(
|
||||
ctx context.Context,
|
||||
provider *domain.Provider,
|
||||
modelID string,
|
||||
messages []*domain.Message,
|
||||
) (string, error) {
|
||||
|
||||
p, err := providerFactory(provider)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
anyllmMessages := make([]anyllm.Message, 0)
|
||||
for _, m := range messages {
|
||||
anyllmMessages = append(anyllmMessages, anyllm.Message{
|
||||
Role: m.Role,
|
||||
Content: m.Content,
|
||||
})
|
||||
}
|
||||
|
||||
response, err := p.Completion(ctx, anyllm.CompletionParams{
|
||||
Model: modelID,
|
||||
Messages: anyllmMessages,
|
||||
Stream: false,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return response.Choices[0].Message.Content.(string), nil
|
||||
|
||||
}
|
||||
|
||||
func toolConvert(domainTool *domain.ToolDefinition) providers.Tool {
|
||||
return providers.Tool{
|
||||
Type: domainTool.Type,
|
||||
|
||||
Reference in new issue
Block a user