Skip to content

Commit 278a2ea

Browse files
committed
naming
1 parent 50f5d0c commit 278a2ea

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/AskAiEvent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import * as z from 'zod'
44
// Event type constants for type-safe referencing
55
export const EventTypes = {
66
CONVERSATION_START: 'conversation_start',
7-
CHUNK: 'chunk',
8-
CHUNK_COMPLETE: 'chunk_complete',
7+
MESSAGE_CHUNK: 'message_chunk',
8+
MESSAGE_COMPLETE: 'message_complete',
99
SEARCH_TOOL_CALL: 'search_tool_call',
1010
TOOL_CALL: 'tool_call',
1111
TOOL_RESULT: 'tool_result',
@@ -23,14 +23,14 @@ export const ConversationStartEventSchema = z.object({
2323
})
2424

2525
export const ChunkEventSchema = z.object({
26-
type: z.literal(EventTypes.CHUNK),
26+
type: z.literal(EventTypes.MESSAGE_CHUNK),
2727
id: z.string(),
2828
timestamp: z.number(),
2929
content: z.string(),
3030
})
3131

3232
export const ChunkCompleteEventSchema = z.object({
33-
type: z.literal(EventTypes.CHUNK_COMPLETE),
33+
type: z.literal(EventTypes.MESSAGE_COMPLETE),
3434
id: z.string(),
3535
timestamp: z.number(),
3636
fullContent: z.string(),

src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/ChatMessage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const computeAiStatus = (
144144
m.type === EventTypes.SEARCH_TOOL_CALL ||
145145
m.type === EventTypes.TOOL_CALL ||
146146
m.type === EventTypes.TOOL_RESULT ||
147-
m.type === EventTypes.CHUNK
147+
m.type === EventTypes.MESSAGE_CHUNK
148148
)
149149
.sort((a, b) => a.timestamp - b.timestamp)
150150

@@ -166,9 +166,9 @@ const computeAiStatus = (
166166
case EventTypes.TOOL_RESULT:
167167
return STATUS_MESSAGES.ANALYZING
168168

169-
case EventTypes.CHUNK: {
169+
case EventTypes.MESSAGE_CHUNK: {
170170
const allContent = events
171-
.filter((m) => m.type === EventTypes.CHUNK)
171+
.filter((m) => m.type === EventTypes.MESSAGE_CHUNK)
172172
.map((m) => m.content)
173173
.join('')
174174

src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/StreamingAiMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const StreamingAiMessage = ({
3535
if (event.conversationId && !threadId) {
3636
setThreadId(event.conversationId)
3737
}
38-
} else if (event.type === EventTypes.CHUNK) {
38+
} else if (event.type === EventTypes.MESSAGE_CHUNK) {
3939
contentRef.current += event.content
4040
} else if (event.type === EventTypes.ERROR) {
4141
// Handle error events from the stream

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ namespace Elastic.Documentation.Api.Core.AskAi;
1111
/// </summary>
1212
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
1313
[JsonDerivedType(typeof(ConversationStart), typeDiscriminator: "conversation_start")]
14-
[JsonDerivedType(typeof(Chunk), typeDiscriminator: "chunk")]
15-
[JsonDerivedType(typeof(ChunkComplete), typeDiscriminator: "chunk_complete")]
14+
[JsonDerivedType(typeof(MessageChunk), typeDiscriminator: "message_chunk")]
15+
[JsonDerivedType(typeof(MessageComplete), typeDiscriminator: "message_complete")]
1616
[JsonDerivedType(typeof(SearchToolCall), typeDiscriminator: "search_tool_call")]
1717
[JsonDerivedType(typeof(ToolCall), typeDiscriminator: "tool_call")]
1818
[JsonDerivedType(typeof(ToolResult), typeDiscriminator: "tool_result")]
@@ -33,7 +33,7 @@ string ConversationId
3333
/// <summary>
3434
/// Streaming text chunk from AI
3535
/// </summary>
36-
public sealed record Chunk(
36+
public sealed record MessageChunk(
3737
string Id,
3838
long Timestamp,
3939
string Content
@@ -42,7 +42,7 @@ string Content
4242
/// <summary>
4343
/// Complete message when streaming is done
4444
/// </summary>
45-
public sealed record ChunkComplete(
45+
public sealed record MessageComplete(
4646
string Id,
4747
long Timestamp,
4848
string FullContent
@@ -111,8 +111,8 @@ string Message
111111
/// </summary>
112112
[JsonSerializable(typeof(AskAiEvent))]
113113
[JsonSerializable(typeof(AskAiEvent.ConversationStart))]
114-
[JsonSerializable(typeof(AskAiEvent.Chunk))]
115-
[JsonSerializable(typeof(AskAiEvent.ChunkComplete))]
114+
[JsonSerializable(typeof(AskAiEvent.MessageChunk))]
115+
[JsonSerializable(typeof(AskAiEvent.MessageComplete))]
116116
[JsonSerializable(typeof(AskAiEvent.SearchToolCall))]
117117
[JsonSerializable(typeof(AskAiEvent.ToolCall))]
118118
[JsonSerializable(typeof(AskAiEvent.ToolResult))]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public class AgentBuilderStreamTransformer(ILogger<AgentBuilderStreamTransformer
4141
new AskAiEvent.ConversationStart(id, timestamp, convId.GetString()!),
4242

4343
"message_chunk" when innerData.TryGetProperty("text_chunk", out var textChunk) =>
44-
new AskAiEvent.Chunk(id, timestamp, textChunk.GetString()!),
44+
new AskAiEvent.MessageChunk(id, timestamp, textChunk.GetString()!),
4545

4646
"message_complete" when innerData.TryGetProperty("message_content", out var fullContent) =>
47-
new AskAiEvent.ChunkComplete(id, timestamp, fullContent.GetString()!),
47+
new AskAiEvent.MessageComplete(id, timestamp, fullContent.GetString()!),
4848

4949
"reasoning" =>
5050
// Parse reasoning message if available

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public class LlmGatewayStreamTransformer(ILogger<LlmGatewayStreamTransformer> lo
4141
new AskAiEvent.ConversationStart(id, timestamp, Guid.NewGuid().ToString()),
4242

4343
"ai_message_chunk" when messageData.TryGetProperty("content", out var content) =>
44-
new AskAiEvent.Chunk(id, timestamp, content.GetString()!),
44+
new AskAiEvent.MessageChunk(id, timestamp, content.GetString()!),
4545

4646
"ai_message" when messageData.TryGetProperty("content", out var fullContent) =>
47-
new AskAiEvent.ChunkComplete(id, timestamp, fullContent.GetString()!),
47+
new AskAiEvent.MessageComplete(id, timestamp, fullContent.GetString()!),
4848

4949
"tool_call" when messageData.TryGetProperty("toolCalls", out var toolCalls) =>
5050
TransformToolCall(id, timestamp, toolCalls),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private async Task ProcessStreamAsync(PipeReader reader, PipeWriter writer, Acti
180180
outputMessageParts.Add(new MessagePart("reasoning", reasoning.Message ?? string.Empty));
181181
break;
182182
}
183-
case AskAiEvent.Chunk:
183+
case AskAiEvent.MessageChunk:
184184
{
185185
// Event type already tagged above
186186
break;
@@ -209,7 +209,7 @@ private async Task ProcessStreamAsync(PipeReader reader, PipeWriter writer, Acti
209209
_ = parseActivity?.SetTag("tool.result_summary", toolResult.Result);
210210
break;
211211
}
212-
case AskAiEvent.ChunkComplete chunkComplete:
212+
case AskAiEvent.MessageComplete chunkComplete:
213213
{
214214
outputMessageParts.Add(new MessagePart("text", chunkComplete.FullContent));
215215
Logger.LogInformation("AskAI output message: {OutputMessage}", chunkComplete.FullContent);

0 commit comments

Comments
 (0)