Skip to content

Commit

Permalink
support node --experimental-strip-types main_node.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
zuisong committed Sep 14, 2024
1 parent edd8ebb commit dc27b86
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
5 changes: 5 additions & 0 deletions dist/main_bun.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ var GoogleGenerativeAIError = class extends Error {
}
};
var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError {
response;
constructor(message, response) {
super(message);
this.response = response;
Expand Down Expand Up @@ -377,6 +378,10 @@ async function makeRequest(url, body, requestOptions) {
return response;
}
var RequestUrl = class {
model;
task;
stream;
apiParam;
constructor(model, task, stream, apiParam) {
this.model = model;
this.task = task;
Expand Down
5 changes: 5 additions & 0 deletions dist/main_cloudflare-workers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ var GoogleGenerativeAIError = class extends Error {
}
};
var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError {
response;
constructor(message, response) {
super(message);
this.response = response;
Expand Down Expand Up @@ -377,6 +378,10 @@ async function makeRequest(url, body, requestOptions) {
return response;
}
var RequestUrl = class {
model;
task;
stream;
apiParam;
constructor(model, task, stream, apiParam) {
this.model = model;
this.task = task;
Expand Down
5 changes: 5 additions & 0 deletions dist/main_deno.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ var GoogleGenerativeAIError = class extends Error {
}
};
var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError {
response;
constructor(message, response) {
super(message);
this.response = response;
Expand Down Expand Up @@ -377,6 +378,10 @@ async function makeRequest(url, body, requestOptions) {
return response;
}
var RequestUrl = class {
model;
task;
stream;
apiParam;
constructor(model, task, stream, apiParam) {
this.model = model;
this.task = task;
Expand Down
5 changes: 5 additions & 0 deletions dist/main_node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ var GoogleGenerativeAIError = class extends Error {
}
};
var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError {
response;
constructor(message, response) {
super(message);
this.response = response;
Expand Down Expand Up @@ -817,6 +818,10 @@ async function makeRequest(url, body, requestOptions) {
return response;
}
var RequestUrl = class {
model;
task;
stream;
apiParam;
constructor(model, task, stream, apiParam) {
this.model = model;
this.task = task;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"devDependencies": {
"esbuild": "0.23.1",
"@total-typescript/ts-reset": "^0.6.0"
"@total-typescript/ts-reset": "^0.6.1"
},
"engines": {
"node": ">=18.0.0",
Expand Down
7 changes: 3 additions & 4 deletions src/gemini-api-client/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ export class GoogleGenerativeAIError extends Error {
}

export class GoogleGenerativeAIResponseError<T> extends GoogleGenerativeAIError {
constructor(
message: string,
public response?: T,
) {
public response?: T
constructor(message: string, response?: T) {
super(message)
this.response = response
}
}
16 changes: 10 additions & 6 deletions src/gemini-api-client/gemini-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ async function makeRequest(url: RequestUrl, body: string, requestOptions?: Reque
}

export class RequestUrl {
constructor(
public model: GeminiModel,
public task: keyof Task,
public stream: boolean,
public apiParam: ApiParam,
) {}
public model: GeminiModel
public task: keyof Task
public stream: boolean
public apiParam: ApiParam
constructor(model: GeminiModel, task: keyof Task, stream: boolean, apiParam: ApiParam) {
this.model = model
this.task = task
this.stream = stream
this.apiParam = apiParam
}
toURL(): URL {
const api_version: API_VERSION = "v1beta"
const url = new URL(`${BASE_URL}/${api_version}/models/${this.model}:${this.task}`)
Expand Down

0 comments on commit dc27b86

Please sign in to comment.