-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](copilot.service.ts): Remove deprecated imports and update key e…
…vent handling logic [feat](copilot.service.ts): Add new dependencies and features to copilotPlugin [fix](copilot.service.ts): Update renderHint function to use new widget view component [fix](copilot.service.ts): Throttle API calls to prevent excessive requests [fix](copilot.service.ts): Update fetchAIHint function to use the config from localStorage [fix](copilot.service.ts): Update API request headers to use token from localStorage [fix](copilot-widget.component.ts): Update template to use updated CSS class [fix](top-bar.component.ts): Update selector name to 'top-bar' [fix](collaborative-editing.component.ts): Update import statement for component [fix](workGround.component.html): Update component selector to use 'top-bar' [fix](workGround.component.ts): Update import statement for component [fix](workGround.component.ts): Pass provider to copilotPlugin in the configuration [fix](README.md): Mark 'plugin-copilot' as supported
- Loading branch information
Showing
9 changed files
with
90 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copilot Plugin | ||
|
||
This plugin allows you to use Copilot in your app. | ||
|
||
LocalStorage is used to store the model and the api key. | ||
|
||
Set them before using the plugin. | ||
|
||
```typescript | ||
window.localStorage.setItem('openai-api-url', 'https://api.openai.com/v1/completions'); | ||
window.localStorage.setItem('openai-api-token', 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); | ||
window.localStorage.setItem('openai-api-config', '{"model":"davinci-002","max_tokens":7,"temperature":0,"top_p":1,"n":1,"stream":false,"logprobs":null}'); | ||
``` |
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
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,33 @@ | ||
export function debounce(fn: Function, delay = 800, ...args: any[]) { | ||
// @ts-ignore | ||
let context = this; | ||
if (timer !== null) { | ||
clearTimeout(timer) | ||
} | ||
timer = setTimeout(() => { | ||
fn.apply(context, args); | ||
timer = null | ||
}, delay) | ||
} | ||
|
||
|
||
let timer: number = null; | ||
let startTime = Date.now(); | ||
|
||
export function throttle(fn: Function, wait = 800, ...args: any[]) { | ||
let curTime = Date.now(); | ||
let remaining = wait - (curTime - startTime); | ||
// @ts-ignore | ||
let context = this; | ||
|
||
clearTimeout(timer); | ||
|
||
if (remaining <= 0) { | ||
fn.apply(context, args); | ||
startTime = Date.now(); | ||
} else { | ||
timer = setTimeout(()=>{ | ||
fn.apply(context, args); | ||
}, remaining); // 如果小于wait 保证在差值时间后执行 | ||
} | ||
} |