Skip to content

Commit 075c8c5

Browse files
committed
formatting
1 parent 0d2a09a commit 075c8c5

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,6 @@ export const chatStore = create<ChatState>((set) => ({
9595
}))
9696

9797
export const useChatMessages = () => chatStore((state) => state.chatMessages)
98-
export const useConversationId = () => chatStore((state) => state.conversationId)
98+
export const useConversationId = () =>
99+
chatStore((state) => state.conversationId)
99100
export const useChatActions = () => chatStore((state) => state.actions)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ export const useAskAi = (props: Props): UseAskAiResponse => {
136136
setEvents([])
137137
clearQueue()
138138
lastSentQuestionRef.current = question
139-
const payload = createAskAiRequest(question, props.conversationId)
139+
const payload = createAskAiRequest(
140+
question,
141+
props.conversationId
142+
)
140143

141144
try {
142145
await sendMessage(payload)

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5-
using System.Buffers;
6-
using System.IO.Pipelines;
7-
using System.Text;
85
using System.Text.Json;
96
using Elastic.Documentation.Api.Core.AskAi;
107
using Microsoft.Extensions.Logging;
@@ -34,11 +31,6 @@ public class LlmGatewayStreamTransformer(ILogger<LlmGatewayStreamTransformer> lo
3431
var id = message.GetProperty("id").GetString()!;
3532
var messageData = message.GetProperty("data");
3633

37-
// LLM gateway does not emit conversation start events with thread IDs
38-
// so we create a synthetic conversation start event here
39-
if (conversationId is null)
40-
return new AskAiEvent.ConversationStart(id, timestamp, Guid.NewGuid().ToString());
41-
4234
return type switch
4335
{
4436
"ai_message_chunk" when messageData.TryGetProperty("content", out var content) =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ private IStreamTransformer GetTransformer()
3939
public string AgentId => GetTransformer().AgentId;
4040
public string AgentProvider => GetTransformer().AgentProvider;
4141

42-
public async Task<Stream> TransformAsync(Stream rawStream, System.Diagnostics.Activity? parentActivity, CancellationToken cancellationToken = default)
42+
public async Task<Stream> TransformAsync(Stream rawStream, string? conversationId, System.Diagnostics.Activity? parentActivity, Cancel cancellationToken = default)
4343
{
4444
var transformer = GetTransformer();
45-
return await transformer.TransformAsync(rawStream, parentActivity, cancellationToken);
45+
return await transformer.TransformAsync(rawStream, conversationId, parentActivity, cancellationToken);
4646
}
4747
}

0 commit comments

Comments
 (0)