(
request: GetCompletionsRequest
)
| 71 | } |
| 72 | |
| 73 | async getCompletions( |
| 74 | request: GetCompletionsRequest |
| 75 | ): Promise<GetCompletionsResponse | undefined> { |
| 76 | this.abortController?.abort(); |
| 77 | this.abortController = new AbortController(); |
| 78 | const signal = this.abortController.signal; |
| 79 | const getCompletionsPromise = (await this.client).getCompletions(request, { |
| 80 | signal, |
| 81 | headers: this.getHeaders(request.metadata?.apiKey), |
| 82 | }); |
| 83 | try { |
| 84 | return await getCompletionsPromise; |
| 85 | } catch (err) { |
| 86 | if (signal.aborted) { |
| 87 | return; |
| 88 | } |
| 89 | if (err instanceof ConnectError) { |
| 90 | if (err.code != Code.Canceled) { |
| 91 | console.log(err.message); |
| 92 | await chrome.runtime.sendMessage(chrome.runtime.id, { |
| 93 | type: 'error', |
| 94 | message: err.message, |
| 95 | }); |
| 96 | } |
| 97 | } else { |
| 98 | console.log((err as Error).message); |
| 99 | await chrome.runtime.sendMessage(chrome.runtime.id, { |
| 100 | type: 'error', |
| 101 | message: (err as Error).message, |
| 102 | }); |
| 103 | } |
| 104 | return; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | async acceptedLastCompletion( |
| 109 | acceptCompletionRequest: PartialMessage<AcceptCompletionRequest> |
nothing calls this directly
no test coverage detected