forked from run-llama/LlamaIndexTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtogether.ts
27 lines (23 loc) · 787 Bytes
/
together.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { getEnv } from "@llamaindex/env";
import { OpenAIEmbedding } from "@llamaindex/openai";
export class TogetherEmbedding extends OpenAIEmbedding {
constructor(init?: Omit<Partial<OpenAIEmbedding>, "session">) {
const {
apiKey = getEnv("TOGETHER_API_KEY"),
additionalSessionOptions = {},
model = "togethercomputer/m2-bert-80M-32k-retrieval",
...rest
} = init ?? {};
if (!apiKey) {
throw new Error("Set Together Key in TOGETHER_API_KEY env variable"); // Tell user to set correct env variable, and not OPENAI_API_KEY
}
additionalSessionOptions.baseURL =
additionalSessionOptions.baseURL ?? "https://api.together.xyz/v1";
super({
apiKey,
additionalSessionOptions,
model,
...rest,
});
}
}