Skip to content

[AutoPR default] Batch 2 sdk gen #11683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions sdk/openai/openai-assistants/src/api/assistantsContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { TokenCredential, KeyCredential } from "@azure/core-auth";
import { ClientOptions, Client, getClient } from "@azure-rest/core-client";
import { logger } from "../logger.js";

export interface AssistantsContext extends Client {}

/** Optional parameters for the client. */
export interface AssistantsClientOptionalParams extends ClientOptions {}

/** Azure OpenAI APIs for Assistants. */
export function createAssistants(
endpointParam: string,
credential: KeyCredential | TokenCredential,
options: AssistantsClientOptionalParams = {},
): AssistantsContext {
const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}`;

const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
const userAgentPrefix = prefixFromOptions
? `${prefixFromOptions} azsdk-js-api`
: "azsdk-js-api";
const { apiVersion: _, ...updatedOptions } = {
...options,
userAgentOptions: { userAgentPrefix },
loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },
credentials: {
scopes: options.credentials?.scopes ?? [
"https://cognitiveservices.azure.com/.default",
],
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "api-key",
},
};
const clientContext = getClient(endpointUrl, credential, updatedOptions);
clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" });
if (options.apiVersion) {
logger.warning(
"This client does not support client api-version, please change it at the operation level",
);
}
return clientContext;
}
50 changes: 50 additions & 0 deletions sdk/openai/openai-assistants/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export {
createAssistants,
AssistantsContext,
AssistantsClientOptionalParams,
} from "./assistantsContext.js";
export {
createAssistant,
listAssistants,
getAssistant,
updateAssistant,
deleteAssistant,
createThread,
getThread,
updateThread,
deleteThread,
createMessage,
listMessages,
getMessage,
updateMessage,
createRun,
listRuns,
getRun,
updateRun,
submitToolOutputsToRun,
cancelRun,
createThreadAndRun,
getRunStep,
listRunSteps,
listFiles,
uploadFile,
deleteFile,
getFile,
getFileContent,
listVectorStores,
createVectorStore,
getVectorStore,
modifyVectorStore,
deleteVectorStore,
listVectorStoreFiles,
createVectorStoreFile,
getVectorStoreFile,
deleteVectorStoreFile,
createVectorStoreFileBatch,
getVectorStoreFileBatch,
cancelVectorStoreFileBatch,
listVectorStoreFileBatchFiles,
} from "./operations.js";
Loading