Skip to content

Commit

Permalink
Update OV Version (openvinotoolkit#729)
Browse files Browse the repository at this point in the history
* Update OV Version to Release

* Add GIFs to README.md

* Delete vsix from the repo

* Add Platform Specific Hotkeys and Show Selected Quote Style on the Side Panel

---------

Co-authored-by: Yaroslav Tarkan <[email protected]>
  • Loading branch information
apaniukov and yatarkan authored Sep 19, 2023
1 parent cabe453 commit b13ed38
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 15 deletions.
6 changes: 5 additions & 1 deletion modules/openvino_code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ To check the connection manually, use the `Check Connection` button located on t

### Code Completion

![code_completion](https://github.com/apaniukov/openvino_contrib/assets/51917466/c3ba73bf-106b-4045-a36e-96440f8c804f)

1. Create a new Python file or open an existing one.
1. Type `def main():` or place the cursor where you'd like code suggestions to be generated.
1. Press the keyboard shortcut `Ctrl+Alt+Space` or click the `Generate Code Completion` button located in the side panel.
1. Press the keyboard shortcut `Ctrl+Alt+Space` (`Cmd+Alt+Space` for macOS) or click the `Generate Code Completion` button located in the side panel.
1. Use the `Tab` key to accept the entire suggestion or `Ctrl`+`Right Arrow` to accept it word by word. To decline the suggestion, press `Esc`.

You can customize the length of the generated code by adjusting `Max New Tokens` and `Min New Tokens` parameters in the extension settings.
Expand All @@ -36,6 +38,8 @@ This mode allows you to immediately receive model output and avoid problems with

### Summarization via Docstring Generation

![summarization](https://github.com/apaniukov/openvino_contrib/assets/51917466/1d066b0e-cff7-4353-90f9-a53343d60b59)

To generate function docstring start typing `"""` or `'''` right under function signature and choose `Generate Docstring`.
You can select the desired type of quotes in the extension settings.

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions modules/openvino_code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion modules/openvino_code/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"publisher": "OpenVINO",
"name": "openvino-code-completion",
"version": "0.0.4",
"version": "0.0.5",
"displayName": "OpenVINO Code Completion",
"description": "VSCode extension for AI code completion with OpenVINO",
"icon": "media/logo.png",
Expand Down
2 changes: 1 addition & 1 deletion modules/openvino_code/server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies = [
'torch @ https://download.pytorch.org/whl/cpu-cxx11-abi/torch-2.0.1%2Bcpu.cxx11.abi-cp310-cp310-linux_x86_64.whl ; sys_platform=="linux" and python_version == "3.10"',
'torch @ https://download.pytorch.org/whl/cpu-cxx11-abi/torch-2.0.1%2Bcpu.cxx11.abi-cp311-cp311-linux_x86_64.whl ; sys_platform=="linux" and python_version == "3.11"',
'torch ; sys_platform != "linux"',
'openvino==2023.1.0.dev20230811',
'openvino==2023.1.0',
'transformers==4.31.0',
'optimum==1.12.0',
'optimum-intel[openvino]==1.10.1',
Expand Down
1 change: 1 addition & 0 deletions modules/openvino_code/shared/extension-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface IExtensionState {
get isServerAvailable(): boolean;
get config(): ExtensionConfiguration;
features: IStateFeatures;
platform: NodeJS.Platform;
}
6 changes: 4 additions & 2 deletions modules/openvino_code/side-panel-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ function App(): JSX.Element {
<ServerSection state={state}></ServerSection>
{isServerStarted && (
<>
<CompletionSection isLoading={state?.isLoading}></CompletionSection>
{isSummarizationSupported && <SummarizationSection></SummarizationSection>}
<CompletionSection isLoading={state?.isLoading} platform={state?.platform}></CompletionSection>
{isSummarizationSupported && (
<SummarizationSection quoteStyle={state?.config.quoteStyle}></SummarizationSection>
)}
</>
)}
<ActionsSection></ActionsSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ import { VscodeIcon } from '../../shared/VscodeIcon/VscodeIcon';

interface CompletionSectionProps {
isLoading: boolean;
platform: NodeJS.Platform;
}

export function CompletionSection({ isLoading }: CompletionSectionProps = { isLoading: false }): JSX.Element {
export function CompletionSection({ isLoading, platform }: CompletionSectionProps): JSX.Element {
const handleGenerateClick = () => {
vscode.postMessage({
type: SidePanelMessageTypes.GENERATE_COMPLETION_CLICK,
});
};

const platformKeyBinding = platform === 'darwin' ? 'Cmd+Alt+Space' : 'Ctrl+Alt+Space';

return (
<section className="completion-section">
<h3>Code Completion</h3>
<span>
{/* TODO Detect OS and show specific keybindings */}
{/* TODO Consider getting keybinding from package.json */}
To generate inline code completion use combination <kbd>Ctrl+Alt+Space</kbd> or press the button below.
To generate inline code completion use combination <kbd>{platformKeyBinding}</kbd> or press the button below.
</span>
<br />
<button className="generate-button" onClick={handleGenerateClick} disabled={isLoading}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
export function SummarizationSection(): JSX.Element {
interface SummarizationSectionProps {
quoteStyle: string;
}

export function SummarizationSection({ quoteStyle }: SummarizationSectionProps): JSX.Element {
return (
<section className="summarization-section">
<h3>Summarization</h3>
<span>
{/* TODO Consider geting selected docstring quotes from extension settings */}
To use summarization for docstrings, start typing docstring quotes (<code>&quot;&quot;&quot;</code> by default).
To use summarization for docstrings, start typing docstring quotes (<code>{quoteStyle}</code>).
</span>
</section>
);
Expand Down
4 changes: 2 additions & 2 deletions modules/openvino_code/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export type CustomConfiguration = {
endToken: string;
stopToken: string;
} & {
quoteStyle?: string;
docstringFormat?: string;
quoteStyle: string;
docstringFormat: string;
};

export type ExtensionConfiguration = WorkspaceConfiguration & CustomConfiguration;
Expand Down
2 changes: 2 additions & 0 deletions modules/openvino_code/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IExtensionState, ConnectionStatus } from '@shared/extension-state';
import { INITIAL_SERVER_STATE, ServerStatus } from '@shared/server-state';
import { MODEL_SUPPORTED_FEATURES } from '@shared/model';
import { Features } from '@shared/features';
import { platform } from 'process';

class ExtensionState implements IExtensionComponent {
private readonly _state: IExtensionState = {
Expand All @@ -28,6 +29,7 @@ class ExtensionState implements IExtensionComponent {
return this.supportedList.includes(Features.SUMMARIZATION);
},
},
platform,
};

private _emitter = new EventEmitter();
Expand Down

0 comments on commit b13ed38

Please sign in to comment.