@tansy/ai-openai 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/index.d.ts +4 -0
- package/index.js +27 -0
- package/package.json +29 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohamed Salah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- Generated by scripts/package-metadata.mjs. Change that script, not this file. -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @tansy/ai-openai
|
|
4
|
+
|
|
5
|
+
OpenAI for @tansy/ai.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tansy/ai-openai
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Add it to `tansy.config.ts`. See [the ai plugin documentation](https://github.com/mhmdsalahsebai/tansy/blob/main/docs/plugins/ai.md) for what it adds and the options it takes.
|
|
12
|
+
|
|
13
|
+
A first-party plugin for [tansy](https://github.com/mhmdsalahsebai/tansy), a self-hosted, runtime-schema CMS for Next.js. MIT licensed.
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
+
import { defineAiProvider, guessCapabilities, openAiModels, str } from "@tansy/ai/provider";
|
|
3
|
+
/** OpenAI, through the AI SDK's @ai-sdk/openai. */
|
|
4
|
+
export const openai = (options = {}) => defineAiProvider({
|
|
5
|
+
id: "openai",
|
|
6
|
+
label: "OpenAI",
|
|
7
|
+
defaultModel: options.defaultModel ?? "gpt-6-astra",
|
|
8
|
+
// Its settings in other interface languages. English is each setting's own label and description.
|
|
9
|
+
messages: {
|
|
10
|
+
ar: {
|
|
11
|
+
settings: {
|
|
12
|
+
openaiApiKey: {
|
|
13
|
+
label: "مفتاح API لـ OpenAI",
|
|
14
|
+
description: "من platform.openai.com ← API keys."
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
settings: () => [
|
|
20
|
+
{ name: "openaiApiKey", type: "secret", env: "OPENAI_API_KEY", label: "OpenAI API key", description: "From platform.openai.com → API keys." },
|
|
21
|
+
],
|
|
22
|
+
ready: (settings) => Boolean(str(settings.openaiApiKey)),
|
|
23
|
+
model: (settings, modelId) => createOpenAI({ apiKey: str(settings.openaiApiKey) })(modelId),
|
|
24
|
+
// GPT Image and DALL·E draw pictures. OpenAI's /models lists ids only, so what each can do comes from its name.
|
|
25
|
+
imageModel: (settings, modelId) => (guessCapabilities(modelId).output?.includes("image") ? createOpenAI({ apiKey: str(settings.openaiApiKey) }).image(modelId) : undefined),
|
|
26
|
+
models: (settings) => openAiModels("https://api.openai.com/v1", str(settings.openaiApiKey)),
|
|
27
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tansy/ai-openai",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OpenAI for @tansy/ai.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"tansy",
|
|
7
|
+
"tansy-ai-provider"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Mohamed Salah <mohamedsalahsebai@gmail.com>",
|
|
11
|
+
"homepage": "https://github.com/mhmdsalahsebai/tansy",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/mhmdsalahsebai/tansy.git",
|
|
15
|
+
"directory": "plugins/ai-openai"
|
|
16
|
+
},
|
|
17
|
+
"bugs": "https://github.com/mhmdsalahsebai/tansy/issues",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./index.d.ts",
|
|
21
|
+
"default": "./index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@tansy/ai": "^0.1.0",
|
|
26
|
+
"tansy": "^0.1.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@ai-sdk/openai": "^4.0.118"
|
|
30
|
+
}
|
|
31
|
+
}
|