add used sources
This commit is contained in:
@@ -44,6 +44,7 @@ final readonly class AgentRunner
|
||||
$swagFullOutPut = '';
|
||||
$firstThinkLoop = true;
|
||||
$shopResults = [];
|
||||
$sources = [];
|
||||
|
||||
if ($prompt === '') {
|
||||
yield '❌ Empty prompt.';
|
||||
@@ -70,13 +71,18 @@ final readonly class AgentRunner
|
||||
// ---------------------------------------------------------
|
||||
yield $this->systemMsg("Ich prüfe auf Internet Quellen...", "think");
|
||||
$urlContent = $this->urlAnalyzer->extractContentFromPrompt($prompt);
|
||||
if($urlContent){
|
||||
$sources[]= 'Externe URL';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// 3) Retrieve RAG knowledge
|
||||
// ---------------------------------------------------------
|
||||
yield $this->systemMsg("Ich hole relevante Daten aus meinem RAG Wissen...", "think");
|
||||
$knowledgeChunks = $this->retriever->retrieve($prompt);
|
||||
|
||||
if($knowledgeChunks){
|
||||
$sources[]= 'RAG Wissen';
|
||||
}
|
||||
// ---------------------------------------------------------
|
||||
// 4) commerce/shop search
|
||||
// ---------------------------------------------------------
|
||||
@@ -126,6 +132,10 @@ final readonly class AgentRunner
|
||||
}
|
||||
}
|
||||
|
||||
if($shopResults){
|
||||
$sources[]= 'Shopsystem';
|
||||
}
|
||||
|
||||
if ($commerceIntent === CommerceIntentLite::PRODUCT_SEARCH) {
|
||||
$knowledgeChunks = array_slice($knowledgeChunks, 0, 2);
|
||||
} elseif ($commerceIntent === CommerceIntentLite::ADVISORY_PRODUCT_SEARCH) {
|
||||
@@ -168,6 +178,10 @@ final readonly class AgentRunner
|
||||
$chunker->flush();
|
||||
$this->thinkSuppressor->reset();
|
||||
|
||||
if($sources){
|
||||
yield $this->systemMsg("Genutze Quellen: ".implode(', ',$sources), 'info');
|
||||
}
|
||||
|
||||
foreach ($this->ollamaClient->stream($finalPrompt) as $token) {
|
||||
|
||||
if (!is_string($token)) {
|
||||
@@ -202,6 +216,10 @@ final readonly class AgentRunner
|
||||
yield $this->systemMsg('❌ Es wurden keine Daten vom LLM empfangen.', 'err');
|
||||
}
|
||||
|
||||
if($sources){
|
||||
yield $this->systemMsg("Quellen: ".implode(', ',$sources), 'info');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// 7) Persist conversation history
|
||||
// ---------------------------------------------------------
|
||||
@@ -237,7 +255,8 @@ final readonly class AgentRunner
|
||||
return match ($type) {
|
||||
'answer' => '' . $msg,
|
||||
'err' => '<span class="text-danger">' . $msg . "</span>\n<hr>\n",
|
||||
'think' => '<span class="text-info think">' . $msg . "</span>\n"
|
||||
'think' => '<span class="text-info think">' . $msg . "</span>\n",
|
||||
'info' => "\n\n<span class=\"text-info fw-bolder\">" . $msg . "</span>\n"
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user