Skip to content

Commit ea58d5d

Browse files
committed
chore: move some tasks
1 parent 5a61325 commit ea58d5d

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ import {
1212
ZeroShotClassificationOutput,
1313
HfInferenceEndpoint,
1414
HfInference,
15+
FeatureExtractionOutput,
16+
ConversationalOutput,
1517
} from '@huggingface/inference';
1618

1719
import config from './config';
1820
import { Task } from './tasks';
1921
import { FirestoreTableInput } from './types/table';
22+
import { conversational } from './tasks/conversational';
23+
import { featureExtraction } from './tasks/feature-extraction';
2024

2125
/**
2226
* Validate inputs and create a task.
@@ -39,6 +43,8 @@ export async function runInference(
3943
| TokenClassificationOutput
4044
| TranslationOutput
4145
| ZeroShotClassificationOutput
46+
| FeatureExtractionOutput
47+
| ConversationalOutput
4248
> {
4349
switch (task) {
4450
case Task.fillMask: {
@@ -221,10 +227,10 @@ export async function runInference(
221227
return await inference.zeroShotClassification(options);
222228
}
223229
case Task.conversational: {
224-
throw new Error('Conversational task is not supported yet');
230+
return await conversational(snapshot, inference);
225231
}
226232
case Task.featureExtraction: {
227-
throw new Error('Feature extraction task is not supported yet');
233+
return await featureExtraction(snapshot, inference);
228234
}
229235

230236
default: {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {
2+
ConversationalOutput,
3+
HfInference,
4+
HfInferenceEndpoint,
5+
} from '@huggingface/inference';
6+
import { DocumentSnapshot } from 'firebase-admin/firestore';
7+
8+
export function conversational(
9+
data: DocumentSnapshot,
10+
inference: HfInference | HfInferenceEndpoint,
11+
): Promise<ConversationalOutput> {
12+
throw new Error('Conversational task is not supported yet');
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {
2+
FeatureExtractionOutput,
3+
HfInference,
4+
HfInferenceEndpoint,
5+
} from '@huggingface/inference';
6+
import { DocumentSnapshot } from 'firebase-admin/firestore';
7+
8+
export function featureExtraction(
9+
data: DocumentSnapshot,
10+
inference: HfInference | HfInferenceEndpoint,
11+
): Promise<FeatureExtractionOutput> {
12+
throw new Error('Feature Extraction task is not supported yet');
13+
}

0 commit comments

Comments
 (0)