-
Notifications
You must be signed in to change notification settings - Fork 32
Add ability to switch between LLM Gateway and Agent Builder #2128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
09ecd11
Add ability to switch between LLM Gateway and Agent Builder
reakaleek 947f896
Run prettier
reakaleek 185fad9
Revert actions/update-link-index/README.md
reakaleek 86e06a7
Merge branch 'main' into feature/agent-builder-poc
reakaleek ebe6ef8
Merge remote-tracking branch 'origin/feature/agent-builder-poc' into …
reakaleek 77226a9
Refactor and move more logic into the StreamTransformerBase class
reakaleek c301972
Fix test
reakaleek 40329db
Log errors
reakaleek ca4b567
Fix type
reakaleek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...astic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/AiProviderSelector.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /** @jsxImportSource @emotion/react */ | ||
| import { useAiProviderStore } from './aiProviderStore' | ||
| import { EuiRadioGroup } from '@elastic/eui' | ||
| import type { EuiRadioGroupOption } from '@elastic/eui' | ||
| import { css } from '@emotion/react' | ||
|
|
||
| const containerStyles = css` | ||
| padding: 1rem; | ||
| display: flex; | ||
| justify-content: center; | ||
| ` | ||
|
|
||
| const options: EuiRadioGroupOption[] = [ | ||
| { | ||
| id: 'LlmGateway', | ||
| label: 'LLM Gateway', | ||
| }, | ||
| { | ||
| id: 'AgentBuilder', | ||
| label: 'Agent Builder', | ||
| }, | ||
| ] | ||
|
|
||
| export const AiProviderSelector = () => { | ||
| const { provider, setProvider } = useAiProviderStore() | ||
|
|
||
| return ( | ||
| <div css={containerStyles}> | ||
| <EuiRadioGroup | ||
| options={options} | ||
| idSelected={provider} | ||
| onChange={(id) => | ||
| setProvider(id as 'AgentBuilder' | 'LlmGateway') | ||
| } | ||
| name="aiProvider" | ||
| legend={{ | ||
| children: 'AI Provider', | ||
| display: 'visible', | ||
| }} | ||
| /> | ||
| </div> | ||
| ) | ||
| } |
109 changes: 109 additions & 0 deletions
109
src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi/AskAiEvent.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // Canonical AskAI event types - matches backend AskAiEvent records | ||
| import * as z from 'zod' | ||
|
|
||
| // Event type constants for type-safe referencing | ||
| export const EventTypes = { | ||
| CONVERSATION_START: 'conversation_start', | ||
| CHUNK: 'chunk', | ||
| CHUNK_COMPLETE: 'chunk_complete', | ||
| SEARCH_TOOL_CALL: 'search_tool_call', | ||
| TOOL_CALL: 'tool_call', | ||
| TOOL_RESULT: 'tool_result', | ||
| REASONING: 'reasoning', | ||
| CONVERSATION_END: 'conversation_end', | ||
| ERROR: 'error', | ||
| } as const | ||
|
|
||
| // Individual event schemas | ||
| export const ConversationStartEventSchema = z.object({ | ||
| type: z.literal(EventTypes.CONVERSATION_START), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| conversationId: z.string(), | ||
| }) | ||
|
|
||
| export const ChunkEventSchema = z.object({ | ||
| type: z.literal(EventTypes.CHUNK), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| content: z.string(), | ||
| }) | ||
|
|
||
| export const ChunkCompleteEventSchema = z.object({ | ||
| type: z.literal(EventTypes.CHUNK_COMPLETE), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| fullContent: z.string(), | ||
| }) | ||
|
|
||
| export const SearchToolCallEventSchema = z.object({ | ||
| type: z.literal(EventTypes.SEARCH_TOOL_CALL), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| toolCallId: z.string(), | ||
| searchQuery: z.string(), | ||
| }) | ||
|
|
||
| export const ToolCallEventSchema = z.object({ | ||
| type: z.literal(EventTypes.TOOL_CALL), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| toolCallId: z.string(), | ||
| toolName: z.string(), | ||
| arguments: z.string(), | ||
| }) | ||
|
|
||
| export const ToolResultEventSchema = z.object({ | ||
| type: z.literal(EventTypes.TOOL_RESULT), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| toolCallId: z.string(), | ||
| result: z.string(), | ||
| }) | ||
|
|
||
| export const ReasoningEventSchema = z.object({ | ||
| type: z.literal(EventTypes.REASONING), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| message: z.string().nullable(), | ||
| }) | ||
|
|
||
| export const ConversationEndEventSchema = z.object({ | ||
| type: z.literal(EventTypes.CONVERSATION_END), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| }) | ||
|
|
||
| export const ErrorEventSchema = z.object({ | ||
| type: z.literal(EventTypes.ERROR), | ||
| id: z.string(), | ||
| timestamp: z.number(), | ||
| message: z.string(), | ||
| }) | ||
|
|
||
| // Discriminated union of all event types | ||
| export const AskAiEventSchema = z.discriminatedUnion('type', [ | ||
| ConversationStartEventSchema, | ||
| ChunkEventSchema, | ||
| ChunkCompleteEventSchema, | ||
| SearchToolCallEventSchema, | ||
| ToolCallEventSchema, | ||
| ToolResultEventSchema, | ||
| ReasoningEventSchema, | ||
| ConversationEndEventSchema, | ||
| ErrorEventSchema, | ||
| ]) | ||
|
|
||
| // Infer TypeScript types from schemas | ||
| export type ConversationStartEvent = z.infer< | ||
| typeof ConversationStartEventSchema | ||
| > | ||
| export type ChunkEvent = z.infer<typeof ChunkEventSchema> | ||
| export type ChunkCompleteEvent = z.infer<typeof ChunkCompleteEventSchema> | ||
| export type SearchToolCallEvent = z.infer<typeof SearchToolCallEventSchema> | ||
| export type ToolCallEvent = z.infer<typeof ToolCallEventSchema> | ||
| export type ToolResultEvent = z.infer<typeof ToolResultEventSchema> | ||
| export type ReasoningEvent = z.infer<typeof ReasoningEventSchema> | ||
| export type ConversationEndEvent = z.infer<typeof ConversationEndEventSchema> | ||
| export type ErrorEvent = z.infer<typeof ErrorEventSchema> | ||
| export type AskAiEvent = z.infer<typeof AskAiEventSchema> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.