|
1 | | -import type { UIMessage } from '@ai-sdk/react'; |
2 | | -import type { ToolUIPart, UIDataTypes, UIMessagePart } from 'ai'; |
| 1 | +import type { MultiSearchRequestSchema } from 'typesense/lib/Typesense/Types'; |
3 | 2 |
|
4 | 3 | export type AskAiState = 'conversation-history' | 'conversation' | 'initial' | 'new-conversation'; |
5 | 4 |
|
6 | | -export interface SearchIndexTool { |
7 | | - input: { |
8 | | - query: string; |
9 | | - }; |
10 | | - output: { |
11 | | - query?: string; |
12 | | - hits?: any[]; |
13 | | - }; |
14 | | -} |
| 5 | +export type AskAiStatus = 'error' | 'ready' | 'streaming' | 'submitted'; |
15 | 6 |
|
16 | | -export interface AgentStudioSearchTool { |
17 | | - input: { |
18 | | - index: string; |
19 | | - query: string; |
20 | | - number_of_results: number; |
21 | | - facet_filters: any | null; |
22 | | - }; |
23 | | - output: { |
24 | | - hits?: any[]; |
25 | | - nbHits?: number; |
26 | | - queryID?: string; |
27 | | - }; |
| 7 | +export interface AITextPart { |
| 8 | + type: 'text'; |
| 9 | + text: string; |
| 10 | + state?: 'done' | 'streaming'; |
28 | 11 | } |
29 | 12 |
|
30 | | -type Tools = { |
31 | | - searchIndex: SearchIndexTool; |
32 | | - algolia_search_index: AgentStudioSearchTool; |
| 13 | +export type AIMessagePart = AITextPart; |
| 14 | + |
| 15 | +export type AIMessage = { |
| 16 | + id: string; |
| 17 | + role: 'assistant' | 'user'; |
| 18 | + parts: AIMessagePart[]; |
| 19 | + metadata?: { |
| 20 | + stopped?: boolean; |
| 21 | + conversationId?: string; |
| 22 | + }; |
33 | 23 | }; |
34 | 24 |
|
35 | | -export type AIMessage = UIMessage<{ stopped?: boolean }, UIDataTypes, Tools>; |
| 25 | +export type UseAskAiSendMessageOptions = { |
| 26 | + suggestedQuestionId?: string; |
| 27 | +}; |
36 | 28 |
|
37 | | -export type AIMessagePart = UIMessagePart<UIDataTypes, Tools>; |
| 29 | +export type TypesenseAskAiSearchParameters = Omit< |
| 30 | + Partial<MultiSearchRequestSchema<Record<string, unknown>, string>>, |
| 31 | + 'collection' | 'exclude_fields' | 'q' | 'query_by' |
| 32 | +>; |
38 | 33 |
|
39 | | -export type AIToolPart = ToolUIPart<Tools>; |
| 34 | +export type TypesenseAskAiParams = { |
| 35 | + collection: string; |
| 36 | + conversationModelId: string; |
| 37 | + excludeFields?: string; |
| 38 | + queryBy: string; |
| 39 | + searchParameters?: TypesenseAskAiSearchParameters; |
| 40 | +}; |
0 commit comments