Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into judge
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 20, 2024
2 parents 6cce2d1 + fab38b7 commit 9dcfc67
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/anthropic.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: anthropic tests
on:
workflow_dispatch:
release:
types:
- published
pull_request:
paths:
- yarn.lock
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: azure openai tests
on:
workflow_dispatch:
release:
types:
- published
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 }}
5 changes: 4 additions & 1 deletion .github/workflows/google.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: google tests
on:
workflow_dispatch:
release:
types:
- published
pull_request:
paths:
- yarn.lock
- ".github/workflows/anthropic.yml"
- ".github/workflows/google.yml"
- "packages/core/**/*"
- "packages/cli/**/*"
- "packages/samples/**/*"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ollama.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: ollama smoke tests
on:
workflow_dispatch:
release:
types:
- published
pull_request:
paths:
- yarn.lock
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "docs",
"type": "module",
"private": true,
"version": "1.86.2",
"version": "1.86.4",
"license": "MIT",
"scripts": {
"install:force": "rm yarn.lock && yarn install",
Expand Down
6 changes: 3 additions & 3 deletions docs/src/content/docs/getting-started/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a id="azure_serverless" href=""></a>

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.

Expand All @@ -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:"
Expand Down Expand Up @@ -593,7 +593,7 @@ AZURE_SERVERLESS_OPENAI_API_KEY=...

### Azure AI Models <a href="" id="azure_serverless_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" })
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genaiscript-workspace",
"version": "1.86.2",
"version": "1.86.4",
"license": "MIT",
"private": true,
"workspaces": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genaiscript",
"version": "1.86.2",
"version": "1.86.4",
"main": "built/genaiscript.cjs",
"type": "commonjs",
"bin": {
Expand Down
20 changes: 8 additions & 12 deletions packages/cli/src/azuretoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -108,44 +108,40 @@ class AzureTokenResolverImpl implements AzureTokenResolver {
return this._error
}

clear() {
this._token = undefined
this._error = undefined
this._resolver = undefined
}

async token(
credentialsType: AzureCredentialsType,
options?: CancellationOptions
): Promise<{ token?: AuthenticationToken; error?: SerializedError }> {
// 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
}
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/src/nodehost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ export class NodeHost implements RuntimeHost {
}

async readConfig(): Promise<HostConfiguration> {
this.azureToken.clear()
this.azureServerlessToken.clear()

const config = await resolveGlobalConfiguration(this.dotEnvPath)
const { envFile, modelAliases } = config
if (modelAliases)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genaiscript-core-internal",
"version": "1.86.2",
"version": "1.86.4",
"main": "src/index.ts",
"license": "MIT",
"private": true,
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export function isAzureTokenExpired(token: AuthenticationToken) {
}

export interface AzureTokenResolver {
clear(): void
token(
credentialsType: AzureCredentialsType,
options?: CancellationOptions
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 7 additions & 1 deletion packages/sample/genaisrc/pr-describe.genai.mjs
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/sample/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genaiscript-sample",
"version": "1.86.2",
"version": "1.86.4",
"license": "MIT",
"private": true,
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"displayName": "GenAIScript Insiders",
"description": "Generative AI Scripting.",
"version": "1.86.2",
"version": "1.86.4",
"icon": "icon.png",
"engines": {
"vscode": "^1.95.0"
Expand Down
2 changes: 1 addition & 1 deletion slides/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "genaiscript-slides",
"version": "1.86.2",
"version": "1.86.4",
"type": "module",
"private": true,
"npm": {
Expand Down

0 comments on commit 9dcfc67

Please sign in to comment.