From e9230569f940ff973c8ff351f00f71f704327974 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Thu, 19 Dec 2024 18:25:47 +0100 Subject: [PATCH 1/8] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20improve=20?= =?UTF-8?q?token=20logging=20and=20config=20handling=20adjustments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/azuretoken.ts | 2 +- packages/cli/src/nodehost.ts | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/cli/src/azuretoken.ts b/packages/cli/src/azuretoken.ts index 78013ba65..17e573342 100644 --- a/packages/cli/src/azuretoken.ts +++ b/packages/cli/src/azuretoken.ts @@ -87,7 +87,7 @@ export async function createAzureToken( // Log the expiration time of the token logVerbose( - `azure: ${credentialsType || ""} token (${scopes.join(",")}) expires at ${new Date(res.expiresOnTimestamp).toLocaleString()}` + `azure: ${credentialsType || ""} token (${scopes.join(",")}) expires on ${new Date(res.expiresOnTimestamp).toUTCString()}` ) return res diff --git a/packages/cli/src/nodehost.ts b/packages/cli/src/nodehost.ts index 427e72550..b09c736e7 100644 --- a/packages/cli/src/nodehost.ts +++ b/packages/cli/src/nodehost.ts @@ -196,9 +196,6 @@ export class NodeHost implements RuntimeHost { } async readConfig(): Promise { - this.azureToken.clear() - this.azureServerlessToken.clear() - const config = await resolveGlobalConfiguration(this.dotEnvPath) const { envFile, modelAliases } = config if (modelAliases) From d0f167c572e7ab18db0d80b7b5da9135fc18b241 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Thu, 19 Dec 2024 18:27:58 +0100 Subject: [PATCH 2/8] Release 1.86.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f563bd11d..edf0e7ead 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript-workspace", - "version": "1.86.2", + "version": "1.86.3", "license": "MIT", "private": true, "workspaces": { From 62fd2bdda4f111064a77f7cfb24c9fae316077df Mon Sep 17 00:00:00 2001 From: pelikhan Date: Thu, 19 Dec 2024 18:28:48 +0100 Subject: [PATCH 3/8] v1.86.3 --- docs/package.json | 2 +- packages/cli/package.json | 2 +- packages/core/package.json | 2 +- packages/sample/package.json | 2 +- packages/vscode/package.json | 2 +- slides/package.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/package.json b/docs/package.json index 2935051cf..ab3b09a93 100644 --- a/docs/package.json +++ b/docs/package.json @@ -2,7 +2,7 @@ "name": "docs", "type": "module", "private": true, - "version": "1.86.2", + "version": "1.86.3", "license": "MIT", "scripts": { "install:force": "rm yarn.lock && yarn install", diff --git a/packages/cli/package.json b/packages/cli/package.json index a060fe5b3..7181c7965 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript", - "version": "1.86.2", + "version": "1.86.3", "main": "built/genaiscript.cjs", "type": "commonjs", "bin": { diff --git a/packages/core/package.json b/packages/core/package.json index 297fa25ae..fe9927ea7 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript-core-internal", - "version": "1.86.2", + "version": "1.86.3", "main": "src/index.ts", "license": "MIT", "private": true, diff --git a/packages/sample/package.json b/packages/sample/package.json index 2129c198c..571b8bac2 100644 --- a/packages/sample/package.json +++ b/packages/sample/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript-sample", - "version": "1.86.2", + "version": "1.86.3", "license": "MIT", "private": true, "scripts": { diff --git a/packages/vscode/package.json b/packages/vscode/package.json index 5f4e9f407..a5711f0a0 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -7,7 +7,7 @@ }, "displayName": "GenAIScript Insiders", "description": "Generative AI Scripting.", - "version": "1.86.2", + "version": "1.86.3", "icon": "icon.png", "engines": { "vscode": "^1.95.0" diff --git a/slides/package.json b/slides/package.json index bc388a799..dd6107265 100644 --- a/slides/package.json +++ b/slides/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript-slides", - "version": "1.86.2", + "version": "1.86.3", "type": "module", "private": true, "npm": { From 9b1bc3067fabb9d264bd6ad93b756f13a216e63a Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 01:35:10 +0000 Subject: [PATCH 4/8] fixed azure connection issue --- .github/workflows/anthropic.yml | 3 ++ .github/workflows/azure.yml | 38 +++++++++++++++++++ .github/workflows/google.yml | 5 ++- .github/workflows/ollama.yml | 3 ++ .../docs/getting-started/configuration.mdx | 6 +-- packages/cli/src/azuretoken.ts | 18 ++++----- packages/core/src/host.ts | 1 - packages/core/src/openai.ts | 3 +- 8 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/azure.yml diff --git a/.github/workflows/anthropic.yml b/.github/workflows/anthropic.yml index c3abd8369..4e19f8ec7 100644 --- a/.github/workflows/anthropic.yml +++ b/.github/workflows/anthropic.yml @@ -1,6 +1,9 @@ name: anthropic tests on: workflow_dispatch: + release: + types: + - created pull_request: paths: - yarn.lock diff --git a/.github/workflows/azure.yml b/.github/workflows/azure.yml new file mode 100644 index 000000000..3336ac92a --- /dev/null +++ b/.github/workflows/azure.yml @@ -0,0 +1,38 @@ +name: azure openai tests +on: + workflow_dispatch: + release: + types: + - created + pull_request: + paths: + - yarn.lock + - ".github/workflows/azure.yml" + - "packages/core/**/*" + - "packages/cli/**/*" + - "packages/samples/**/*" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-azure + cancel-in-progress: true +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: "20" + cache: yarn + - run: yarn install --frozen-lockfile + - name: typecheck + run: yarn typecheck + - name: compile + run: yarn compile + - name: poem + run: yarn run:script poem --model azure:gpt-4o -tlp 5 --out-trace $GITHUB_STEP_SUMMARY + env: + AZURE_OPENAI_API_ENDPOINT: ${{ secrets.AZURE_OPENAI_API_ENDPOINT }} + AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }} diff --git a/.github/workflows/google.yml b/.github/workflows/google.yml index 93f7b9e2c..0c3633159 100644 --- a/.github/workflows/google.yml +++ b/.github/workflows/google.yml @@ -1,10 +1,13 @@ name: google tests on: workflow_dispatch: + release: + types: + - created pull_request: paths: - yarn.lock - - ".github/workflows/anthropic.yml" + - ".github/workflows/google.yml" - "packages/core/**/*" - "packages/cli/**/*" - "packages/samples/**/*" diff --git a/.github/workflows/ollama.yml b/.github/workflows/ollama.yml index 08d7e24ac..6dee0a21c 100644 --- a/.github/workflows/ollama.yml +++ b/.github/workflows/ollama.yml @@ -1,6 +1,9 @@ name: ollama smoke tests on: workflow_dispatch: + release: + types: + - created pull_request: paths: - yarn.lock diff --git a/docs/src/content/docs/getting-started/configuration.mdx b/docs/src/content/docs/getting-started/configuration.mdx index b85325e6e..1123382b1 100644 --- a/docs/src/content/docs/getting-started/configuration.mdx +++ b/docs/src/content/docs/getting-started/configuration.mdx @@ -481,7 +481,7 @@ The rest of the steps are the same: Find the deployment name and use it in your ## Azure AI Serverless Deployments -You can deploy "serverless" models through [Azure AI Studio](https://ai.azure.com/) and pay as you go per token. +You can deploy "serverless" models through [Azure AI Foundry](https://ai.azure.com/) and pay as you go per token. You can browse the [Azure AI model catalog](https://ai.azure.com/explore/models) and use the [serverless API](https://learn.microsoft.com/en-us/azure/ai-studio/how-to/deploy-models-serverless-availability) filter to see the available models. @@ -493,7 +493,7 @@ They are configured slightly differently. ### Azure AI OpenAI -The `azure_serverless` provider supports OpenAI models deployed through the Azure AI Studio serverless deployments. +The `azure_serverless` provider supports OpenAI models deployed through the Azure AI Foundry serverless deployments. It supports both Entra ID and key-based authentication. ```js "azure_serverless:" @@ -593,7 +593,7 @@ AZURE_SERVERLESS_OPENAI_API_KEY=... ### Azure AI Models -The `azure_serverless_models` provider supports non-OpenAI models deployed through the Azure AI Studio serverless deployments. +The `azure_serverless_models` provider supports non-OpenAI models deployed through the Azure AI Foundary serverless deployments. ```js "azure_serverless_models:" script({ model: "azure_serverless_models:deployment-id" }) diff --git a/packages/cli/src/azuretoken.ts b/packages/cli/src/azuretoken.ts index 17e573342..2395a93e3 100644 --- a/packages/cli/src/azuretoken.ts +++ b/packages/cli/src/azuretoken.ts @@ -108,12 +108,6 @@ class AzureTokenResolverImpl implements AzureTokenResolver { return this._error } - clear() { - this._token = undefined - this._error = undefined - this._resolver = undefined - } - async token( credentialsType: AzureCredentialsType, options?: CancellationOptions @@ -121,31 +115,33 @@ class AzureTokenResolverImpl implements AzureTokenResolver { // cached const { cancellationToken } = options || {} - if (isAzureTokenExpired(this._token)) this._token = undefined + if (isAzureTokenExpired(this._token)) { + logVerbose(`azure: ${this.name} token expired`) + this._token = undefined + this._error = undefined + } if (this._token || this._error) return { token: this._token, error: this._error } if (!this._resolver) { const scope = await runtimeHost.readSecret(this.envName) const scopes = scope ? scope.split(",") : this.scopes - const resolver = (this._resolver = createAzureToken( + this._resolver = createAzureToken( scopes, credentialsType, cancellationToken ) .then((res) => { - if (this._resolver !== resolver) return undefined this._token = res this._error = undefined this._resolver = undefined return { token: this._token, error: this._error } }) .catch((err) => { - if (this._resolver !== resolver) return undefined this._resolver = undefined this._token = undefined this._error = serializeError(err) return { token: this._token, error: this._error } - })) + }) } return this._resolver } diff --git a/packages/core/src/host.ts b/packages/core/src/host.ts index 58064117c..023f6c159 100644 --- a/packages/core/src/host.ts +++ b/packages/core/src/host.ts @@ -103,7 +103,6 @@ export function isAzureTokenExpired(token: AuthenticationToken) { } export interface AzureTokenResolver { - clear(): void token( credentialsType: AzureCredentialsType, options?: CancellationOptions diff --git a/packages/core/src/openai.ts b/packages/core/src/openai.ts index a1a720b62..16592161f 100644 --- a/packages/core/src/openai.ts +++ b/packages/core/src/openai.ts @@ -44,8 +44,7 @@ import { INITryParse } from "./ini" import { serializeChunkChoiceToLogProbs } from "./logprob" export function getConfigHeaders(cfg: LanguageModelConfiguration) { - const { provider } = parseModelIdentifier(cfg.model) - let { token, type, base } = cfg + let { token, type, base, provider } = cfg if (type === "azure_serverless_models") { const keys = INITryParse(token) if (keys && Object.keys(keys).length > 1) token = keys[cfg.model] From 396ac36abf4f64650df148e26639da8ad08a56c4 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 01:47:10 +0000 Subject: [PATCH 5/8] Release 1.86.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index edf0e7ead..324e29727 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript-workspace", - "version": "1.86.3", + "version": "1.86.4", "license": "MIT", "private": true, "workspaces": { From 9770a01707579364f1f1ffaf693d289f1e1d7f46 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 01:47:31 +0000 Subject: [PATCH 6/8] [skip ci] updated version numbers --- docs/package.json | 2 +- packages/cli/package.json | 2 +- packages/core/package.json | 2 +- packages/sample/package.json | 2 +- packages/vscode/package.json | 2 +- slides/package.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/package.json b/docs/package.json index ab3b09a93..c759f09fb 100644 --- a/docs/package.json +++ b/docs/package.json @@ -2,7 +2,7 @@ "name": "docs", "type": "module", "private": true, - "version": "1.86.3", + "version": "1.86.4", "license": "MIT", "scripts": { "install:force": "rm yarn.lock && yarn install", diff --git a/packages/cli/package.json b/packages/cli/package.json index 7181c7965..7235185f2 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript", - "version": "1.86.3", + "version": "1.86.4", "main": "built/genaiscript.cjs", "type": "commonjs", "bin": { diff --git a/packages/core/package.json b/packages/core/package.json index fe9927ea7..c1a87a4f4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript-core-internal", - "version": "1.86.3", + "version": "1.86.4", "main": "src/index.ts", "license": "MIT", "private": true, diff --git a/packages/sample/package.json b/packages/sample/package.json index 571b8bac2..12b79dd03 100644 --- a/packages/sample/package.json +++ b/packages/sample/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript-sample", - "version": "1.86.3", + "version": "1.86.4", "license": "MIT", "private": true, "scripts": { diff --git a/packages/vscode/package.json b/packages/vscode/package.json index a5711f0a0..2ad8c3707 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -7,7 +7,7 @@ }, "displayName": "GenAIScript Insiders", "description": "Generative AI Scripting.", - "version": "1.86.3", + "version": "1.86.4", "icon": "icon.png", "engines": { "vscode": "^1.95.0" diff --git a/slides/package.json b/slides/package.json index dd6107265..7d33aefe4 100644 --- a/slides/package.json +++ b/slides/package.json @@ -1,6 +1,6 @@ { "name": "genaiscript-slides", - "version": "1.86.3", + "version": "1.86.4", "type": "module", "private": true, "npm": { From a8aaac8e67b5e30069db09ef7b0b8a3a8be65c8e Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 01:53:24 +0000 Subject: [PATCH 7/8] run on release published --- .github/workflows/anthropic.yml | 2 +- .github/workflows/azure.yml | 2 +- .github/workflows/google.yml | 2 +- .github/workflows/ollama.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/anthropic.yml b/.github/workflows/anthropic.yml index 4e19f8ec7..ccd972dfa 100644 --- a/.github/workflows/anthropic.yml +++ b/.github/workflows/anthropic.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: release: types: - - created + - published pull_request: paths: - yarn.lock diff --git a/.github/workflows/azure.yml b/.github/workflows/azure.yml index 3336ac92a..ce4f02e3b 100644 --- a/.github/workflows/azure.yml +++ b/.github/workflows/azure.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: release: types: - - created + - published pull_request: paths: - yarn.lock diff --git a/.github/workflows/google.yml b/.github/workflows/google.yml index 0c3633159..6f61fd4a7 100644 --- a/.github/workflows/google.yml +++ b/.github/workflows/google.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: release: types: - - created + - published pull_request: paths: - yarn.lock diff --git a/.github/workflows/ollama.yml b/.github/workflows/ollama.yml index 6dee0a21c..bb7587634 100644 --- a/.github/workflows/ollama.yml +++ b/.github/workflows/ollama.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: release: types: - - created + - published pull_request: paths: - yarn.lock From fab38b73dd105624662f4c854e7168b083e59ecf Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 20 Dec 2024 01:54:32 +0000 Subject: [PATCH 8/8] =?UTF-8?q?feat:=20=E2=99=BB=EF=B8=8F=20add=20new=20sy?= =?UTF-8?q?stem=20commands=20to=20pr-describe=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/sample/genaisrc/pr-describe.genai.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/sample/genaisrc/pr-describe.genai.mjs b/packages/sample/genaisrc/pr-describe.genai.mjs index 85f551cb1..5fffb1bd4 100644 --- a/packages/sample/genaisrc/pr-describe.genai.mjs +++ b/packages/sample/genaisrc/pr-describe.genai.mjs @@ -1,7 +1,13 @@ script({ temperature: 1, title: "pr-describe", - system: ["system", "system.fs_find_files", "system.fs_read_file"], + system: [ + "system", + "system.output_markdown", + "system.assistant", + "system.fs_find_files", + "system.fs_read_file", + ], parameters: { defaultBranch: { type: "string",