File tree Expand file tree Collapse file tree 5 files changed +298
-0
lines changed
packages/agent-infra/agent/llm Expand file tree Collapse file tree 5 files changed +298
-0
lines changed Original file line number Diff line number Diff line change
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
+ ```
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ } ) ;
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments