Skip to content

Commit

Permalink
Merge pull request #7 from speakeasy-sdks/speakeasy-sdk-regen-1678275180
Browse files Browse the repository at this point in the history
chore: speakeasy sdk regeneration - Generate
  • Loading branch information
ndimares authored Mar 8, 2023
2 parents 7141648 + cca3bac commit ff37036
Show file tree
Hide file tree
Showing 51 changed files with 765 additions and 159 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ import {
} from "@speakeasy-api/openai/dist/sdk/models/operations";

import { AxiosError } from "axios";
import { Openai } from "@speakeasy-api/openai";
import { Gpt } from "@speakeasy-api/openai";


const sdk = new Openai();
const sdk = new Gpt();

const req: CancelFineTuneRequest = {
pathParams: {
Expand All @@ -75,6 +75,7 @@ sdk.openAI.cancelFineTune(req).then((res: CancelFineTuneResponse | AxiosError) =

The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions).

* `createChatCompletion` - Creates a completion for the chat message
* `createClassification` - Classifies the specified `query` using provided examples.

The endpoint first [searches](/docs/api-reference/searches) over the labeled examples
Expand All @@ -86,7 +87,7 @@ Labeled examples can be provided via an uploaded `file`, or explicitly listed in
request using the `examples` parameter for quick tests and small scale use cases.

* `createCompletion` - Creates a completion for the provided prompt and parameters
* `createEdit` - Creates a new edit for the provided input, instruction, and parameters
* `createEdit` - Creates a new edit for the provided input, instruction, and parameters.
* `createEmbedding` - Creates an embedding vector representing the input text.
* `createFile` - Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.

Expand All @@ -106,6 +107,8 @@ To go beyond the 200 document limit, documents can be processed offline and then

The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.

* `createTranscription` - Transcribes audio into the input language.
* `createTranslation` - Translates audio into into English.
* `deleteFile` - Delete a file.
* `deleteModel` - Delete a fine-tuned model. You must have the Owner role in your organization.
* `downloadFile` - Returns the contents of the specified file
Expand Down
10 changes: 9 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ Based on:
- OpenAPI Doc 1.1.0 https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml
- Speakeasy CLI 1.5.4 https://github.com/speakeasy-api/speakeasy
### Releases
- [NPM v1.2.1] https://www.npmjs.com/package/@speakeasy-api/openai/v/1.2.1 - .
- [NPM v1.2.1] https://www.npmjs.com/package/@speakeasy-api/openai/v/1.2.1 - .

## 2023-03-08 11:32:59
### Changes
Based on:
- OpenAPI Doc 1.2.0 https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml
- Speakeasy CLI 1.8.6 https://github.com/speakeasy-api/speakeasy
### Releases
- [NPM v1.3.0] https://www.npmjs.com/package/@speakeasy-api/openai/v/1.3.0 - .
4 changes: 2 additions & 2 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
} from "@speakeasy-api/openai/dist/sdk/models/operations";

import { AxiosError } from "axios";
import { Openai } from "@speakeasy-api/openai";
import { Gpt } from "@speakeasy-api/openai";


const sdk = new Openai();
const sdk = new Gpt();

const req: CancelFineTuneRequest = {
pathParams: {
Expand Down
11 changes: 11 additions & 0 deletions files.gen
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ src/sdk/index.ts
tsconfig.json
src/sdk/models/operations/cancelfinetune.ts
src/sdk/models/operations/createanswer.ts
src/sdk/models/operations/createchatcompletion.ts
src/sdk/models/operations/createclassification.ts
src/sdk/models/operations/createcompletion.ts
src/sdk/models/operations/createedit.ts
Expand All @@ -28,6 +29,8 @@ src/sdk/models/operations/createimageedit.ts
src/sdk/models/operations/createimagevariation.ts
src/sdk/models/operations/createmoderation.ts
src/sdk/models/operations/createsearch.ts
src/sdk/models/operations/createtranscription.ts
src/sdk/models/operations/createtranslation.ts
src/sdk/models/operations/deletefile.ts
src/sdk/models/operations/deletemodel.ts
src/sdk/models/operations/downloadfile.ts
Expand All @@ -43,6 +46,10 @@ src/sdk/models/operations/retrievemodel.ts
src/sdk/models/operations/index.ts
src/sdk/models/shared/createanswerresponse.ts
src/sdk/models/shared/createanswerrequest.ts
src/sdk/models/shared/createchatcompletionresponse.ts
src/sdk/models/shared/chatcompletionresponsemessage.ts
src/sdk/models/shared/createchatcompletionrequest.ts
src/sdk/models/shared/chatcompletionrequestmessage.ts
src/sdk/models/shared/createclassificationresponse.ts
src/sdk/models/shared/createclassificationrequest.ts
src/sdk/models/shared/createcompletionresponse.ts
Expand All @@ -60,6 +67,10 @@ src/sdk/models/shared/createmoderationresponse.ts
src/sdk/models/shared/createmoderationrequest.ts
src/sdk/models/shared/createsearchresponse.ts
src/sdk/models/shared/createsearchrequest.ts
src/sdk/models/shared/createtranscriptionresponse.ts
src/sdk/models/shared/createtranscriptionrequest.ts
src/sdk/models/shared/createtranslationresponse.ts
src/sdk/models/shared/createtranslationrequest.ts
src/sdk/models/shared/deletefileresponse.ts
src/sdk/models/shared/deletemodelresponse.ts
src/sdk/models/shared/listenginesresponse.ts
Expand Down
8 changes: 4 additions & 4 deletions gen.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
configVersion: 1.0.0
management:
docChecksum: 070eea1a67c4e5af9e7dbad61d95fd37
docVersion: 1.1.0
speakeasyVersion: 1.5.4
docChecksum: 5399f7767be93d4a4b8cecb9bbc687b3
docVersion: 1.2.0
speakeasyVersion: 1.8.6
generation:
telemetryEnabled: false
sdkClassName: gpt
sdkFlattening: true
typescript:
version: 1.2.1
version: 1.3.0
author: speakeasy-openai
packageName: '@speakeasy-api/openai'
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": "@speakeasy-api/openai",
"version": "1.2.1",
"version": "1.3.0",
"author": "speakeasy-openai",
"scripts": {
"prepare": "tsc --build"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/utils/requestbody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function serializeRequestBody(request: any): [object, any] {
case "text/json":
[requestHeaders, requestBody] = [
{ "Content-Type": `${requestDecorator.MediaType}` },
{ ...requestBodyObj[fname] },
requestBodyObj[fname],
];
break;

Expand Down
155 changes: 93 additions & 62 deletions src/internal/utils/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ function parseSecurityClass(
const securityDecorator: SecurityDecorator =
parseSecurityDecorator(securityAnn);
if (securityDecorator == null) return;

const value = security[fname];

if (securityDecorator.Option) {
return parseSecurityOption(client, security[fname]);
return parseSecurityOption(client, value);
} else if (securityDecorator.Scheme) {
return parseSecurityScheme(client, securityDecorator, security[fname]);
if (securityDecorator.SubType === "basic" && value !== Object(value)) {
return parseSecurityScheme(client, securityDecorator, security);
} else {
client = parseSecurityScheme(client, securityDecorator, value);
}
}
});

Expand All @@ -85,10 +92,8 @@ function parseSecurityOption(
if (securityAnn == null) return;
const securityDecorator: SecurityDecorator =
parseSecurityDecorator(securityAnn);
if (securityDecorator != null && securityDecorator.Scheme) return;
if (securityDecorator.Scheme) {
return parseSecurityScheme(client, securityDecorator, optionType[fname]);
}
if (securityDecorator == null || !securityDecorator.Scheme) return;
return parseSecurityScheme(client, securityDecorator, optionType[fname]);
});

return client;
Expand All @@ -99,65 +104,91 @@ function parseSecurityScheme(
schemeDecorator: SecurityDecorator,
scheme: any
): AxiosInstance {
if (schemeDecorator.Type === "http" && schemeDecorator.SubType === "basic") {
return parseBasicAuthScheme(client, scheme);
}
if (scheme === Object(scheme)) {
if (
schemeDecorator.Type === "http" &&
schemeDecorator.SubType === "basic"
) {
return parseBasicAuthScheme(client, scheme);
}

const fieldNames: string[] = Object.getOwnPropertyNames(scheme);
fieldNames.forEach((fname) => {
const securityAnn: string = Reflect.getMetadata(
securityMetadataKey,
scheme,
fname
const fieldNames: string[] = Object.getOwnPropertyNames(scheme);
fieldNames.forEach((fname) => {
const securityAnn: string = Reflect.getMetadata(
securityMetadataKey,
scheme,
fname
);
if (securityAnn == null) return;
const securityDecorator: SecurityDecorator =
parseSecurityDecorator(securityAnn);
if (securityDecorator == null || securityDecorator.Name === "") return;

client = parseSecuritySchemeValue(
client,
schemeDecorator,
securityDecorator,
scheme[fname]
);
});
} else {
client = parseSecuritySchemeValue(
client,
schemeDecorator,
schemeDecorator,
scheme
);
if (securityAnn == null) return;
const securityDecorator: SecurityDecorator =
parseSecurityDecorator(securityAnn);
if (securityDecorator == null || securityDecorator.Name === "") return;
}

switch (schemeDecorator.Type) {
case "apiKey":
switch (schemeDecorator.SubType) {
case "header":
client.defaults.headers.common[securityDecorator.Name] =
scheme[fname];
break;
case "query":
client.defaults.params[securityDecorator.Name] = scheme[fname];
break;
case "cookie":
const securityDecoratorName: string = securityDecorator.Name;
const val: string = scheme[fname];
client.defaults.headers.common[
"Cookie"
] = `${securityDecoratorName}=${val}`;
break;
default:
throw new Error("not supported");
}
break;
case "openIdConnect":
client.defaults.headers.common[securityDecorator.Name] = scheme[fname];
break;
case "oauth2":
client.defaults.headers.common[securityDecorator.Name] = scheme[fname];
break;
case "http":
switch (schemeDecorator.SubType) {
case "basic":
break;
case "bearer":
client.defaults.headers.common[securityDecorator.Name] =
scheme[fname];
break;
default:
throw new Error("not supported");
}
break;
default:
throw new Error("not supported");
}
});
return client;
}

function parseSecuritySchemeValue(
client: AxiosInstance,
schemeDecorator: SecurityDecorator,
securityDecorator: SecurityDecorator,
value: any
): AxiosInstance {
switch (schemeDecorator.Type) {
case "apiKey":
switch (schemeDecorator.SubType) {
case "header":
client.defaults.headers.common[securityDecorator.Name] = value;
break;
case "query":
client.defaults.params[securityDecorator.Name] = value;
break;
case "cookie":
const securityDecoratorName: string = securityDecorator.Name;
const val: string = value;
client.defaults.headers.common[
"Cookie"
] = `${securityDecoratorName}=${val}`;
break;
default:
throw new Error("not supported");
}
break;
case "openIdConnect":
client.defaults.headers.common[securityDecorator.Name] = value;
break;
case "oauth2":
client.defaults.headers.common[securityDecorator.Name] = value;
break;
case "http":
switch (schemeDecorator.SubType) {
case "basic":
break;
case "bearer":
client.defaults.headers.common[securityDecorator.Name] = value;
break;
default:
throw new Error("not supported");
}
break;
default:
throw new Error("not supported");
}

return client;
}
Expand Down
4 changes: 2 additions & 2 deletions src/internal/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function SpeakeasyMetadata<
};
}

export function replaceParameters(
export function templateUrl(
stringWithParams: string,
params: Record<string, string>
): string {
Expand Down Expand Up @@ -195,7 +195,7 @@ export function generateURL(
});
}
});
return replaceParameters(url, parsedParameters);
return templateUrl(url, parsedParameters);
}

export function parseParamDecorator(
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/models/operations/cancelfinetune.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SpeakeasyBase, SpeakeasyMetadata } from "../../../internal/utils";
import { AxiosResponse } from "axios";
import { Type } from "class-transformer";


Expand All @@ -21,4 +22,7 @@ export class CancelFineTuneResponse extends SpeakeasyBase {

@SpeakeasyMetadata()
statusCode: number;

@SpeakeasyMetadata()
rawResponse?: AxiosResponse;
}
4 changes: 4 additions & 0 deletions src/sdk/models/operations/createanswer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SpeakeasyBase, SpeakeasyMetadata } from "../../../internal/utils";
import * as shared from "../shared";
import { AxiosResponse } from "axios";
import { Type } from "class-transformer";


Expand All @@ -17,4 +18,7 @@ export class CreateAnswerResponse extends SpeakeasyBase {

@SpeakeasyMetadata()
statusCode: number;

@SpeakeasyMetadata()
rawResponse?: AxiosResponse;
}
Loading

0 comments on commit ff37036

Please sign in to comment.