Skip to content

Commit 9e6c1e3

Browse files
committed
feat: initial
0 parents  commit 9e6c1e3

File tree

22 files changed

+5545
-0
lines changed

22 files changed

+5545
-0
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = true

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.yarn/** linguist-vendored
2+
/.yarn/releases/* binary
3+
/.yarn/plugins/**/* binary
4+
/.pnp.* binary linguist-generated

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.yarn/*
2+
!.yarn/patches
3+
!.yarn/plugins
4+
!.yarn/releases
5+
!.yarn/sdks
6+
!.yarn/versions
7+
8+
# Whether you use PnP or not, the node_modules folder is often used to store
9+
# build artifacts that should be gitignored
10+
node_modules
11+
12+
# Swap the comments on the following lines if you wish to use zero-installs
13+
# In that case, don't forget to run `yarn config set enableGlobalCache false`!
14+
# Documentation here: https://yarnpkg.com/features/caching#zero-installs
15+
16+
#!.yarn/cache
17+
.pnp.*
18+
19+
# Build output
20+
dist

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# provider-conversions

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@inference-net/provider-conversions",
3+
"version": "0.0.1",
4+
"type": "module",
5+
"packageManager": "yarn@4.11.0",
6+
"main": "./dist/inference-net-provider-conversions.cjs",
7+
"module": "./dist/inference-net-provider-conversions.js",
8+
"types": "./dist/index.d.ts",
9+
"exports": {
10+
".": {
11+
"types": "./dist/index.d.ts",
12+
"import": "./dist/inference-net-provider-conversions.js",
13+
"require": "./dist/inference-net-provider-conversions.cjs"
14+
}
15+
},
16+
"files": [
17+
"dist"
18+
],
19+
"scripts": {
20+
"build": "tsc && vite build",
21+
"test": "vitest",
22+
"test:run": "vitest run"
23+
},
24+
"devDependencies": {
25+
"@anthropic-ai/sdk": "^0.71.0",
26+
"ai": "^5.0.102",
27+
"openai": "^6.9.1",
28+
"typescript": "^5.9.3",
29+
"vite": "^7.2.4",
30+
"vite-plugin-dts": "^4.5.4",
31+
"vitest": "^4.0.14"
32+
}
33+
}

src/ai/index.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import {
2+
generateText,
3+
streamText,
4+
type ToolSet,
5+
type TextStreamPart,
6+
} from "ai";
7+
8+
type RelevantAISDKParamsFields =
9+
// Core
10+
| "model"
11+
| "messages"
12+
// Prompt
13+
| "system"
14+
| "prompt"
15+
// Generation params
16+
| "maxOutputTokens"
17+
| "temperature"
18+
| "topP"
19+
| "topK"
20+
| "frequencyPenalty"
21+
| "presencePenalty"
22+
| "stopSequences"
23+
| "seed"
24+
// Tools
25+
| "tools"
26+
| "toolChoice";
27+
28+
type RelevantAISDKResponseFields =
29+
// Content
30+
| "text"
31+
| "reasoning"
32+
| "reasoningText"
33+
| "files"
34+
| "sources"
35+
// Tool calls & results
36+
| "toolCalls"
37+
| "toolResults"
38+
// Completion info
39+
| "finishReason"
40+
| "usage"
41+
// Response metadata
42+
| "response";
43+
44+
export type AiSDKGenerateTextParams = Parameters<typeof generateText>[0];
45+
export type AiSDKGenerateTextReturn = Awaited<ReturnType<typeof generateText>>;
46+
47+
export type AiSDKStreamTextParams = Parameters<typeof streamText>[0];
48+
export type AiSDKStreamTextReturn = Awaited<ReturnType<typeof streamText>>;
49+
50+
export type AiSDKParams = Pick<
51+
AiSDKGenerateTextParams & AiSDKStreamTextParams,
52+
RelevantAISDKParamsFields
53+
>;
54+
55+
export type AiSDKResponse = Pick<
56+
AiSDKGenerateTextReturn,
57+
RelevantAISDKResponseFields
58+
>;
59+
60+
export type AiSDKChunk<T extends ToolSet> = TextStreamPart<T>;

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as OpenAIChatCompletion from "./openai/chat-completion";
2+
import * as AISDKTypes from "./ai";
3+
4+
export { OpenAIChatCompletion, AISDKTypes };

0 commit comments

Comments
 (0)