Skip to content

Commit 1514255

Browse files
committed
feat(llm): init llm provider
1 parent fe26f12 commit 1514255

File tree

5 files changed

+298
-0
lines changed

5 files changed

+298
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# @agent-infra/llm
2+
3+
A TypeScript SDK to call multiple LLM Prividers in OpenAI format.
4+
5+
## Installation
6+
7+
```bash
8+
pnpm install @agent-infra/llm
9+
```
10+
11+
## Motivation
12+
13+
14+
15+
16+
## Quick Start
17+
18+
### Create a OpenAI provider
19+
20+
```ts
21+
import { LLMClient } from '@agent-infra/llm';
22+
23+
const client = new LLMClient('openai', {
24+
apiKey: '',
25+
baseUrl: '',
26+
});
27+
28+
const result = await client.chat.completions.create({
29+
messages: [{ role: 'user', content: 'Say this is a test' }],
30+
model: 'gpt-4o',
31+
});
32+
```
33+
34+
## Features
35+
36+
### Create different providers
37+
38+
```ts
39+
import { LLMClient } from '@agent-infra/llm';
40+
41+
const client = new LLMClient('openrouter', {
42+
apiKey: '',
43+
baseUrl: '',
44+
});
45+
46+
const result = await client.chat.completions.create({
47+
messages: [{ role: 'user', content: 'Say this is a test' }],
48+
model: 'openai/gpt-4o',
49+
});
50+
```
51+
52+
## Create a Anthropic provider
53+
54+
```ts
55+
import { LLMClient } from '@agent-infra/llm';
56+
57+
const client = new LLMClient('anthropic', {
58+
apiKey: '',
59+
baseUrl: '',
60+
});
61+
62+
const result = await client.chat.completions.create({
63+
messages: [{ role: 'user', content: 'Say this is a test' }],
64+
model: 'openai/gpt-4o',
65+
});
66+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@agent-infra/llm",
3+
"version": "0.1.0",
4+
"description": "A TypeScript SDK to call multiple LLM Prividers in OpenAI format.",
5+
"main": "dist/index.js",
6+
"module": "dist/index.mjs",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"import": "./dist/index.mjs",
11+
"require": "./dist/index.js",
12+
"types": "./dist/index.d.ts"
13+
}
14+
},
15+
"files": [
16+
"dist"
17+
],
18+
"scripts": {
19+
"dev": "rslib build --watch",
20+
"build": "rslib build",
21+
"prepare": "npm run build",
22+
"prepublishOnly": "pnpm run build"
23+
},
24+
"dependencies": {
25+
"@anthropic-ai/sdk": "0.39.0",
26+
"@google/generative-ai": "0.24.0",
27+
"@google/genai": "0.8.0",
28+
"openai": "4.93.0"
29+
},
30+
"devDependencies": {
31+
"@types/node": "^20.10.4",
32+
"typescript": "^5.5.3"
33+
}
34+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import { defineConfig } from '@rslib/core';
6+
7+
const BANNER = `/**
8+
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
9+
* SPDX-License-Identifier: Apache-2.0
10+
*/`;
11+
12+
export default defineConfig({
13+
source: {
14+
entry: {
15+
index: 'src/index.ts',
16+
},
17+
},
18+
lib: [
19+
{
20+
format: 'esm',
21+
syntax: 'es2021',
22+
bundle: true,
23+
dts: true,
24+
banner: { js: BANNER },
25+
},
26+
{
27+
format: 'cjs',
28+
syntax: 'es2021',
29+
bundle: true,
30+
dts: true,
31+
banner: { js: BANNER },
32+
},
33+
],
34+
output: {
35+
target: 'web',
36+
cleanDistPath: true,
37+
sourceMap: true,
38+
},
39+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "commonjs",
5+
"declaration": true,
6+
"outDir": "./dist",
7+
"strict": true,
8+
"esModuleInterop": true,
9+
"skipLibCheck": true,
10+
"forceConsistentCasingInFileNames": true,
11+
"resolveJsonModule": true
12+
},
13+
"include": [
14+
"src/**/*"
15+
],
16+
"exclude": [
17+
"node_modules",
18+
"dist"
19+
]
20+
}

0 commit comments

Comments
 (0)