-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchat.ts
34 lines (31 loc) · 1.2 KB
/
chat.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
import { LLMGateway } from "../src/index";
import { EnumLLMProvider } from "../src/types";
const llmGatewayTest = async () => {
//ANTHROPIC
const anthropicGateway = new LLMGateway({
provider: EnumLLMProvider.ANTHROPIC, // or ANTHROPIC, AZUREOPENAI, OPENAI
apiKey: process.env['ANTHROPIC_API_KEY'],
});
const anthropicResponse = await anthropicGateway.chatCompletion({
messages: [
{ role: 'user', content: 'Write a one sentence story about a cat.' }
],
model: 'claude-3-5-sonnet-latest',
max_tokens:200
})
console.log('Response:', JSON.stringify(anthropicResponse.llmGatewayOutput, null, 2));
// OPEN AI
const openAIGateway = new LLMGateway({
provider: EnumLLMProvider.OPENAI, // or ANTHROPIC, AZUREOPENAI, OPENAI
apiKey: process.env['OPENAI_API_KEY'],
});
const openAIresponse = await openAIGateway.chatCompletion({
messages: [
{ role: 'user', content: 'Write a one sentence story about a cat.' }
],
model: 'gpt-4o-mini',
max_completion_tokens:200
})
console.log('Response:', JSON.stringify(openAIresponse.llmGatewayOutput, null, 2));
}
llmGatewayTest()