-
Notifications
You must be signed in to change notification settings - Fork 39
/
api.ts
49 lines (44 loc) 路 1.02 KB
/
api.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import type { AIServiceOptions } from '../../text/types.js';
import { OpenAI } from '../openai/api.js';
import type { OpenAIConfig } from '../openai/types.js';
type TogetherAIConfig = OpenAIConfig;
/**
* TogetherAI: Default Model options for text generation
* @export
*/
export const TogetherDefaultConfig = (): TogetherAIConfig => ({
model: 'llama2-70b-4096',
stream: false,
suffix: null,
maxTokens: 500,
temperature: 0.1,
topP: 0.9,
frequencyPenalty: 0.5
});
export interface TogetherArgs {
apiKey: string;
config: Readonly<TogetherAIConfig>;
options?: Readonly<AIServiceOptions>;
}
/**
* TogetherAI: AI Service
* @export
*/
export class Together extends OpenAI {
constructor({
apiKey,
config = TogetherDefaultConfig(),
options
}: Readonly<TogetherArgs>) {
if (!apiKey || apiKey === '') {
throw new Error('Together API key not set');
}
super({
apiKey,
config,
options,
apiURL: 'https://api.together.xyz/v1'
});
super.setName('Together');
}
}