Skip to content

Commit d413c5d

Browse files
committed
fix: embedding inference for gte-small type
- Fix wrong input variable name. - Accepting 'opts' param as optinal, applying null safes.
1 parent 23cddf9 commit d413c5d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ext/ai/js/ai.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ export type SessionInputOptions<T extends SessionType> = T extends "gte-small"
4444

4545
export type SessionOutput<T extends SessionType, O> = T extends "gte-small"
4646
? number[]
47-
: T extends LLMProviderName
48-
? O extends { stream: true }
49-
? AsyncGenerator<
47+
: T extends LLMProviderName ? O extends { stream: true } ? AsyncGenerator<
5048
Result<
5149
LLMProviderInstance<T>["output"],
5250
LLMProviderInstance<T>["error"]
@@ -104,7 +102,7 @@ export class Session<T extends SessionType> {
104102

105103
async run<O extends SessionInputOptions<T>>(
106104
input: SessionInput<T>,
107-
options: O,
105+
options?: O,
108106
): Promise<
109107
[SessionOutput<T, O>, undefined] | [undefined, SessionOutputError<T>]
110108
> {
@@ -136,14 +134,14 @@ export class Session<T extends SessionType> {
136134
await this.#init;
137135
}
138136

139-
const opts = options as EmbeddingInputOptions;
137+
const opts = options as EmbeddingInputOptions | undefined;
140138

141-
const mean_pool = opts.mean_pool ?? true;
142-
const normalize = opts.normalize ?? true;
139+
const mean_pool = opts?.mean_pool ?? true;
140+
const normalize = opts?.normalize ?? true;
143141

144142
const result = await core.ops.op_ai_run_model(
145143
this.#model,
146-
prompt,
144+
input,
147145
mean_pool,
148146
normalize,
149147
) as SessionOutput<T, typeof options>;

0 commit comments

Comments
 (0)