Skip to content

Commit

Permalink
wip 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
aeltorio committed Oct 4, 2024
1 parent 66412e7 commit f5b6db0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sctg/ai-sdk",
"version": "0.0.2",
"version": "0.0.3",
"description": "Unofficial TypeScript library for the Groq API",
"author": "Groq <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
16 changes: 8 additions & 8 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,6 @@ export abstract class APIClient {

const reqHeaders = this.buildHeaders({ options, headers, contentLength });

// If we're using a proxy, we need to set the final host in a header and rewrite the URL.
if (this.proxy) {
reqHeaders['X-Host-Final'] = new URL(this.baseURL).host;
let newBaseURL = new URL(this.baseURL);
newBaseURL.host = this.proxy;
this.baseURL = newBaseURL.toString();
}

const req: RequestInit = {
mode: this.disableCorsCheck ? 'no-cors' : 'cors',
method,
Expand Down Expand Up @@ -370,6 +362,10 @@ export abstract class APIClient {
reqHeaders['content-length'] = contentLength;
}

// If we're using a proxy, we need to set the final host in a header.
if (this.proxy) {
reqHeaders['X-Host-Final'] = new URL(this.baseURL).host;
}
const defaultHeaders = this.defaultHeaders(options);
applyHeadersMut(reqHeaders, defaultHeaders);
applyHeadersMut(reqHeaders, headers);
Expand Down Expand Up @@ -508,6 +504,10 @@ export abstract class APIClient {
url.search = this.stringifyQuery(query as Record<string, unknown>);
}

// If we're using ai-proxy we need to rewrite the URL to point to the proxy.
if (this.proxy) {
url.host = this.proxy;
}
return url.toString();
}

Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '0.0.1'; // x-release-please-version
export const VERSION = '0.0.3'; // x-release-please-version

0 comments on commit f5b6db0

Please sign in to comment.