-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fdec22
commit c906d50
Showing
11 changed files
with
54 additions
and
242 deletions.
There are no files selected for viewing
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
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,2 @@ | ||
export const DEFAULT_COPILOT_MAX_TOKENS = 256 as const; | ||
export const DEFAULT_COPILOT_STOP_SEQUENCE = '\n\n' as const; |
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,28 @@ | ||
export const fetchWithTimeout = async ( | ||
url: string, | ||
options: RequestInit = {}, | ||
timeoutMs: number = 5000, | ||
): Promise<Response> => { | ||
const controller = new AbortController(); | ||
const {signal} = controller; | ||
|
||
const timeoutId = setTimeout(() => { | ||
controller.abort(); | ||
}, timeoutMs); | ||
|
||
try { | ||
const response = await fetch(url, { | ||
...options, | ||
signal, | ||
}); | ||
|
||
return response; | ||
} catch (error) { | ||
if (error instanceof DOMException && error.name === 'AbortError') { | ||
throw new Error(`Request timed out after ${timeoutMs}ms`); | ||
} | ||
throw error; | ||
} finally { | ||
clearTimeout(timeoutId); | ||
} | ||
}; |
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
Oops, something went wrong.