-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(context-provider): move ContextItem interface to new BaseContext…
…Provider Moved the ContextItem interface from the retrieval module to a new BaseContextProvider module. This change also includes updates to import statements in various files to reflect the new location of the ContextItem interface.
- Loading branch information
Showing
7 changed files
with
104 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { TextRange } from "../../code-search/scope-graph/model/TextRange"; | ||
import { Reranker } from "../../code-search/reranker/Reranker"; | ||
import { EmbeddingsProvider } from "../../code-search/embedding/_base/EmbeddingsProvider"; | ||
import { IdeAction } from "../../editor/editor-api/IdeAction"; | ||
import { OpenAICompletion } from "../../llm-provider/OpenAICompletion"; | ||
|
||
export interface ContextSubmenuItem { | ||
id: string; | ||
title: string; | ||
description: string; | ||
} | ||
|
||
export interface ContextItem { | ||
content: string; | ||
name: string; | ||
path: string; | ||
range: TextRange; | ||
description: string; | ||
editing?: boolean; | ||
editable?: boolean; | ||
} | ||
|
||
export type ContextProviderType = "normal" | "query" | "submenu"; | ||
|
||
export interface ContextProviderDescription { | ||
title: string; | ||
displayTitle: string; | ||
description: string; | ||
renderInlineAs?: string; | ||
type: ContextProviderType; | ||
} | ||
|
||
export type FetchFunction = (url: string | URL, init?: any) => Promise<any>; | ||
|
||
export interface LoadSubmenuItemsArgs { | ||
ide: IdeAction; | ||
fetch: FetchFunction; | ||
} | ||
|
||
export interface RangeInFile { | ||
filepath: string; | ||
range: Range; | ||
} | ||
|
||
export interface ContextProviderExtras { | ||
fullInput: string; | ||
embeddingsProvider: EmbeddingsProvider; | ||
reranker: Reranker | undefined; | ||
// todo: replace to other models | ||
llm: OpenAICompletion; | ||
ide: IdeAction; | ||
selectedCode: RangeInFile[]; | ||
fetch: FetchFunction; | ||
} | ||
|
||
|
||
export interface IContextProvider { | ||
get description(): ContextProviderDescription; | ||
|
||
getContextItems( | ||
query: string, | ||
extras: ContextProviderExtras, | ||
): Promise<ContextItem[]>; | ||
|
||
loadSubmenuItems(args: LoadSubmenuItemsArgs): Promise<ContextSubmenuItem[]>; | ||
} | ||
|
||
|
||
export abstract class BaseContextProvider implements IContextProvider { | ||
options: { [key: string]: any }; | ||
|
||
constructor(options: { [key: string]: any }) { | ||
this.options = options; | ||
} | ||
|
||
static description: ContextProviderDescription; | ||
|
||
get description(): ContextProviderDescription { | ||
return (this.constructor as any).description; | ||
} | ||
|
||
// Maybe just include the chat message in here. Should never have to go back to the context provider once you have the information. | ||
abstract getContextItems( | ||
query: string, | ||
extras: ContextProviderExtras, | ||
): Promise<ContextItem[]>; | ||
|
||
async loadSubmenuItems( | ||
args: LoadSubmenuItemsArgs, | ||
): Promise<ContextSubmenuItem[]> { | ||
return []; | ||
} | ||
} |
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