Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jan 22, 2025
2 parents 4700c27 + 920d3d7 commit a65de44
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 154 deletions.
19 changes: 10 additions & 9 deletions THIRD_PARTY_LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ The following npm packages may be included in this product:

- @aws-crypto/[email protected]
- @aws-crypto/[email protected]
- @huggingface/[email protected].1
- @huggingface/[email protected].2
- [email protected]
- [email protected]

Expand Down Expand Up @@ -2862,7 +2862,7 @@ MIT License

The following npm package may be included in this product:

- genaiscript-vscode@1.93.0
- genaiscript-vscode@1.94.0

This package contains the following license:

Expand Down Expand Up @@ -4183,7 +4183,7 @@ The following npm packages may be included in this product:
- @aws-sdk/[email protected]
- @aws-sdk/[email protected]
- @aws-sdk/[email protected]
- @aws-sdk/credential-providers@3.731.1
- @aws-sdk/credential-providers@3.733.0
- @aws-sdk/[email protected]
- @aws-sdk/[email protected]
- @aws-sdk/[email protected]
Expand Down Expand Up @@ -6920,6 +6920,7 @@ The following npm packages may be included in this product:

- @anthropic-ai/[email protected]
- @anthropic-ai/[email protected]
- @anthropic-ai/[email protected]

These packages each contain the following license:

Expand Down Expand Up @@ -7982,10 +7983,10 @@ The following npm packages may be included in this product:
- @tokenizer/[email protected]
- [email protected]
- [email protected]
- genaiscript-core-internal@1.93.0
- genaiscript-sample@1.93.0
- genaiscript-web@1.93.0
- genaiscript@1.93.0
- genaiscript-core-internal@1.94.0
- genaiscript-sample@1.94.0
- genaiscript-web@1.94.0
- genaiscript@1.94.0
- [email protected]
- [email protected]
- [email protected]
Expand Down Expand Up @@ -9066,7 +9067,7 @@ SOFTWARE.

The following npm package may be included in this product:

- @modelcontextprotocol/[email protected].0
- @modelcontextprotocol/[email protected].2

This package contains the following license:

Expand Down Expand Up @@ -9157,7 +9158,7 @@ SOFTWARE.

The following npm packages may be included in this product:

- get-tsconfig@4.9.0
- get-tsconfig@4.10.0
- [email protected]

These packages each contain the following license:
Expand Down
67 changes: 54 additions & 13 deletions docs/src/content/docs/getting-started/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ while the Azure AI models, like `Meta-Llama-3.1-405B-Instruct` are deployed to `

They are configured slightly differently.

### Azure AI OpenAI
### Azure AI OpenAI Serverless

The `azure_serverless` provider supports OpenAI models deployed through the Azure AI Foundry serverless deployments.
It supports both Entra ID and key-based authentication.
Expand All @@ -518,21 +518,17 @@ It supports both Entra ID and key-based authentication.
script({ model: "azure_serverless:deployment-id" })
```

#### Managed Identity (Entra ID)
:::note

<Steps>
This kind of deployment is different from the **Azure OpenAI** deployments (`azure` provider).

<ol>

<li>
:::

