hide Hugging Face token usage in getModelInfo and related functions
Browse files- src/lib/huggingface.ts +33 -33
src/lib/huggingface.ts
CHANGED
|
@@ -5,21 +5,21 @@ const getModelInfo = async (
|
|
| 5 |
modelName: string,
|
| 6 |
pipeline: string
|
| 7 |
): Promise<ModelInfoResponse> => {
|
| 8 |
-
const token = process.env.REACT_APP_HUGGINGFACE_TOKEN
|
| 9 |
|
| 10 |
-
if (!token) {
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
}
|
| 15 |
|
| 16 |
const response = await fetch(
|
| 17 |
`https://huggingface.co/api/models/${modelName}`,
|
| 18 |
{
|
| 19 |
method: 'GET',
|
| 20 |
-
headers: {
|
| 21 |
-
|
| 22 |
-
}
|
| 23 |
}
|
| 24 |
)
|
| 25 |
|
|
@@ -103,9 +103,9 @@ const getModelInfo = async (
|
|
| 103 |
`https://huggingface.co/api/models/${baseModel}`,
|
| 104 |
{
|
| 105 |
method: 'GET',
|
| 106 |
-
headers: {
|
| 107 |
-
|
| 108 |
-
}
|
| 109 |
}
|
| 110 |
)
|
| 111 |
|
|
@@ -140,22 +140,22 @@ const getModelInfo = async (
|
|
| 140 |
const getModelsByPipeline = async (
|
| 141 |
pipelineTag: string
|
| 142 |
): Promise<ModelInfoResponse[]> => {
|
| 143 |
-
const token = process.env.REACT_APP_HUGGINGFACE_TOKEN
|
| 144 |
|
| 145 |
-
if (!token) {
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
}
|
| 150 |
|
| 151 |
// First search with filter=onnx
|
| 152 |
const response1 = await fetch(
|
| 153 |
`https://huggingface.co/api/models?filter=${pipelineTag}&filter=onnx&sort=downloads&limit=50`,
|
| 154 |
{
|
| 155 |
method: 'GET',
|
| 156 |
-
headers: {
|
| 157 |
-
|
| 158 |
-
}
|
| 159 |
}
|
| 160 |
)
|
| 161 |
if (!response1.ok) {
|
|
@@ -170,9 +170,9 @@ const getModelsByPipeline = async (
|
|
| 170 |
`https://huggingface.co/api/models?filter=${pipelineTag}&search=onnx&sort=downloads&limit=50`,
|
| 171 |
{
|
| 172 |
method: 'GET',
|
| 173 |
-
headers: {
|
| 174 |
-
|
| 175 |
-
}
|
| 176 |
}
|
| 177 |
)
|
| 178 |
if (!response2.ok) {
|
|
@@ -209,20 +209,20 @@ const getModelsByPipelineCustom = async (
|
|
| 209 |
searchString: string,
|
| 210 |
pipelineTag: string
|
| 211 |
): Promise<ModelInfoResponse[]> => {
|
| 212 |
-
const token = process.env.REACT_APP_HUGGINGFACE_TOKEN
|
| 213 |
|
| 214 |
-
if (!token) {
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
}
|
| 219 |
const response = await fetch(
|
| 220 |
`https://huggingface.co/api/models?filter=${pipelineTag}&search=${searchString}&sort=downloads&limit=50`,
|
| 221 |
{
|
| 222 |
method: 'GET',
|
| 223 |
-
headers: {
|
| 224 |
-
|
| 225 |
-
}
|
| 226 |
}
|
| 227 |
)
|
| 228 |
|
|
|
|
| 5 |
modelName: string,
|
| 6 |
pipeline: string
|
| 7 |
): Promise<ModelInfoResponse> => {
|
| 8 |
+
// const token = process.env.REACT_APP_HUGGINGFACE_TOKEN
|
| 9 |
|
| 10 |
+
// if (!token) {
|
| 11 |
+
// throw new Error(
|
| 12 |
+
// 'Hugging Face token not found. Please set REACT_APP_HUGGINGFACE_TOKEN in your .env file'
|
| 13 |
+
// )
|
| 14 |
+
// }
|
| 15 |
|
| 16 |
const response = await fetch(
|
| 17 |
`https://huggingface.co/api/models/${modelName}`,
|
| 18 |
{
|
| 19 |
method: 'GET',
|
| 20 |
+
// headers: {
|
| 21 |
+
// Authorization: `Bearer ${token}`
|
| 22 |
+
// }
|
| 23 |
}
|
| 24 |
)
|
| 25 |
|
|
|
|
| 103 |
`https://huggingface.co/api/models/${baseModel}`,
|
| 104 |
{
|
| 105 |
method: 'GET',
|
| 106 |
+
// headers: {
|
| 107 |
+
// Authorization: `Bearer ${token}`
|
| 108 |
+
// }
|
| 109 |
}
|
| 110 |
)
|
| 111 |
|
|
|
|
| 140 |
const getModelsByPipeline = async (
|
| 141 |
pipelineTag: string
|
| 142 |
): Promise<ModelInfoResponse[]> => {
|
| 143 |
+
// const token = process.env.REACT_APP_HUGGINGFACE_TOKEN
|
| 144 |
|
| 145 |
+
// if (!token) {
|
| 146 |
+
// throw new Error(
|
| 147 |
+
// 'Hugging Face token not found. Please set REACT_APP_HUGGINGFACE_TOKEN in your .env file'
|
| 148 |
+
// )
|
| 149 |
+
// }
|
| 150 |
|
| 151 |
// First search with filter=onnx
|
| 152 |
const response1 = await fetch(
|
| 153 |
`https://huggingface.co/api/models?filter=${pipelineTag}&filter=onnx&sort=downloads&limit=50`,
|
| 154 |
{
|
| 155 |
method: 'GET',
|
| 156 |
+
// headers: {
|
| 157 |
+
// Authorization: `Bearer ${token}`
|
| 158 |
+
// }
|
| 159 |
}
|
| 160 |
)
|
| 161 |
if (!response1.ok) {
|
|
|
|
| 170 |
`https://huggingface.co/api/models?filter=${pipelineTag}&search=onnx&sort=downloads&limit=50`,
|
| 171 |
{
|
| 172 |
method: 'GET',
|
| 173 |
+
// headers: {
|
| 174 |
+
// Authorization: `Bearer ${token}`
|
| 175 |
+
// }
|
| 176 |
}
|
| 177 |
)
|
| 178 |
if (!response2.ok) {
|
|
|
|
| 209 |
searchString: string,
|
| 210 |
pipelineTag: string
|
| 211 |
): Promise<ModelInfoResponse[]> => {
|
| 212 |
+
// const token = process.env.REACT_APP_HUGGINGFACE_TOKEN
|
| 213 |
|
| 214 |
+
// if (!token) {
|
| 215 |
+
// throw new Error(
|
| 216 |
+
// 'Hugging Face token not found. Please set REACT_APP_HUGGINGFACE_TOKEN in your .env file'
|
| 217 |
+
// )
|
| 218 |
+
// }
|
| 219 |
const response = await fetch(
|
| 220 |
`https://huggingface.co/api/models?filter=${pipelineTag}&search=${searchString}&sort=downloads&limit=50`,
|
| 221 |
{
|
| 222 |
method: 'GET',
|
| 223 |
+
// headers: {
|
| 224 |
+
// Authorization: `Bearer ${token}`
|
| 225 |
+
// }
|
| 226 |
}
|
| 227 |
)
|
| 228 |
|