Skip to content

Commit 110905a

Browse files
committed
refactor
1 parent ea58d5d commit 110905a

16 files changed

+467
-258
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Task } from './tasks';
1+
import { TaskId } from './tasks';
22

33
/* eslint-disable @typescript-eslint/no-non-null-assertion */
44
export default {
55
collectionPath: process.env.COLLECTION_PATH!,
66
location: process.env.LOCATION!,
77
accessToken: process.env.HF_ACCESS_TOKEN!,
88
modelId: process.env.MODEL_ID!,
9-
task: process.env.TASK! as Task,
9+
task: process.env.TASK! as TaskId,
1010
inferenceEndpoint: process.env.HF_INFERENCE_ENDPOINT!,
1111
};

extensions/firestore-huggingface-inference-api/functions/src/inference.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { HfInference, HfInferenceEndpoint } from '@huggingface/inference';
12
import { describe, expect, test } from '@jest/globals';
23
import { runInference } from './inference';
3-
import { Task } from './tasks';
4-
import { HfInference, HfInferenceEndpoint } from '@huggingface/inference';
4+
import { TaskId } from './tasks';
55

66
const inference = new HfInference('test');
77

@@ -20,7 +20,7 @@ jest.mock('@huggingface/inference', () => ({
2020
})),
2121
}));
2222

23-
describe(Task.fillMask, () => {
23+
describe(TaskId.fillMask, () => {
2424
test('should throw an error if inputs are not provided', async () => {
2525
const snapshot = {
2626
data: () => ({
@@ -29,7 +29,7 @@ describe(Task.fillMask, () => {
2929
} as any;
3030

3131
await expect(
32-
runInference(snapshot, Task.fillMask, inference),
32+
runInference(snapshot, TaskId.fillMask, inference),
3333
).rejects.toThrow(Error);
3434
});
3535

@@ -41,12 +41,12 @@ describe(Task.fillMask, () => {
4141
} as any;
4242

4343
await expect(
44-
runInference(snapshot, Task.fillMask, inference),
44+
runInference(snapshot, TaskId.fillMask, inference),
4545
).rejects.toThrow(Error);
4646
});
4747
});
4848

49-
describe(Task.summarization, () => {
49+
describe(TaskId.summarization, () => {
5050
test('should throw an error if inputs are not provided', async () => {
5151
const snapshot = {
5252
data: () => ({
@@ -55,7 +55,7 @@ describe(Task.summarization, () => {
5555
} as any;
5656

5757
await expect(
58-
runInference(snapshot, Task.summarization, inference),
58+
runInference(snapshot, TaskId.summarization, inference),
5959
).rejects.toThrow(Error);
6060
});
6161

@@ -67,18 +67,18 @@ describe(Task.summarization, () => {
6767
} as any;
6868

6969
await expect(
70-
runInference(snapshot, Task.summarization, inference),
70+
runInference(snapshot, TaskId.summarization, inference),
7171
).rejects.toThrow(Error);
7272
});
7373
});
7474

7575
// Testing questionAnswering task.
76-
describe(Task.questionAnswering, () => {
77-
let mockTask: Task;
76+
describe(TaskId.questionAnswering, () => {
77+
let mockTask: TaskId;
7878
let inference: HfInference | HfInferenceEndpoint;
7979

8080
beforeAll(() => {
81-
mockTask = Task.questionAnswering;
81+
mockTask = TaskId.questionAnswering;
8282
inference = new HfInference();
8383
});
8484

@@ -140,8 +140,8 @@ describe(Task.questionAnswering, () => {
140140
});
141141

142142
// Testing tableQuestionAnswering task.
143-
describe(Task.tableQuestionAnswering, () => {
144-
let mockTask: Task;
143+
describe(TaskId.tableQuestionAnswering, () => {
144+
let mockTask: TaskId;
145145
let inference: HfInference | HfInferenceEndpoint;
146146
const snapshot = {
147147
data: () => ({
@@ -156,7 +156,7 @@ describe(Task.tableQuestionAnswering, () => {
156156
} as any;
157157

158158
beforeAll(() => {
159-
mockTask = Task.tableQuestionAnswering;
159+
mockTask = TaskId.tableQuestionAnswering;
160160
inference = new HfInference();
161161
});
162162

0 commit comments

Comments
 (0)