Skip to content

Commit

Permalink
add changeset, simplify header merging.
Browse files Browse the repository at this point in the history
  • Loading branch information
shaper committed Nov 30, 2024
1 parent 58bd1a2 commit 2f30d44
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .changeset/stupid-trees-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@ai-sdk/google-vertex': patch
'@ai-sdk/google': patch
---

feat (provider/google-vertex): Add support for edge runtime.
2 changes: 1 addition & 1 deletion packages/google-vertex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
}
},
"dependencies": {
"@ai-sdk/google": "1.0.4",
"@ai-sdk/provider": "1.0.1",
"@ai-sdk/provider-utils": "2.0.2"
},
Expand All @@ -41,7 +42,6 @@
"zod": "3.23.8"
},
"peerDependencies": {
"@ai-sdk/google": "1.0.4",
"google-auth-library": "^9.15.0",
"zod": "^3.0.0"
},
Expand Down
1 change: 1 addition & 0 deletions packages/google/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"./internal": {
"types": "./internal/dist/index.d.ts",
"import": "./internal/dist/index.mjs",
"module": "./internal/dist/index.mjs",
"require": "./internal/dist/index.js"
}
},
Expand Down
8 changes: 5 additions & 3 deletions packages/google/src/google-generative-ai-embedding-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ export class GoogleGenerativeAIEmbeddingModel
}

const asyncHeaders = this.config.experimental_getHeadersAsync?.();
const mergedHeaders = asyncHeaders
? combineHeaders(this.config.headers(), await asyncHeaders, headers)
: combineHeaders(this.config.headers(), headers);
const mergedHeaders = combineHeaders(
this.config.headers(),
asyncHeaders ? await asyncHeaders : {},
headers,
);

const { responseHeaders, value: response } = await postJsonToApi({
url: `${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,
Expand Down
24 changes: 10 additions & 14 deletions packages/google/src/google-generative-ai-language-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,11 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV1 {
const body = JSON.stringify(args);

const asyncHeaders = this.config.experimental_getHeadersAsync?.();
const mergedHeaders = asyncHeaders
? combineHeaders(
this.config.headers(),
await asyncHeaders,
options.headers,
)
: combineHeaders(this.config.headers(), options.headers);
const mergedHeaders = combineHeaders(
this.config.headers(),
asyncHeaders ? await asyncHeaders : {},
options.headers,
);

const { responseHeaders, value: response } = await postJsonToApi({
url: `${this.config.baseURL}/${getModelPath(
Expand Down Expand Up @@ -258,13 +256,11 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV1 {
const body = JSON.stringify(args);

const asyncHeaders = this.config.experimental_getHeadersAsync?.();
const headers = asyncHeaders
? combineHeaders(
this.config.headers(),
await asyncHeaders,
options.headers,
)
: combineHeaders(this.config.headers(), options.headers);
const headers = combineHeaders(
this.config.headers(),
asyncHeaders ? await asyncHeaders : {},
options.headers,
);

const { responseHeaders, value: response } = await postJsonToApi({
url: `${this.config.baseURL}/${getModelPath(
Expand Down

0 comments on commit 2f30d44

Please sign in to comment.