File size: 3,505 Bytes
21dd449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import type { PipelineType } from "@huggingface/tasks";

export type RepoType = "space" | "dataset" | "model";

export interface RepoId {
	name: string;
	type: RepoType;
}

export type RepoFullName = string | `spaces/${string}` | `datasets/${string}`;

export type RepoDesignation = RepoId | RepoFullName;

/** Actually `hf_${string}`, but for convenience, using the string type */
export type AccessToken = string;

/**
 * @deprecated Use `AccessToken` instead. Pass { accessToken: "hf_..." } instead of { credentials: { accessToken: "hf_..." } }
 */
export interface Credentials {
	accessToken: AccessToken;
}

export type CredentialsParams =
	| {
			accessToken?: undefined;
			/**
			 * @deprecated Use `accessToken` instead
			 */
			credentials: Credentials;
	  }
	| {
			accessToken: AccessToken;
			/**
			 * @deprecated Use `accessToken` instead
			 */
			credentials?: undefined;
	  };

export type SpaceHardwareFlavor =
	| "cpu-basic"
	| "cpu-upgrade"
	| "t4-small"
	| "t4-medium"
	| "l4x1"
	| "l4x4"
	| "a10g-small"
	| "a10g-large"
	| "a10g-largex2"
	| "a10g-largex4"
	| "a100-large"
	| "v5e-1x1"
	| "v5e-2x2"
	| "v5e-2x4";

export type SpaceSdk = "streamlit" | "gradio" | "docker" | "static";

export type SpaceStage =
	| "NO_APP_FILE"
	| "CONFIG_ERROR"
	| "BUILDING"
	| "BUILD_ERROR"
	| "RUNNING"
	| "RUNNING_BUILDING"
	| "RUNTIME_ERROR"
	| "DELETING"
	| "PAUSED"
	| "SLEEPING";

export type AccessTokenRole = "admin" | "write" | "contributor" | "read";

export type AuthType = "access_token" | "app_token" | "app_token_as_user";

export type { PipelineType };

export interface SpaceRuntime {
	stage: SpaceStage;
	sdk?: SpaceSdk;
	sdkVersion?: string;
	errorMessage?: string;
	hardware?: {
		current: SpaceHardwareFlavor | null;
		currentPrettyName?: string;
		requested: SpaceHardwareFlavor | null;
		requestedPrettyName?: string;
	};
	/** when calling /spaces, those props are only fetched if ?full=true */
	resources?: SpaceResourceConfig;
	/** in seconds */
	gcTimeout?: number | null;
}

export interface SpaceResourceRequirement {
	cpu?: string;
	memory?: string;
	gpu?: string;
	gpuModel?: string;
	ephemeral?: string;
}

export interface SpaceResourceConfig {
	requests: SpaceResourceRequirement;
	limits: SpaceResourceRequirement;
	replicas?: number;
	throttled?: boolean;
	is_custom?: boolean;
}

export type License =
	| "apache-2.0"
	| "mit"
	| "openrail"
	| "bigscience-openrail-m"
	| "creativeml-openrail-m"
	| "bigscience-bloom-rail-1.0"
	| "bigcode-openrail-m"
	| "afl-3.0"
	| "artistic-2.0"
	| "bsl-1.0"
	| "bsd"
	| "bsd-2-clause"
	| "bsd-3-clause"
	| "bsd-3-clause-clear"
	| "c-uda"
	| "cc"
	| "cc0-1.0"
	| "cc-by-2.0"
	| "cc-by-2.5"
	| "cc-by-3.0"
	| "cc-by-4.0"
	| "cc-by-sa-3.0"
	| "cc-by-sa-4.0"
	| "cc-by-nc-2.0"
	| "cc-by-nc-3.0"
	| "cc-by-nc-4.0"
	| "cc-by-nd-4.0"
	| "cc-by-nc-nd-3.0"
	| "cc-by-nc-nd-4.0"
	| "cc-by-nc-sa-2.0"
	| "cc-by-nc-sa-3.0"
	| "cc-by-nc-sa-4.0"
	| "cdla-sharing-1.0"
	| "cdla-permissive-1.0"
	| "cdla-permissive-2.0"
	| "wtfpl"
	| "ecl-2.0"
	| "epl-1.0"
	| "epl-2.0"
	| "etalab-2.0"
	| "eupl-1.1"
	| "agpl-3.0"
	| "gfdl"
	| "gpl"
	| "gpl-2.0"
	| "gpl-3.0"
	| "lgpl"
	| "lgpl-2.1"
	| "lgpl-3.0"
	| "isc"
	| "lppl-1.3c"
	| "ms-pl"
	| "mpl-2.0"
	| "odc-by"
	| "odbl"
	| "openrail++"
	| "osl-3.0"
	| "postgresql"
	| "ofl-1.1"
	| "ncsa"
	| "unlicense"
	| "zlib"
	| "pddl"
	| "lgpl-lr"
	| "deepfloyd-if-license"
	| "llama2"
	| "llama3"
	| "llama3.1"
	| "llama3.2"
	| "llama3.3"
	| "gemma"
	| "apple-ascl"
	| "apple-amlr"
	| "unknown"
	| "other";