no brain command

This commit is contained in:
Christoph K.
2026-03-12 19:49:50 +01:00
parent 3c8d3873dc
commit e597617266
3 changed files with 81 additions and 17 deletions

View File

@@ -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 }