-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathglobal.d.ts
164 lines (134 loc) · 4.46 KB
/
global.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
declare type BeforeunloadReason = "cpu" | "memory" | "wall_clock" | "early_drop" | "termination";
declare interface WindowEventMap {
"load": Event;
"unload": Event;
"beforeunload": CustomEvent<BeforeunloadReason>;
"drain": Event;
}
type DecoratorType = "tc39" | "typescript" | "typescript_with_metadata";
interface JsxImportBaseConfig {
defaultSpecifier?: string | null;
module?: string | null;
baseUrl?: string | null;
}
// TODO(Nyannyacha): These two type defs will be provided later.
// deno-lint-ignore no-explicit-any
type S3FsConfig = any;
// deno-lint-ignore no-explicit-any
type TmpFsConfig = any;
interface UserWorkerFetchOptions {
signal?: AbortSignal;
}
interface UserWorkerCreateOptions {
servicePath?: string | null;
envVars?: string[][] | [string, string][] | null;
noModuleCache?: boolean | null;
importMapPath?: string | null;
forceCreate?: boolean | null;
netAccessDisabled?: boolean | null;
allowNet?: string[] | null;
allowRemoteModules?: boolean | null;
customModuleRoot?: string | null;
maybeEszip?: Uint8Array | null;
maybeEntrypoint?: string | null;
maybeModuleCode?: string | null;
memoryLimitMb?: number | null;
lowMemoryMultiplier?: number | null;
workerTimeoutMs?: number | null;
cpuTimeSoftLimitMs?: number | null;
cpuTimeHardLimitMs?: number | null;
decoratorType?: DecoratorType | null;
jsxImportSourceConfig?: JsxImportBaseConfig | null;
s3FsConfig?: S3FsConfig | null;
tmpFsConfig?: TmpFsConfig | null;
context?: { [key: string]: unknown } | null;
}
interface HeapStatistics {
totalHeapSize: number;
totalHeapSizeExecutable: number;
totalPhysicalSize: number;
totalAvailableSize: number;
totalGlobalHandlesSize: number;
usedGlobalHandlesSize: number;
usedHeapSize: number;
mallocedMemory: number;
externalMemory: number;
peakMallocedMemory: number;
}
interface RuntimeMetrics {
mainWorkerHeapStats: HeapStatistics;
eventWorkerHeapStats?: HeapStatistics;
}
interface MemInfo {
total: number;
free: number;
available: number;
buffers: number;
cached: number;
swapTotal: number;
swapFree: number;
}
declare namespace EdgeRuntime {
export namespace ai {
function tryCleanupUnusedSession(): Promise<number>;
}
class UserWorker {
constructor(key: string);
fetch(request: Request, options?: UserWorkerFetchOptions): Promise<Response>;
static create(opts: UserWorkerCreateOptions): Promise<UserWorker>;
}
export function scheduleTermination(): void;
export function waitUntil<T>(promise: Promise<T>): Promise<T>;
export function getRuntimeMetrics(): Promise<RuntimeMetrics>;
export function applySupabaseTag(src: Request, dest: Request): void;
export function systemMemoryInfo(): MemInfo;
export function raiseSegfault(): void;
export { UserWorker as userWorkers };
}
declare namespace Supabase {
export namespace ai {
interface ModelOptions {
/**
* Pool embeddings by taking their mean. Applies only for `gte-small` model
*/
mean_pool?: boolean
/**
* Normalize the embeddings result. Applies only for `gte-small` model
*/
normalize?: boolean
/**
* Stream response from model. Applies only for LLMs like `mistral` (default: false)
*/
stream?: boolean
/**
* Automatically abort the request to the model after specified time (in seconds). Applies only for LLMs like `mistral` (default: 60)
*/
timeout?: number
/**
* Mode for the inference API host. (default: 'ollama')
*/
mode?: 'ollama' | 'openaicompatible'
signal?: AbortSignal
}
export class Session {
/**
* Create a new model session using given model
*/
constructor(model: string);
/**
* Execute the given prompt in model session
*/
run(
prompt:
| string
| Omit<import('openai').OpenAI.Chat.ChatCompletionCreateParams, 'model' | 'stream'>,
modelOptions?: ModelOptions
): unknown
}
}
}
declare namespace Deno {
export namespace errors {
class WorkerRequestCancelled extends Error { }
}
}