Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions exa/language_server_pb/language_server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ service LanguageServerService {
rpc GetAuthToken(GetAuthTokenRequest) returns (GetAuthTokenResponse) {}
}

message MultilineConfig {
// Multiline model threshold. 0-1, higher = more single line, lower = more multiline,
// 0.0 = only_multiline, default is 0.5
float threshold = 1;
}

// Next ID: 9, Previous field: disable_cache.
message GetCompletionsRequest {
codeium_common_pb.Metadata metadata = 1 [(validate.rules).message.required = true];
Expand All @@ -24,6 +30,7 @@ message GetCompletionsRequest {
ExperimentConfig experiment_config = 7;

string model_name = 10;
MultilineConfig multiline_config = 13;
}

// Next ID: 5, Previous field: latency_info.
Expand Down
8 changes: 8 additions & 0 deletions src/components/CodeiumEditor/CodeiumEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export interface CodeiumEditorProps extends EditorProps {
* Optional styles for the container.
*/
containerStyle?: React.CSSProperties;

/**
* Optional multiline model threshold. Should not be needed for most use cases.
* Numerical value between 0-1, higher = more single line, lower = more multiline,
* 0.0 = only_multiline.
*/
multilineModelThreshold?: number;
}

/**
Expand Down Expand Up @@ -86,6 +93,7 @@ export const CodeiumEditor: React.FC<CodeiumEditorProps> = ({
setCodeiumStatus,
setCodeiumStatusMessage,
props.apiKey,
props.multilineModelThreshold,
);
}, []);

Expand Down
10 changes: 10 additions & 0 deletions src/components/CodeiumEditor/CompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Document as DocumentInfo,
GetCompletionsResponse,
CompletionItem,
MultilineConfig,
} from '../../api/proto/exa/language_server_pb/language_server_pb';
import { Document } from './Document';
import { Position, Range } from './Location';
Expand Down Expand Up @@ -62,6 +63,7 @@ export class MonacoCompletionProvider {
readonly setStatus: (status: Status) => void,
readonly setMessage: (message: string) => void,
readonly apiKey?: string | undefined,
readonly multilineModelThreshold?: number | undefined,
) {
this.sessionId = `react-editor-${uuid()}`;
this.client = grpcClient;
Expand Down Expand Up @@ -132,6 +134,13 @@ export class MonacoCompletionProvider {
includedOtherDocs = includedOtherDocs.slice(0, 10);
}

let multilineConfig: MultilineConfig | undefined = undefined;
if (this.multilineModelThreshold !== undefined) {
multilineConfig = new MultilineConfig({
threshold: this.multilineModelThreshold,
});
}

// Get completions.
let getCompletionsResponse: GetCompletionsResponse;
try {
Expand All @@ -141,6 +150,7 @@ export class MonacoCompletionProvider {
document: documentInfo,
editorOptions: editorOptions,
otherDocuments: includedOtherDocs,
multilineConfig,
},
{
signal,
Expand Down
2 changes: 2 additions & 0 deletions src/components/CodeiumEditor/InlineCompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ export class InlineCompletionProvider
setCodeiumStatus: Dispatch<SetStateAction<Status>>,
setCodeiumStatusMessage: Dispatch<SetStateAction<string>>,
apiKey?: string | undefined,
multilineModelThreshold?: number | undefined,
) {
this.numCompletionsProvided = 0;
this.completionProvider = new MonacoCompletionProvider(
grpcClient,
setCodeiumStatus,
setCodeiumStatusMessage,
apiKey,
multilineModelThreshold,
);
}

Expand Down
1 change: 1 addition & 0 deletions src/stories/CodeiumEditor.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const PlainTextEditor: Story = {
...baseParams,
language: 'markdown',
value: 'This is a test textarea. Lorem',
multilineModelThreshold: 1.0,
containerStyle: {
border: '1px solid black',
borderRadius: '2px',
Expand Down