Skip to content

Commit 68737c7

Browse files
committed
fix
1 parent a3efcb8 commit 68737c7

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/api/Elastic.Documentation.Api.Core/AskAi/AskAiUsecase.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ public class AskAiUsecase(
1414
{
1515
private static readonly ActivitySource AskAiActivitySource = new("Elastic.Documentation.Api.AskAi");
1616

17-
private static string GetModelNameFromProvider(string provider) => provider switch
18-
{
19-
"LlmGateway" => "docs_assistant",
20-
"AgentBuilder" => "docs-agent",
21-
_ => "elastic-docs-rag"
22-
};
23-
2417
public async Task<Stream> AskAi(AskAiRequest askAiRequest, Cancel ctx)
2518
{
2619
using var activity = AskAiActivitySource.StartActivity("gen_ai.agent");
@@ -35,7 +28,6 @@ public async Task<Stream> AskAi(AskAiRequest askAiRequest, Cancel ctx)
3528
tags:
3629
[
3730
new KeyValuePair<string, object?>("gen_ai.operation.name", "chat"),
38-
new KeyValuePair<string, object?>("gen_ai.request.model", GetModelNameFromProvider("Unknown")), // Will be updated by transformer
3931
new KeyValuePair<string, object?>("gen_ai.conversation.id", askAiRequest.ThreadId ?? "pending"), // Will be updated when we receive ConversationStart
4032
new KeyValuePair<string, object?>("gen_ai.input.messages", $"[{{\"role\":\"user\",\"content\":\"{askAiRequest.Message}\"}}]"),
4133
new KeyValuePair<string, object?>("gen_ai.system_instructions", $"[{{\"type\":\"text\",\"content\":\"{AskAiRequest.SystemPrompt}\"}}]")

src/api/Elastic.Documentation.Api.Infrastructure/Adapters/AskAi/StreamTransformerBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,13 @@ protected virtual async Task ProcessStreamAsync(PipeReader reader, PipeWriter wr
163163

164164
if (transformedEvent != null)
165165
{
166-
// Update parent activity with conversation ID when we receive ConversationStart events
166+
// Update parent activity with conversation ID and model info when we receive ConversationStart events
167167
if (transformedEvent is AskAiEvent.ConversationStart conversationStart)
168168
{
169169
_ = (parentActivity?.SetTag("gen_ai.conversation.id", conversationStart.ConversationId));
170+
_ = (parentActivity?.SetTag("gen_ai.request.model", GetAgentId()));
171+
_ = (parentActivity?.SetTag("gen_ai.agent.name", GetAgentId()));
172+
_ = (parentActivity?.SetTag("gen_ai.provider.name", GetAgentProvider()));
170173
_ = (activity?.SetTag("gen_ai.conversation.id", conversationStart.ConversationId));
171174
}
172175

0 commit comments

Comments
 (0)