-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix): expression measurement is migrated and tested
- Loading branch information
Showing
11 changed files
with
144 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
export * as Hume from "./api"; | ||
export { HumeBatchClient } from "./wrapper/HumeBatchClient"; | ||
export { HumeStreamingClient } from "./wrapper/HumeStreamingClient"; | ||
export { Job } from "./wrapper/Job"; | ||
export { HumeClient } from "./wrapper/HumeClient"; | ||
export { HumeEnvironment } from "./environments"; | ||
export { HumeError, HumeTimeoutError } from "./errors"; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { HumeClient as FernClient } from "../Client"; | ||
import { ExpressionMeasurement } from "./expressionMeasurement/ExpressionMeasurementClient"; | ||
|
||
export class HumeClient extends FernClient { | ||
protected _expressionMeasurement: ExpressionMeasurement | undefined; | ||
|
||
public get expressionMeasurement(): ExpressionMeasurement { | ||
return (this._expressionMeasurement ??= new ExpressionMeasurement(this._options)); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/wrapper/expressionMeasurement/ExpressionMeasurementClient.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ExpressionMeasurement as FernClient } from "../../api/resources/expressionMeasurement/client/Client"; | ||
import { BatchClient } from "./batch/BatchClient"; | ||
import { StreamClient } from "./streaming/StreamingClient"; | ||
|
||
export class ExpressionMeasurement extends FernClient { | ||
protected _batch: BatchClient | undefined; | ||
|
||
public get batch(): BatchClient { | ||
return (this._batch ??= new BatchClient(this._options)); | ||
} | ||
|
||
protected _stream: StreamClient | undefined; | ||
|
||
public get stream(): StreamClient { | ||
return (this._stream ??= new StreamClient(this._options)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Batch as FernClient } from "../../../api/resources/expressionMeasurement/resources/batch/client/Client"; | ||
import * as Hume from "../../../api"; | ||
import { Job } from "./Job"; | ||
|
||
export class BatchClient extends FernClient { | ||
public async startInferenceJob( | ||
request: Hume.expressionMeasurement.InferenceBaseRequest = {}, | ||
requestOptions?: FernClient.RequestOptions | ||
): Promise<Job> { | ||
const { jobId } = await super.startInferenceJob(request, requestOptions); | ||
return new Job(jobId, this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { HumeClient } from "../../src/" | ||
|
||
describe("Streaming Expression Measurement", () => { | ||
it("Emotional Language Text", async () => { | ||
const hume = new HumeClient({ | ||
apiKey: "<>" | ||
}); | ||
const job = await hume.expressionMeasurement.batch.startInferenceJob({ | ||
models: { | ||
face: {} | ||
}, | ||
urls: ["https://hume-tutorials.s3.amazonaws.com/faces.zip"] | ||
}); | ||
await job.awaitCompletion(); | ||
const predictions = await hume.expressionMeasurement.batch.getJobPredictions(job.jobId); | ||
console.log(JSON.stringify(predictions, null, 2)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { HumeClient } from "../../src/" | ||
|
||
const samples = [ | ||
"Mary had a little lamb,", | ||
"Its fleece was white as snow.", | ||
"Everywhere the child went,", | ||
"The little lamb was sure to go." | ||
]; | ||
|
||
describe("Streaming Expression Measurement", () => { | ||
it.skip("Emotional Language Text", async () => { | ||
const hume = new HumeClient({ | ||
apiKey: "<>" | ||
}); | ||
const socket = hume.expressionMeasurement.stream.connect({ | ||
config: { | ||
language: {} | ||
} | ||
}) | ||
for (const sample of samples) { | ||
const result = await socket.sendText({ text: sample }) | ||
console.log(result) | ||
} | ||
}, 100000); | ||
}); |