generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f333d54
commit 95796a8
Showing
5 changed files
with
184 additions
and
57 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
32 changes: 25 additions & 7 deletions
32
packages/plugin/views/assistant/ai-chat/types/annotations.ts
This file contains 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 |
---|---|---|
@@ -1,20 +1,38 @@ | ||
import { MessageAnnotation } from 'ai'; | ||
import type { Message } from 'ai'; | ||
|
||
export interface SearchResult { | ||
content: string; | ||
score: number; | ||
filePath: string; | ||
segment: { | ||
text: string; | ||
startIndex: number; | ||
endIndex: number; | ||
}; | ||
groundingChunkIndices: number[]; | ||
confidenceScores: number[]; | ||
} | ||
|
||
export interface SearchResultsAnnotation extends MessageAnnotation { | ||
export interface WebSource { | ||
web: { | ||
uri: string; | ||
title: string; | ||
}; | ||
} | ||
|
||
export interface SearchResultsAnnotation { | ||
type: 'search-results'; | ||
results: SearchResult[]; | ||
groundingMetadata: { | ||
webSearchQueries: string[]; | ||
searchEntryPoint: { | ||
renderedContent: string; | ||
}; | ||
groundingChunks: WebSource[]; | ||
groundingSupports: SearchResult[]; | ||
}; | ||
} | ||
|
||
export type CustomAnnotation = SearchResultsAnnotation; | ||
|
||
export function isSearchResultsAnnotation( | ||
annotation: MessageAnnotation | ||
annotation: any | ||
): annotation is SearchResultsAnnotation { | ||
return annotation.type === 'search-results'; | ||
} |