generated from forcedotcom/library-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: reorg file structure and add jsdoc
- Loading branch information
1 parent
840b93a
commit a136ab6
Showing
10 changed files
with
337 additions
and
151 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
export type GenericCompletionType = | ||
| { completion: string } | ||
| { id: string; text: string }; | ||
|
||
/** | ||
* Represents a Salesforce API completion type. | ||
* @property {string} id - The unique identifier for the completion. | ||
* @property {string} text - The text of the completion. | ||
*/ | ||
export type SFApiCompletion = Extract<GenericCompletionType, { id: string }>; | ||
|
||
/** | ||
* Represents a code generation completion type. | ||
* @property {string} completion - The completion text. | ||
*/ | ||
export type CodeGenCompletion = Extract< | ||
GenericCompletionType, | ||
{ completion: string } | ||
>; | ||
|
||
// There are two different APIs we are currently supporting for the GPT response. | ||
// A new conditional type should be created to include future additions. | ||
|
||
/** | ||
* Represents a completion type based on the provided generic type. | ||
* @template T | ||
*/ | ||
export type CompletionType<T extends SFApiCompletion | CodeGenCompletion> = | ||
T extends SFApiCompletion ? SFApiCompletion : CodeGenCompletion; | ||
|
||
/** | ||
* Represents an AI completion type. | ||
*/ | ||
export type AiCompletion = CompletionType<SFApiCompletion | CodeGenCompletion>; |
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,36 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
export type JaccardSnippet = { | ||
file_path: string; | ||
text: string; | ||
similarity: number; | ||
}; | ||
|
||
/** | ||
* Represents the context for an inline completion request. | ||
* @property {string} current_file_path - The current file path. | ||
* @property {JaccardSnippet[]} windows - The array of Jaccard snippets. | ||
*/ | ||
export type InlineCompletionRequestContext = { | ||
current_file_path: string; | ||
windows: JaccardSnippet[]; | ||
}; | ||
|
||
/** | ||
* Represents the inputs for an inline completion request. | ||
* @property {string} prefix - The prefix text for the completion. | ||
* @property {string} suffix - The suffix text for the completion. | ||
* @property {InlineCompletionRequestContext | string} context - The context for the completion request. | ||
* @property {string} promptId - The prompt identifier. | ||
*/ | ||
export type InlineCompletionRequestInputs = { | ||
prefix: string; | ||
suffix: string; | ||
context: InlineCompletionRequestContext | string; | ||
promptId: string; | ||
}; |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
export enum CommandSource { | ||
/** | ||
* Command source for natural language to code generation. | ||
*/ | ||
NLtoCodeGen = 'NLtoCodeGen', | ||
|
||
/** | ||
* Command source for test generation. | ||
*/ | ||
TestGen = 'TestGen', | ||
|
||
/** | ||
* Command source for inline autocomplete. | ||
*/ | ||
InlineAutocomplete = 'InlineAutocomplete', | ||
|
||
/** | ||
* Command source for chat. | ||
*/ | ||
Chat = 'Chat' | ||
} |
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,14 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
export * from './types/PromptStoreEntry'; | ||
export * from './types/TelemetryData'; | ||
export * from './types/ApiClient'; | ||
export * from './enums/commandSource'; | ||
export * from './utils/Completion/Completion'; | ||
export * from './Completions/AiCompletion'; | ||
export * from './Completions/InlineCompletions'; |
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,84 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { | ||
Actions, | ||
FeedbackCustomContextValues, | ||
Reactions | ||
} from './TelemetryData'; | ||
import { CommandSource } from '../enums/commandSource'; | ||
import { Completion } from '../utils/Completion/Completion'; | ||
import { AiCompletion } from '../index'; | ||
import { InlineCompletionRequestInputs } from '../Completions/InlineCompletions'; | ||
import { CancellationToken } from 'vscode'; | ||
|
||
export type LLMRequestBody = { | ||
id: string; | ||
generation_id: string; | ||
feedback: Reactions | null; | ||
feedback_text: string | null; | ||
source: string; | ||
previous_generation_ids?: string[]; | ||
app_feedback: { | ||
feedback_detail: { | ||
action: Actions | null; | ||
}; | ||
custom_context: Record<string, FeedbackCustomContextValues>; | ||
}; | ||
}; | ||
|
||
/** | ||
* Represents the query parameters for natural language queries. | ||
* @property {string} prefix - The prefix for the query. | ||
* @property {string} suffix - The suffix for the query. | ||
* @property {string} input - The input for the query. | ||
* @property {string} promptId - The prompt identifier. | ||
* @property {CommandSource} commandSource - The source of the command. | ||
*/ | ||
export type QueryParams = { | ||
prefix: string; | ||
suffix: string; | ||
input: string; | ||
promptId: string; | ||
commandSource: CommandSource; | ||
}; | ||
/** | ||
* Interface for AI API client. | ||
* @interface AiApiClient | ||
* @property {string} blockRestEndpoint - The endpoint for blocking REST requests. | ||
* @property {string} inlineRestEndpoint - The endpoint for inline REST requests. | ||
*/ | ||
export interface AiApiClient { | ||
blockRestEndpoint: string; | ||
inlineRestEndpoint: string; | ||
|
||
/** | ||
* Executes a natural language query. | ||
* @param queryParams - The query parameters. | ||
* @returns A promise that resolves to an array of completions. | ||
*/ | ||
naturalLanguageQuery( | ||
queryParams: QueryParams | ||
): Promise<Completion<AiCompletion>[]>; | ||
|
||
/** | ||
* Executes an inline query. | ||
* @param inputs - The inputs for the inline query. | ||
* @param token - The cancellation token. | ||
* @returns A promise that resolves to an array of completions. | ||
*/ | ||
inlineQuery( | ||
inputs: InlineCompletionRequestInputs, | ||
token: CancellationToken | ||
): Promise<Completion<AiCompletion>[]>; | ||
|
||
/** | ||
* Sends feedback for LLM. | ||
* @param telemetryData - The telemetry data for feedback. | ||
* @returns A promise that resolves when the feedback is sent. | ||
*/ | ||
sendLLMFeedback?(telemetryData: LLMRequestBody): Promise<void>; | ||
} |
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,10 @@ | ||
/* | ||
* Copyright (c) 2024, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
export type SerializedRange = [ | ||
{ line: number; character: number }, | ||
{ line: number; character: number } | ||
]; |
Oops, something went wrong.