Open a terminal and **login** with [Azure CLI](https://learn.microsoft.com/en-us/javascript/api/overview/azure/identity-readme?view=azure-node-latest#authenticate-via-the-azure-cli).
#### Managed Identity (Entra ID)

```sh
az login
```
<Steps>

</li>
<ol>

<li>

Expand All @@ -549,7 +545,8 @@ You can use the `Deployment Options` -> `Serverless API` option to deploy a mode

<li>

Deploy an OpenAI base model. This will also create a new Azure OpenAI resource in your subscription.
Deploy an OpenAI base model.
This will also create a new Azure OpenAI resource in your subscription (which may be invisible to you, more later).

</li>

Expand All @@ -565,9 +562,18 @@ AZURE_SERVERLESS_OPENAI_API_ENDPOINT=https://....openai.azure.com

<li>

Open your **Azure OpenAI** resource that was created by Azure AI in the [Azure Portal](https://portal.azure.com)
Go back to the **Overview** tab in your Azure AI Foundry project and
click on **Open in Management center**.

</li>

<li>

Click on the **Azure OpenAI Service** resource, then click on the **Resource** external link which will take you back to the (underlying) Azure OpenAI service
in Azure Portal.

</li>

<li>

Navigate to **Access Control (IAM)**, then **View My Access**. Make sure your
Expand All @@ -580,6 +586,41 @@ If you get a `401` error, click on **Add**, **Add role assignment** and add the

</Steps>

At this point, you are ready to login with the Azure CLI and use the managed identity.

:::note

The resources created by Azure AI Foundry are not visible by default in the Azure Portal.
To make them visible, open [All resources](https://portal.azure.com/#browse/all), click **Manage view**
and select **Show hidden types**.


:::

<Steps>

<ol>

<li>

Install the [Azure CLI](https://learn.microsoft.com/en-us/javascript/api/overview/azure/identity-readme?view=azure-node-latest#authenticate-via-the-azure-cli).

</li>

<li>

Open a terminal and login

```sh
az login
```

</li>

</ol>

</Steps>

#### API Key

<Steps>
Expand Down
59 changes: 30 additions & 29 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@
yaml "^2.5.0"

"@atproto/api@^0.13.14":
version "0.13.29"
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.29.tgz#34b8e8f68df95f9d44de243ff33dc92b6b421e71"
integrity sha512-j+2mZikK7dibAll4TrQBVFMUVlZ9UZKTlTuFMMJ/x/JrngdYSvPoCcujbPHSj3XuKuG+MCNps5e7wK4mXXQsSA==
version "0.13.30"
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.30.tgz#073165003303995d0b6b7dfc24dafb8a58a1db6f"
integrity sha512-U+3XUACcCuoEvszh48vnzZITr1D7xZ8yz3EqjadYtV+zb3KjBmGroa50eaSRqHyeaDUZF38knumHPyUe9tTuqg==
dependencies:
"@atproto/common-web" "^0.3.2"
"@atproto/lexicon" "^0.4.5"
Expand Down Expand Up @@ -1838,10 +1838,10 @@ cose-base@^2.2.0:
dependencies:
layout-base "^2.0.0"

crossws@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/crossws/-/crossws-0.3.1.tgz#7980e0b6688fe23286661c3ab8deeccbaa05ca86"
integrity sha512-HsZgeVYaG+b5zA+9PbIPGq4+J/CJynJuearykPsXx4V/eMhyQ5EDVg3Ak2FBZtVXCiOLu/U7IiwDHTr9MA+IKw==
crossws@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/crossws/-/crossws-0.3.2.tgz#dff68797e4e6b5c47f29c7827475854a7ba14492"
integrity sha512-S2PpQHRcgYABOS2465b34wqTOn5dbLL+iSvyweJYGGFLDsKq88xrjDXUiEhfYkhWZq1HuS6of3okRHILbkrqxw==
dependencies:
uncrypto "^0.1.3"

Expand Down Expand Up @@ -2590,12 +2590,12 @@ graphemer@^1.4.0:
integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==

h3@^1.13.0:
version "1.13.1"
resolved "https://registry.yarnpkg.com/h3/-/h3-1.13.1.tgz#915966340b0b0ebeca1acc39bd2ecae08ae331f6"
integrity sha512-u/z6Z4YY+ANZ05cRRfsFJadTBrNA6e3jxdU+AN5UCbZSZEUwgHiwjvUEe0k1NoQmAvQmETwr+xB5jd7mhCJuIQ==
version "1.14.0"
resolved "https://registry.yarnpkg.com/h3/-/h3-1.14.0.tgz#292bf0602444b36fd6b333b1d6872d685ecc9899"
integrity sha512-ao22eiONdgelqcnknw0iD645qW0s9NnrJHr5OBz4WOMdBdycfSas1EQf1wXRsm+PcB2Yoj43pjBPwqIpJQTeWg==
dependencies:
cookie-es "^1.2.2"
crossws "^0.3.1"
crossws "^0.3.2"
defu "^6.1.4"
destr "^2.0.3"
iron-webcrypto "^1.2.1"
Expand Down Expand Up @@ -3241,12 +3241,13 @@ mdast-util-definitions@^6.0.0:
unist-util-visit "^5.0.0"

mdast-util-directive@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/mdast-util-directive/-/mdast-util-directive-3.0.0.tgz#3fb1764e705bbdf0afb0d3f889e4404c3e82561f"
integrity sha512-JUpYOqKI4mM3sZcNxmF/ox04XYFFkNwr0CFlrQIkCwbvH0xzMCqkMqAde9wRd80VAhaUrwFwKm2nxretdT1h7Q==
version "3.1.0"
resolved "https://registry.yarnpkg.com/mdast-util-directive/-/mdast-util-directive-3.1.0.tgz#f3656f4aab6ae3767d3c72cfab5e8055572ccba1"
integrity sha512-I3fNFt+DHmpWCYAT7quoM6lHf9wuqtI+oCOfvILnoicNIqjh5E3dEJWiXuYME2gNe8vl1iMQwyUHa7bgFmak6Q==
dependencies:
"@types/mdast" "^4.0.0"
"@types/unist" "^3.0.0"
ccount "^2.0.0"
devlop "^1.0.0"
mdast-util-from-markdown "^2.0.0"
mdast-util-to-markdown "^2.0.0"
Expand Down Expand Up @@ -3824,9 +3825,9 @@ micromark-util-sanitize-uri@^2.0.0:
micromark-util-symbol "^2.0.0"

micromark-util-subtokenize@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.3.tgz#70ffb99a454bd8c913c8b709c3dc97baefb65f96"
integrity sha512-VXJJuNxYWSoYL6AJ6OQECCFGhIU2GGHMw8tahogePBrjkG8aCCas3ibkp7RnVOSTClg2is05/R7maAhF1XyQMg==
version "2.0.4"
resolved "https://registry.yarnpkg.com/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.4.tgz#50d8ca981373c717f497dc64a0dbfccce6c03ed2"
integrity sha512-N6hXjrin2GTJDe3MVjf5FuXpm12PGm80BrUAeub9XFXca8JZbP+oIwY4LJSVwFUCL1IPm/WwSVUN7goFHmSGGQ==
dependencies:
devlop "^1.0.0"
micromark-util-chunked "^2.0.0"
Expand Down Expand Up @@ -3963,9 +3964,9 @@ ohash@^1.1.4:
integrity sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==

oniguruma-to-es@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/oniguruma-to-es/-/oniguruma-to-es-2.2.0.tgz#7134ab4f05595cadc52fbc697af5c96788dca493"
integrity sha512-EEsso27ri0sf+t4uRFEj5C5gvXQj0d0w1Y2qq06b+hDLBnvzO1rWTwEW4C7ytan6nhg4WPwE26eLoiPhHUbvKg==
version "2.3.0"
resolved "https://registry.yarnpkg.com/oniguruma-to-es/-/oniguruma-to-es-2.3.0.tgz#35ea9104649b7c05f3963c6b3b474d964625028b"
integrity sha512-bwALDxriqfKGfUufKGGepCzu9x7nJQuoRoAFp4AnwehhC2crqrDIAP/uN2qdlsAvSMpeRC3+Yzhqc7hLmle5+g==
dependencies:
emoji-regex-xs "^1.0.0"
regex "^5.1.1"
Expand Down Expand Up @@ -3993,9 +3994,9 @@ p-locate@^4.1.0:
p-limit "^2.2.0"

p-queue@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-8.0.1.tgz#718b7f83836922ef213ddec263ff4223ce70bef8"
integrity sha512-NXzu9aQJTAzbBqOt2hwsR63ea7yvxJc0PwN/zobNAudYfb1B7R08SzB4TsLeSbUCuG467NhnoT0oO6w1qRO+BA==
version "8.1.0"
resolved "https://registry.yarnpkg.com/p-queue/-/p-queue-8.1.0.tgz#d71929249868b10b16f885d8a82beeaf35d32279"
integrity sha512-mxLDbbGIBEXTJL0zEx8JIylaj3xQ7Z/7eEVjcF9fJX4DBiH9oqe+oahYnlKKxm0Ci9TlWTyhSHgygxMxjIB2jw==
dependencies:
eventemitter3 "^5.0.1"
p-timeout "^6.1.2"
Expand Down Expand Up @@ -4352,9 +4353,9 @@ rehype@^13.0.1, rehype@^13.0.2:
unified "^11.0.0"

remark-directive@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/remark-directive/-/remark-directive-3.0.0.tgz#34452d951b37e6207d2e2a4f830dc33442923268"
integrity sha512-l1UyWJ6Eg1VPU7Hm/9tt0zKtReJQNOA4+iDMAxTyZNWnJnFlbS/7zhiel/rogTLQ2vMYwDzSJa4BiVNqGlqIMA==
version "3.0.1"
resolved "https://registry.yarnpkg.com/remark-directive/-/remark-directive-3.0.1.tgz#689ba332f156cfe1118e849164cc81f157a3ef0a"
integrity sha512-gwglrEQEZcZYgVyG1tQuA+h58EZfq5CSULw7J90AFuCTyib1thgHPoqQ+h9iFvU6R+vnZ5oNFQR5QKgGpk741A==
dependencies:
"@types/mdast" "^4.0.0"
mdast-util-directive "^3.0.0"
Expand Down Expand Up @@ -5008,9 +5009,9 @@ vfile@^6.0.0, vfile@^6.0.2, vfile@^6.0.3:
vfile-message "^4.0.0"

vite@^6.0.9:
version "6.0.10"
resolved "https://registry.yarnpkg.com/vite/-/vite-6.0.10.tgz#48685694c36d8c8f87b93f3fd0de089d3930b361"
integrity sha512-MEszunEcMo6pFsfXN1GhCFQqnE25tWRH0MA4f0Q7uanACi4y1Us+ZGpTMnITwCTnYzB2b9cpmnelTlxgTBmaBA==
version "6.0.11"
resolved "https://registry.yarnpkg.com/vite/-/vite-6.0.11.tgz#224497e93e940b34c3357c9ebf2ec20803091ed8"
integrity sha512-4VL9mQPKoHy4+FE0NnRE/kbY51TOfaknxAjt3fJbGJxhIpBZiqVzlZDEesWWsuREXHwNdAoOFZ9MkPEVXczHwg==
dependencies:
esbuild "^0.24.2"
postcss "^8.4.49"
Expand Down
9 changes: 0 additions & 9 deletions packages/core/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ export async function parseTokenFromEnv(
if (!URL.canParse(base))
throw new Error("AZURE_OPENAI_API_ENDPOINT must be a valid URL")
const version = env.AZURE_OPENAI_API_VERSION || env.AZURE_API_VERSION
if (version && version !== AZURE_OPENAI_API_VERSION)
throw new Error(
`AZURE_OPENAI_API_VERSION must be '${AZURE_OPENAI_API_VERSION}'`
)
const azureCredentialsType =
env.AZURE_OPENAI_API_CREDENTIALS?.toLowerCase().trim() as AzureCredentialsType
return {
Expand Down Expand Up @@ -243,11 +239,6 @@ export async function parseTokenFromEnv(
env.AZURE_SERVERLESS_OPENAI_VERSION
const azureCredentialsType =
env.AZURE_SERVERLESS_OPENAI_API_CREDENTIALS?.toLowerCase().trim() as AzureCredentialsType

if (version && version !== AZURE_OPENAI_API_VERSION)
throw new Error(
`AZURE_SERVERLESS_OPENAI_API_VERSION must be '${AZURE_OPENAI_API_VERSION}'`
)
return {
provider,
model,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/llms.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"logitBias": false,
"openaiCompatibility": "https://github.com/ollama/ollama/blob/main/docs/openai.md",
"prediction": false,
"bearerToken": true,
"aliases": {
"large": "phi4:latest",
"small": "llama3.2:3b",
Expand All @@ -181,6 +182,7 @@
"id": "lmstudio",
"detail": "LM Studio local server",
"prediction": false,
"bearerToken": true,
"aliases": {
"large": "phi-4",
"small": "llama-3.2-3b-instruct",
Expand Down
9 changes: 2 additions & 7 deletions packages/core/src/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,11 @@ export function getConfigHeaders(cfg: LanguageModelConfiguration) {
if (keys && Object.keys(keys).length > 1) token = keys[cfg.model]
}
const features = MODEL_PROVIDERS.find(({ id }) => id === provider)
const useBearer = features?.bearerToken === true
const useBearer = features?.bearerToken !== false
const isBearer = /^Bearer /i.test(cfg.token)
const Authorization = isBearer
? token
: token &&
(useBearer ||
type === "openai" ||
type === "localai" ||
type === "azure_serverless_models" ||
base === OPENROUTER_API_CHAT_URL)
: token && (useBearer || base === OPENROUTER_API_CHAT_URL)
? `Bearer ${token}`
: undefined
const apiKey = Authorization ? undefined : token
Expand Down
Loading

0 comments on commit a65de44

Please sign in to comment.