@adminforth/completion-adapter-openai-responses 1.0.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/.woodpecker/buildRelease.sh +9 -0
- package/.woodpecker/buildSlackNotify.sh +44 -0
- package/.woodpecker/release.yml +56 -0
- package/Changelog.md +6 -0
- package/LICENSE +21 -0
- package/README.md +47 -0
- package/build.log +4 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +613 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.js +1 -0
- package/index.ts +818 -0
- package/package.json +62 -0
- package/tsconfig.json +14 -0
- package/types.ts +42 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -x
|
|
4
|
+
|
|
5
|
+
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
|
|
6
|
+
|
|
7
|
+
STATUS=${1}
|
|
8
|
+
|
|
9
|
+
if [ "$STATUS" = "success" ]; then
|
|
10
|
+
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
11
|
+
|
|
12
|
+
curl -s -X POST -H "Content-Type: application/json" -d '{
|
|
13
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
14
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
15
|
+
"attachments": [
|
|
16
|
+
{
|
|
17
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
18
|
+
"color": "#36a64f",
|
|
19
|
+
"text": "'"$MESSAGE"'"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK"
|
|
23
|
+
exit 0
|
|
24
|
+
fi
|
|
25
|
+
export BUILD_LOG=$(cat ./build.log)
|
|
26
|
+
|
|
27
|
+
BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
|
|
28
|
+
|
|
29
|
+
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
|
|
30
|
+
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
|
|
31
|
+
|
|
32
|
+
echo "Sending slack message to developers $MESSAGE"
|
|
33
|
+
curl -sS -X POST -H "Content-Type: application/json" -d '{
|
|
34
|
+
"username": "'"$CI_COMMIT_AUTHOR"'",
|
|
35
|
+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
|
|
36
|
+
"attachments": [
|
|
37
|
+
{
|
|
38
|
+
"mrkdwn_in": ["text", "pretext"],
|
|
39
|
+
"color": "#8A1C12",
|
|
40
|
+
"text": "'"$CODE_BLOCK"'",
|
|
41
|
+
"pretext": "'"$MESSAGE"'"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
clone:
|
|
2
|
+
git:
|
|
3
|
+
image: woodpeckerci/plugin-git
|
|
4
|
+
settings:
|
|
5
|
+
partial: false
|
|
6
|
+
depth: 5
|
|
7
|
+
|
|
8
|
+
steps:
|
|
9
|
+
init-secrets:
|
|
10
|
+
when:
|
|
11
|
+
- event: push
|
|
12
|
+
image: infisical/cli
|
|
13
|
+
environment:
|
|
14
|
+
INFISICAL_TOKEN:
|
|
15
|
+
from_secret: VAULT_TOKEN
|
|
16
|
+
commands:
|
|
17
|
+
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
|
|
18
|
+
|
|
19
|
+
build:
|
|
20
|
+
image: devforth/node20-pnpm:latest
|
|
21
|
+
when:
|
|
22
|
+
- event: push
|
|
23
|
+
commands:
|
|
24
|
+
- . /woodpecker/deploy.vault.env
|
|
25
|
+
- pnpm install
|
|
26
|
+
- /bin/bash ./.woodpecker/buildRelease.sh
|
|
27
|
+
- npm audit signatures
|
|
28
|
+
|
|
29
|
+
release:
|
|
30
|
+
image: devforth/node20-pnpm:latest
|
|
31
|
+
when:
|
|
32
|
+
- event:
|
|
33
|
+
- push
|
|
34
|
+
branch:
|
|
35
|
+
- main
|
|
36
|
+
commands:
|
|
37
|
+
- . /woodpecker/deploy.vault.env
|
|
38
|
+
- pnpm exec semantic-release
|
|
39
|
+
|
|
40
|
+
slack-on-failure:
|
|
41
|
+
image: curlimages/curl
|
|
42
|
+
when:
|
|
43
|
+
- event: push
|
|
44
|
+
status: [failure]
|
|
45
|
+
commands:
|
|
46
|
+
- . /woodpecker/deploy.vault.env
|
|
47
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh failure
|
|
48
|
+
|
|
49
|
+
slack-on-success:
|
|
50
|
+
image: curlimages/curl
|
|
51
|
+
when:
|
|
52
|
+
- event: push
|
|
53
|
+
status: [success]
|
|
54
|
+
commands:
|
|
55
|
+
- . /woodpecker/deploy.vault.env
|
|
56
|
+
- /bin/sh ./.woodpecker/buildSlackNotify.sh success
|
package/Changelog.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Devforth.io
|
|
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
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @adminforth/completion-adapter-openai-responses
|
|
2
|
+
|
|
3
|
+
AdminForth completion adapter for the OpenAI Responses API.
|
|
4
|
+
|
|
5
|
+
This package is the fully compatible successor to `@adminforth/completion-adapter-open-ai-chat-gpt`.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm i @adminforth/completion-adapter-openai-responses
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import CompletionAdapterOpenAIResponses from "@adminforth/completion-adapter-openai-responses";
|
|
17
|
+
|
|
18
|
+
const adapter = new CompletionAdapterOpenAIResponses({
|
|
19
|
+
openAiApiKey: process.env.OPENAI_API_KEY as string,
|
|
20
|
+
model: "gpt-5-nano",
|
|
21
|
+
extraRequestBodyParameters: {
|
|
22
|
+
temperature: 0.7,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
OpenAI-compatible providers can be used by overriding the base URL:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const adapter = new CompletionAdapterOpenAIResponses({
|
|
31
|
+
openAiApiKey: process.env.OVH_AI_ENDPOINTS_ACCESS_TOKEN as string,
|
|
32
|
+
baseUrl: "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1",
|
|
33
|
+
model: "gpt-oss-20b",
|
|
34
|
+
extraRequestBodyParameters: {
|
|
35
|
+
store: false,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The adapter supports:
|
|
41
|
+
|
|
42
|
+
- regular text completion
|
|
43
|
+
- `json_schema` structured output
|
|
44
|
+
- reasoning effort control
|
|
45
|
+
- tool calls
|
|
46
|
+
- streaming output chunks
|
|
47
|
+
- streaming reasoning chunks
|
package/build.log
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AdapterOptions } from "./types.js";
|
|
2
|
+
import type { CompletionAdapter, CompletionStreamEvent, CompletionTool } from "adminforth";
|
|
3
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
4
|
+
export type { AdapterOptions } from "./types.js";
|
|
5
|
+
type StreamChunkCallback = (chunk: string, event?: CompletionStreamEvent) => void | Promise<void>;
|
|
6
|
+
type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
7
|
+
type AgentModelPurpose = "primary" | "summary";
|
|
8
|
+
type CompletionRequestInput = {
|
|
9
|
+
content: string;
|
|
10
|
+
maxTokens?: number;
|
|
11
|
+
outputSchema?: any;
|
|
12
|
+
reasoningEffort?: ReasoningEffort;
|
|
13
|
+
tools?: CompletionTool[];
|
|
14
|
+
onChunk?: StreamChunkCallback;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
};
|
|
17
|
+
type UsedTokens = {
|
|
18
|
+
input_uncached: number;
|
|
19
|
+
input_cached: number;
|
|
20
|
+
output: number;
|
|
21
|
+
};
|
|
22
|
+
type CompletionResult = {
|
|
23
|
+
content?: string;
|
|
24
|
+
finishReason?: string;
|
|
25
|
+
error?: string;
|
|
26
|
+
used_tokens?: UsedTokens;
|
|
27
|
+
};
|
|
28
|
+
export default class CompletionAdapterOpenAIResponses implements CompletionAdapter {
|
|
29
|
+
options: AdapterOptions;
|
|
30
|
+
private encoding;
|
|
31
|
+
private activeAbortController;
|
|
32
|
+
constructor(options: AdapterOptions);
|
|
33
|
+
validate(): void;
|
|
34
|
+
measureTokensCount(content: string): number;
|
|
35
|
+
abort(): void;
|
|
36
|
+
isGenerationInProgress(): boolean;
|
|
37
|
+
private getConfiguredBaseUrl;
|
|
38
|
+
private shouldUseComplitionApi;
|
|
39
|
+
private shouldDumpRawRequest;
|
|
40
|
+
private getClientConfiguration;
|
|
41
|
+
private createResponsesDebugFetch;
|
|
42
|
+
private getFetchUrl;
|
|
43
|
+
private isResponsesUrl;
|
|
44
|
+
private dumpRawRequest;
|
|
45
|
+
private getResponsesUrl;
|
|
46
|
+
getLangChainAgentSpec(params: {
|
|
47
|
+
maxTokens: number;
|
|
48
|
+
purpose: AgentModelPurpose;
|
|
49
|
+
}): {
|
|
50
|
+
model: ChatOpenAI<import("@langchain/openai").ChatOpenAICallOptions>;
|
|
51
|
+
middleware: import("langchain").AgentMiddleware<undefined, undefined, unknown, readonly (import("@langchain/core/tools").ClientTool | import("@langchain/core/tools").ServerTool)[]>[];
|
|
52
|
+
};
|
|
53
|
+
complete: (requestOrContent: CompletionRequestInput | string, maxTokens?: number, outputSchema?: any, reasoningEffort?: ReasoningEffort, toolsOrOnChunk?: CompletionTool[] | StreamChunkCallback, onChunk?: StreamChunkCallback) => Promise<CompletionResult>;
|
|
54
|
+
}
|