no brain command
This commit is contained in:
@@ -169,4 +169,38 @@ func buildContext(chunks []KnowledgeChunk) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// ChatDirect stellt eine Frage direkt an das LLM ohne Datenbankkontext.
|
||||
func ChatDirect(question string) (string, error) {
|
||||
ctx := context.Background()
|
||||
chatClient := config.NewChatClient()
|
||||
|
||||
systemPrompt := `Du bist ein hilfreicher persönlicher Assistent. Antworte auf Deutsch, präzise und direkt.`
|
||||
|
||||
stream, err := chatClient.CreateChatCompletionStream(ctx, openai.ChatCompletionRequest{
|
||||
Model: config.Cfg.Chat.Model,
|
||||
Messages: []openai.ChatCompletionMessage{
|
||||
{Role: openai.ChatMessageRoleSystem, Content: systemPrompt},
|
||||
{Role: openai.ChatMessageRoleUser, Content: question},
|
||||
},
|
||||
Temperature: 0.7,
|
||||
MaxTokens: 500,
|
||||
})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("LLM Fehler: %w", err)
|
||||
}
|
||||
defer stream.Close()
|
||||
|
||||
var answer strings.Builder
|
||||
for {
|
||||
response, err := stream.Recv()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
if len(response.Choices) > 0 {
|
||||
answer.WriteString(response.Choices[0].Delta.Content)
|
||||
}
|
||||
}
|
||||
return answer.String(), nil
|
||||
}
|
||||
|
||||
func floatPtr(f float32) *float32 { return &f }
|
||||
|
||||
Reference in New Issue
Block a user