repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
TokenValidator.deleteKey
public deleteKey(kid: string) { this.cacheWrapper?.cache.del(kid); }
/** * Deletes a key from the cache. * @param {string} kid The key ID to delete from the cache. */
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/functions/middleware/tokenValidator.ts#L163-L165
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
ConsultantApiService.getApiConsultantForBaseConsultant
async getApiConsultantForBaseConsultant(consultant: Consultant, assignments: Assignment[]): Promise<ApiConsultant> { const result = { id: consultant.id, name: consultant.name, email: consultant.email, phone: consultant.phone, consultantPhotoUrl: consu...
// Augment a base consultant to get an ApiConsultant
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/services/ConsultantApiService.ts#L85-L140
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
ConsultantApiService.findHours
private findHours(hours: HoursEntry[]): { lastMonthHours: number, thisMonthHours: number, nextMonthHours: number } { const now = new Date(); const thisMonth = now.getMonth(); const thisYear = now.getFullYear(); const lastMonth = thisMonth === 0 ? 11 : thisMonth - 1; const lastYe...
// Extract this and next month's hours from an array of HoursEntry
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/services/ConsultantApiService.ts#L143-L160
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
Identity.validateRequest
public async validateRequest(req: HttpRequest): Promise<ApiConsultant> { // Default user used for unauthenticated testing let userId = "1"; let userName = "Avery Howard"; let userEmail = "avery@treyresearch.com"; // Try to validate the token and get user's basic information ...
// Number the requests for logging purposes
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/services/IdentityService.ts#L15-L88
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
ProjectApiService.getApiProject
async getApiProject(project: Project, assignments: Assignment[]): Promise<ApiProject> { const result = project as ApiProject; assignments = assignments.filter((a) => a.projectId === project.id); result.consultants = []; result.forecastThisMonth = 0; result.forecastNextMonth = 0...
// Augment a project to get an ApiProject
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/services/ProjectApiService.ts#L57-L94
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
ProjectApiService.findHours
private findHours(hours: HoursEntry[]): { lastMonthHours: number, thisMonthHours: number, nextMonthHours: number } { const now = new Date(); const thisMonth = now.getMonth(); const thisYear = now.getFullYear(); const lastMonth = thisMonth === 0 ? 11 : thisMonth - 1; const lastYe...
// Extract this and next month's hours from an array of HoursEntry
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research-auth/src/services/ProjectApiService.ts#L97-L114
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
ConsultantApiService.getApiConsultantForBaseConsultant
async getApiConsultantForBaseConsultant(consultant: Consultant, assignments: Assignment[]): Promise<ApiConsultant> { const result = { id: consultant.id, name: consultant.name, email: consultant.email, phone: consultant.phone, consultantPhotoUrl: consu...
// Augment a base consultant to get an ApiConsultant
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research/src/services/ConsultantApiService.ts#L85-L140
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
ConsultantApiService.findHours
private findHours(hours: HoursEntry[]): { lastMonthHours: number, thisMonthHours: number, nextMonthHours: number } { const now = new Date(); const thisMonth = now.getMonth(); const thisYear = now.getFullYear(); const lastMonth = thisMonth === 0 ? 11 : thisMonth - 1; const lastYe...
// Extract this and next month's hours from an array of HoursEntry
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research/src/services/ConsultantApiService.ts#L143-L160
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
Identity.validateRequest
public async validateRequest(req: HttpRequest): Promise<ApiConsultant> { // Default user used for unauthenticated testing let userId = "1"; let userName = "Avery Howard"; let userEmail = "avery@treyresearch.com"; // ** INSERT REQUEST VALIDATION HERE (see Lab E6) ** // ...
// Number the requests for logging purposes
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research/src/services/IdentityService.ts#L13-L37
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
ProjectApiService.getApiProject
async getApiProject(project: Project, assignments: Assignment[]): Promise<ApiProject> { const result = project as ApiProject; assignments = assignments.filter((a) => a.projectId === project.id); result.consultants = []; result.forecastThisMonth = 0; result.forecastNextMonth = 0...
// Augment a project to get an ApiProject
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research/src/services/ProjectApiService.ts#L57-L94
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
ProjectApiService.findHours
private findHours(hours: HoursEntry[]): { lastMonthHours: number, thisMonthHours: number, nextMonthHours: number } { const now = new Date(); const thisMonth = now.getMonth(); const thisYear = now.getFullYear(); const lastMonth = thisMonth === 0 ? 11 : thisMonth - 1; const lastYe...
// Extract this and next month's hours from an array of HoursEntry
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/cext-trey-research/src/services/ProjectApiService.ts#L97-L114
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
onTurnErrorHandler
const onTurnErrorHandler = async (context: TurnContext, error: Error) => { // This check writes out errors to console log .vs. app insights. // NOTE: In production environment, you should consider logging this to Azure // application insights. console.error(`\n [onTurnError] unhandled error: ${error}`); ...
// Catch-all for errors.
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-multiparam-ts/src/index.ts#L33-L50
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
onTurnErrorHandler
const onTurnErrorHandler = async (context: TurnContext, error: Error) => { // This check writes out errors to console log .vs. app insights. // NOTE: In production environment, you should consider logging this to Azure // application insights. console.error(`\n [onTurnError] unhandled error: ${error}`); ...
// Catch-all for errors.
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-action-ts/src/index.ts#L33-L50
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
SearchApp.handleTeamsMessagingExtensionQuery
public async handleTeamsMessagingExtensionQuery( context: TurnContext, query: MessagingExtensionQuery ): Promise<MessagingExtensionResponse> { switch (query.commandId) { case productSearchCommand.COMMAND_ID: { return productSearchCommand.handleTeamsMessagingExtensionQuery(context, query); ...
// Handle search message extension
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-action-ts/src/searchApp.ts#L22-L39
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
SearchApp.onAdaptiveCardInvoke
public async onAdaptiveCardInvoke(context: TurnContext): Promise<AdaptiveCardInvokeResponse> { try { switch (context.activity.value.action.verb) { case 'ok': { return actionHandler.handleTeamsCardActionUpdateStock(context); } case 'restock': { return actionHandler....
// Handle adaptive card actions
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-action-ts/src/searchApp.ts#L42-L72
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
isMatchingStatus
function isMatchingStatus(inventoryStatusQuery: string, product: ProductEx): boolean { const query = inventoryStatusQuery.toLowerCase(); if (query.startsWith("out")) { // Out of stock return product.UnitsInStock === 0; } else if (query.startsWith("low")) { // Low stock retur...
// Returns true if the inventory status in a product matches the query using
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-action-ts/src/northwindDB/products.ts#L71-L87
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
isInRange
function isInRange(rangeExpression: string, value: number) { let result = false; // Return false if the expression is malformed if (rangeExpression.indexOf('-')< 0) { // If here, we have a single value or a malformed expression const val = Number(rangeExpression); if (!isNaN(val)) ...
// Used to filter based on a range entered in the stockLevel parameter
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-action-ts/src/northwindDB/products.ts#L91-L117
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
getAllProductsEx
async function getAllProductsEx(): Promise<ProductEx[]> { // Ensure reference data are loaded categories = categories ?? await loadReferenceData<Category>(TABLE_NAME.CATEGORY); suppliers = suppliers ?? await loadReferenceData<Supplier>(TABLE_NAME.SUPPLIER); orderTotals = orderTotals ?? await loadOrderT...
// #endregion
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-action-ts/src/northwindDB/products.ts#L183-L201
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
onTurnErrorHandler
const onTurnErrorHandler = async (context: TurnContext, error: Error) => { // This check writes out errors to console log .vs. app insights. // NOTE: In production environment, you should consider logging this to Azure // application insights. console.error(`\n [onTurnError] unhandled error: ${error}`); ...
// Catch-all for errors.
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-ts/src/index.ts#L33-L50
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
SearchApp.handleTeamsMessagingExtensionQuery
public async handleTeamsMessagingExtensionQuery( context: TurnContext, query: MessagingExtensionQuery ): Promise<MessagingExtensionResponse> { switch (query.commandId) { case productSearchCommand.COMMAND_ID: { return productSearchCommand.handleTeamsMessagingExtensionQuery(context, query); ...
// Handle search message extension
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-ts/src/searchApp.ts#L20-L34
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
SearchApp.onAdaptiveCardInvoke
public async onAdaptiveCardInvoke(context: TurnContext): Promise<AdaptiveCardInvokeResponse> { try { switch (context.activity.value.action.verb) { case 'ok': { return actionHandler.handleTeamsCardActionUpdateStock(context); } case 'restock': { ...
// Handle adaptive card actions
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-ts/src/searchApp.ts#L37-L62
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
isMatchingStatus
function isMatchingStatus(inventoryStatusQuery: string, product: ProductEx): boolean { const query = inventoryStatusQuery.toLowerCase(); if (query.startsWith("out")) { // Out of stock return product.UnitsInStock === 0; } else if (query.startsWith("low")) { // Low stock retur...
// Returns true if the inventory status in a product matches the query using
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-ts/src/northwindDB/products.ts#L70-L86
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
isInRange
function isInRange(rangeExpression: string, value: number) { let result = false; // Return false if the expression is malformed if (rangeExpression.indexOf('-')< 0) { // If here, we have a single value or a malformed expression const val = Number(rangeExpression); if (!isNaN(val)) ...
// Used to filter based on a range entered in the stockLevel parameter
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-ts/src/northwindDB/products.ts#L90-L116
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
getAllProductsEx
async function getAllProductsEx(): Promise<ProductEx[]> { await ensureReferenceDataLoaded(); // We always read the products fresh in case somebody made a change const result: ProductEx[] = []; const tableClient = TableClient.fromConnectionString(config.storageAccountConnectionString, TABLE_NAME.PRODUC...
// #endregion
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-northwind-inventory-ts/src/northwindDB/products.ts#L188-L203
159c86a02b84a4ebba05ec606411afc76bf9d9ab
Microsoft-365-Copilot-Samples
github_2023
OfficeDev
typescript
onTurnErrorHandler
const onTurnErrorHandler = async (context: TurnContext, error: Error) => { // This check writes out errors to console log .vs. app insights. // NOTE: In production environment, you should consider logging this to Azure // application insights. console.error(`\n [onTurnError] unhandled error: ${error}`); ...
// Catch-all for errors.
https://github.com/OfficeDev/Microsoft-365-Copilot-Samples/blob/159c86a02b84a4ebba05ec606411afc76bf9d9ab/samples/msgext-product-support-sso-ts/src/index.ts#L33-L54
159c86a02b84a4ebba05ec606411afc76bf9d9ab
smart-wallet
github_2023
passkeys-4337
typescript
UserOpBuilder.buildUserOp
async buildUserOp({ calls, maxFeePerGas, maxPriorityFeePerGas, keyId, }: { calls: Call[]; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; keyId: Hex; }): Promise<UserOperationAsHex> { // calculate smart wallet address via Factory contract to know the sender const { accoun...
// reference: https://ethereum.stackexchange.com/questions/150796/how-to-create-a-raw-erc-4337-useroperation-from-scratch-and-then-send-it-to-bund
https://github.com/passkeys-4337/smart-wallet/blob/f3aa9fd44646fde0316fc810e21cc553a9ed73e0/front/src/libs/smart-wallet/service/userOps/builder.ts#L54-L122
f3aa9fd44646fde0316fc810e21cc553a9ed73e0
openai-deno-build
github_2023
openai
typescript
APIPromise.asResponse
asResponse(): Promise<Response> { return this.responsePromise.then((p) => p.response); }
/** * Gets the raw `Response` instance instead of parsing the response * data. * * If you want to parse the response body but still get the `Response` * instance, you can use {@link withResponse()}. * * 👋 Getting the wrong TypeScript type for `Response`? * Try setting `"moduleResolution": "Node...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/core.ts#L155-L157
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
APIPromise.withResponse
async withResponse(): Promise< { data: T; response: Response; request_id: string | null | undefined } > { const [data, response] = await Promise.all([ this.parse(), this.asResponse(), ]); return { data, response, request_id: response.headers.get("x-request-id") }; }
/** * Gets the parsed response data, the raw `Response` instance and the ID of the request, * returned via the X-Request-ID header which is useful for debugging requests and reporting * issues to OpenAI. * * If you just want to get the raw `Response` instance without parsing it, * you can use {@link a...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/core.ts#L173-L181
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
getBrowserInfo
function getBrowserInfo(): BrowserInfo | null { if (typeof navigator === "undefined" || !navigator) { return null; } // NOTE: The order matters here! const browserPatterns = [ { key: "edge" as const, pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ }, { key: "ie" as const, pattern: /MSIE(?:\W+(\d+)\...
// Note: modified from https://github.com/JS-DevTools/host-environment/blob/b1ab79ecde37db5d6e163c050e54fe7d287d7c92/src/isomorphic.browser.ts
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/core.ts#L1085-L1126
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
applyHeadersMut
function applyHeadersMut(targetHeaders: Headers, newHeaders: Headers): void { for (const k in newHeaders) { if (!hasOwn(newHeaders, k)) continue; const lowerKey = k.toLowerCase(); if (!lowerKey) continue; const val = newHeaders[k]; if (val === null) { delete targetHeaders[lowerKey]; } ...
/** * Copies headers from "newHeaders" onto "targetHeaders", * using lower-case for all properties, * ignoring any keys with undefined values, * and deleting any keys with null values. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/core.ts#L1296-L1310
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
uuid4
const uuid4 = () => { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => { const r = (Math.random() * 16) | 0; const v = c === "x" ? r : (r & 0x3) | 0x8; return v.toString(16); }); };
/** * https://stackoverflow.com/a/2117523 */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/core.ts#L1321-L1327
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
OpenAI.constructor
constructor({ baseURL = Core.readEnv("OPENAI_BASE_URL"), apiKey = Core.readEnv("OPENAI_API_KEY"), organization = Core.readEnv("OPENAI_ORG_ID") ?? null, project = Core.readEnv("OPENAI_PROJECT_ID") ?? null, ...opts }: ClientOptions = {}) { if (apiKey === undefined) { throw new Errors.OpenA...
/** * API Client for interfacing with the OpenAI API. * * @param {string | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? undefined] * @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null] * @param {string | null | undefined} [opts.project=process.env['OPEN...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/mod.ts#L115-L155
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
AzureOpenAI.constructor
constructor({ baseURL = Core.readEnv("OPENAI_BASE_URL"), apiKey = Core.readEnv("AZURE_OPENAI_API_KEY"), apiVersion = Core.readEnv("OPENAI_API_VERSION"), endpoint, deployment, azureADTokenProvider, dangerouslyAllowBrowser, ...opts }: AzureClientOptions = {}) { if (!apiVersion) { ...
/** * API Client for interfacing with the Azure OpenAI API. * * @param {string | undefined} [opts.apiVersion=process.env['OPENAI_API_VERSION'] ?? undefined] * @param {string | undefined} [opts.endpoint=process.env['AZURE_OPENAI_ENDPOINT'] ?? undefined] - Your Azure endpoint, including the resource, e.g. `ht...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/mod.ts#L416-L485
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Page.nextPageParams
nextPageParams(): null { return null; }
/** * This page represents a response that isn't actually paginated at the API level * so there will never be any next page params. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/pagination.ts#L47-L49
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
CursorPage.nextPageParams
nextPageParams(): Partial<CursorPageParams> | null { const info = this.nextPageInfo(); if (!info) return null; if ("params" in info) return info.params; const params = Object.fromEntries(info.url.searchParams); if (!Object.keys(params).length) return null; return params; }
// @deprecated Please use `nextPageInfo()` instead
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/pagination.ts#L86-L93
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Stream.fromReadableStream
static fromReadableStream<Item>( readableStream: ReadableStream, controller: AbortController, ) { let consumed = false; async function* iterLines(): AsyncGenerator<string, void, unknown> { const lineDecoder = new LineDecoder(); const iter = readableStreamAsyncIterable<Bytes>(readableStre...
/** * Generates a Stream from a newline-separated ReadableStream * where each item is a JSON value. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/streaming.ts#L103-L149
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Stream.tee
tee(): [Stream<Item>, Stream<Item>] { const left: Array<Promise<IteratorResult<Item>>> = []; const right: Array<Promise<IteratorResult<Item>>> = []; const iterator = this.iterator(); const teeIterator = ( queue: Array<Promise<IteratorResult<Item>>>, ): AsyncIterator<Item> => { return { ...
/** * Splits the stream into two streams which can be * independently read from at different speeds. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/streaming.ts#L159-L183
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Stream.toReadableStream
toReadableStream(): ReadableStream { const self = this; let iter: AsyncIterator<Item>; const encoder = new TextEncoder(); return new ReadableStream({ async start() { iter = self[Symbol.asyncIterator](); }, async pull(ctrl: any) { try { const { value, done } =...
/** * Converts this stream to a newline-separated ReadableStream of * JSON stringified values in the stream * which can be turned back into a Stream with `Stream.fromReadableStream()`. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/streaming.ts#L190-L215
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
parseJSON
function parseJSON(jsonString: string, allowPartial: number = Allow.ALL): any { if (typeof jsonString !== "string") { throw new TypeError(`expecting str, got ${typeof jsonString}`); } if (!jsonString.trim()) { throw new Error(`${jsonString} is empty`); } return _parseJSON(jsonString.trim(), allowParti...
/** * Parse incomplete JSON * @param {string} jsonString Partial JSON to be parsed * @param {number} allowPartial Specify what types are allowed to be partial, see {@link Allow} for details * @returns The parsed JSON * @throws {PartialJSON} If the JSON is incomplete (related to the `allow` parameter) * @throws {M...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/_vendor/partial-json-parser/parser.ts#L47-L55
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
partialParse
const partialParse = (input: string) => parseJSON(input, Allow.ALL ^ Allow.NUM);
// using this function with malformed JSON is undefined behavior
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/_vendor/partial-json-parser/parser.ts#L276-L276
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
processRegExp
const processRegExp = ( regexOrFunction: RegExp | (() => RegExp), refs: Refs, ): string => { const regex = typeof regexOrFunction === "function" ? regexOrFunction() : regexOrFunction; if (!refs.applyRegexFlags || !regex.flags) return regex.source; // Currently handled flags const flags = { i: r...
// Mutate z.string.regex() in a best attempt to accommodate for regex flags when applyRegexFlags is true
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/_vendor/zod-to-json-schema/parsers/string.ts#L365-L456
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
LineDecoder.constructor
constructor() { this.buffer = []; this.trailingCR = false; }
// TextDecoder found in browsers; not typed to avoid pulling in either "dom" or "node" types.
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/internal/decoders/line.ts#L20-L23
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
AbstractChatCompletionRunner.finalChatCompletion
async finalChatCompletion(): Promise<ParsedChatCompletion<ParsedT>> { await this.done(); const completion = this._chatCompletions[this._chatCompletions.length - 1]; if (!completion) { throw new OpenAIError("stream ended without producing a ChatCompletion"); } return completion; }
/** * @returns a promise that resolves with the final ChatCompletion, or rejects * if an error occurred or the stream ended prematurely without producing a ChatCompletion. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/AbstractChatCompletionRunner.ts#L98-L105
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
AbstractChatCompletionRunner.finalContent
async finalContent(): Promise<string | null> { await this.done(); return this.#getFinalContent(); }
/** * @returns a promise that resolves with the content of the final ChatCompletionMessage, or rejects * if an error occurred or the stream ended prematurely without producing a ChatCompletionMessage. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/AbstractChatCompletionRunner.ts#L115-L118
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
AbstractChatCompletionRunner.finalMessage
async finalMessage(): Promise<ChatCompletionMessage> { await this.done(); return this.#getFinalMessage(); }
/** * @returns a promise that resolves with the the final assistant ChatCompletionMessage response, * or rejects if an error occurred or the stream ended prematurely without producing a ChatCompletionMessage. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/AbstractChatCompletionRunner.ts#L148-L151
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
AbstractChatCompletionRunner.finalFunctionCall
async finalFunctionCall(): Promise< ChatCompletionMessage.FunctionCall | undefined > { await this.done(); return this.#getFinalFunctionCall(); }
/** * @returns a promise that resolves with the content of the final FunctionCall, or rejects * if an error occurred or the stream ended prematurely without producing a ChatCompletionMessage. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/AbstractChatCompletionRunner.ts#L171-L176
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
ChatCompletionRunner.runFunctions
static runFunctions( client: OpenAI, params: ChatCompletionFunctionRunnerParams<any[]>, options?: RunnerOptions, ): ChatCompletionRunner<null> { const runner = new ChatCompletionRunner(); const opts = { ...options, headers: { ...options?.headers, "X-Stainless-Helper-Met...
/** @deprecated - please use `runTools` instead. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/ChatCompletionRunner.ts#L52-L67
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
ChatCompletionStream.fromReadableStream
static fromReadableStream( stream: ReadableStream, ): ChatCompletionStream<null> { const runner = new ChatCompletionStream(null); runner._run(() => runner._fromReadableStream(stream)); return runner; }
/** * Intended for use on the frontend, consuming a stream produced with * `.toReadableStream()` on the backend. * * Note that messages sent to the model do not appear in `.on('message')` * in this context. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/ChatCompletionStream.ts#L161-L167
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
assertIsEmpty
function assertIsEmpty<T extends {}>( obj: AssertIsEmpty<T>, ): asserts obj is AssertIsEmpty<T> { return; }
/** * Ensures the given argument is an empty object, useful for * asserting that all known properties on an object have been * destructured. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/ChatCompletionStream.ts#L978-L982
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
ChatCompletionStreamingRunner.runFunctions
static runFunctions<T extends (string | object)[]>( client: OpenAI, params: ChatCompletionStreamingFunctionRunnerParams<T>, options?: RunnerOptions, ): ChatCompletionStreamingRunner<null> { const runner = new ChatCompletionStreamingRunner(null); const opts = { ...options, headers: { ...
/** @deprecated - please use `runTools` instead. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/ChatCompletionStreamingRunner.ts#L62-L77
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
EventStream.on
on<Event extends keyof EventTypes>( event: Event, listener: EventListener<EventTypes, Event>, ): this { const listeners: EventListeners<EventTypes, Event> = this.#listeners[event] || (this.#listeners[event] = []); listeners.push({ listener }); return this; }
/** * Adds the listener function to the end of the listeners array for the event. * No checks are made to see if the listener has already been added. Multiple calls passing * the same combination of event and listener will result in the listener being added, and * called, multiple times. * @returns this ...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/EventStream.ts#L82-L90
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
EventStream.off
off<Event extends keyof EventTypes>( event: Event, listener: EventListener<EventTypes, Event>, ): this { const listeners = this.#listeners[event]; if (!listeners) return this; const index = listeners.findIndex((l) => l.listener === listener); if (index >= 0) listeners.splice(index, 1); ret...
/** * Removes the specified listener from the listener array for the event. * off() will remove, at most, one instance of a listener from the listener array. If any single * listener has been added multiple times to the listener array for the specified event, then * off() must be called multiple times to re...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/EventStream.ts#L99-L108
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
EventStream.once
once<Event extends keyof EventTypes>( event: Event, listener: EventListener<EventTypes, Event>, ): this { const listeners: EventListeners<EventTypes, Event> = this.#listeners[event] || (this.#listeners[event] = []); listeners.push({ listener, once: true }); return this; }
/** * Adds a one-time listener function for the event. The next time the event is triggered, * this listener is removed and then invoked. * @returns this ChatCompletionStream, so that calls can be chained */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/EventStream.ts#L115-L123
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
EventStream.emitted
emitted<Event extends keyof EventTypes>( event: Event, ): Promise< EventParameters<EventTypes, Event> extends [infer Param] ? Param : EventParameters<EventTypes, Event> extends [] ? void : EventParameters<EventTypes, Event> > { return new Promise((resolve, reject) => { this.#catchingPr...
/** * This is similar to `.once()`, but returns a Promise that resolves the next time * the event is triggered, instead of calling a listener callback. * @returns a Promise that resolves the next time given event is triggered, * or rejects if an error is emitted. (If you request the 'error' event, * ret...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/lib/EventStream.ts#L136-L148
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Batches.create
create( body: BatchCreateParams, options?: Core.RequestOptions, ): Core.APIPromise<Batch> { return this._client.post("/batches", { body, ...options }); }
/** * Creates and executes a batch from an uploaded file of requests */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/batches.ts#L13-L18
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Batches.retrieve
retrieve( batchId: string, options?: Core.RequestOptions, ): Core.APIPromise<Batch> { return this._client.get(`/batches/${batchId}`, options); }
/** * Retrieves a batch. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/batches.ts#L23-L28
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Batches.cancel
cancel( batchId: string, options?: Core.RequestOptions, ): Core.APIPromise<Batch> { return this._client.post(`/batches/${batchId}/cancel`, options); }
/** * Cancels an in-progress batch. The batch will be in status `cancelling` for up to * 10 minutes, before changing to `cancelled`, where it will have partial results * (if any) available in the output file. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/batches.ts#L56-L61
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Embeddings.create
create( body: EmbeddingCreateParams, options?: Core.RequestOptions, ): Core.APIPromise<CreateEmbeddingResponse> { return this._client.post("/embeddings", { body, ...options }); }
/** * Creates an embedding vector representing the input text. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/embeddings.ts#L11-L16
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Files.create
create( body: FileCreateParams, options?: Core.RequestOptions, ): Core.APIPromise<FileObject> { return this._client.post( "/files", Core.multipartFormRequestOptions({ body, ...options }), ); }
/** * Upload a file that can be used across various endpoints. Individual files can be * up to 512 MB, and the size of all files uploaded by one organization can be up * to 100 GB. * * The Assistants API supports files up to 2 million tokens and of specific file * types. See the * [Assistants Tools...
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/files.ts#L36-L44
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Files.retrieve
retrieve( fileId: string, options?: Core.RequestOptions, ): Core.APIPromise<FileObject> { return this._client.get(`/files/${fileId}`, options); }
/** * Returns information about a specific file. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/files.ts#L49-L54
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Files.del
del( fileId: string, options?: Core.RequestOptions, ): Core.APIPromise<FileDeleted> { return this._client.delete(`/files/${fileId}`, options); }
/** * Delete a file. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/files.ts#L82-L87
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Files.content
content( fileId: string, options?: Core.RequestOptions, ): Core.APIPromise<Response> { return this._client.get(`/files/${fileId}/content`, { ...options, __binaryResponse: true, }); }
/** * Returns the contents of the specified file. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/files.ts#L92-L100
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Files.retrieveContent
retrieveContent( fileId: string, options?: Core.RequestOptions, ): Core.APIPromise<string> { return this._client.get(`/files/${fileId}/content`, { ...options, headers: { Accept: "application/json", ...options?.headers }, }); }
/** * Returns the contents of the specified file. * * @deprecated The `.content()` method should be used instead */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/files.ts#L107-L115
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Files.waitForProcessing
async waitForProcessing( id: string, { pollInterval = 5000, maxWait = 30 * 60 * 1000 }: { pollInterval?: number; maxWait?: number; } = {}, ): Promise<FileObject> { const TERMINAL_STATES = new Set(["processed", "error", "deleted"]); const start = Date.now(); let file = await this.r...
/** * Waits for the given file to be processed, default timeout is 30 mins. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/files.ts#L120-L145
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Images.createVariation
createVariation( body: ImageCreateVariationParams, options?: Core.RequestOptions, ): Core.APIPromise<ImagesResponse> { return this._client.post( "/images/variations", Core.multipartFormRequestOptions({ body, ...options }), ); }
/** * Creates a variation of a given image. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/images.ts#L11-L19
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Images.edit
edit( body: ImageEditParams, options?: Core.RequestOptions, ): Core.APIPromise<ImagesResponse> { return this._client.post( "/images/edits", Core.multipartFormRequestOptions({ body, ...options }), ); }
/** * Creates an edited or extended image given an original image and a prompt. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/images.ts#L24-L32
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Images.generate
generate( body: ImageGenerateParams, options?: Core.RequestOptions, ): Core.APIPromise<ImagesResponse> { return this._client.post("/images/generations", { body, ...options }); }
/** * Creates an image given a prompt. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/images.ts#L37-L42
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Models.retrieve
retrieve( model: string, options?: Core.RequestOptions, ): Core.APIPromise<Model> { return this._client.get(`/models/${model}`, options); }
/** * Retrieves a model instance, providing basic information about the model such as * the owner and permissioning. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/models.ts#L13-L18
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Models.list
list(options?: Core.RequestOptions): Core.PagePromise<ModelsPage, Model> { return this._client.getAPIList("/models", ModelsPage, options); }
/** * Lists the currently available models, and provides basic information about each * one such as the owner and availability. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/models.ts#L24-L26
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Models.del
del( model: string, options?: Core.RequestOptions, ): Core.APIPromise<ModelDeleted> { return this._client.delete(`/models/${model}`, options); }
/** * Delete a fine-tuned model. You must have the Owner role in your organization to * delete a model. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/models.ts#L32-L37
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Moderations.create
create( body: ModerationCreateParams, options?: Core.RequestOptions, ): Core.APIPromise<ModerationCreateResponse> { return this._client.post("/moderations", { body, ...options }); }
/** * Classifies if text and/or image inputs are potentially harmful. Learn more in * the [moderation guide](https://platform.openai.com/docs/guides/moderation). */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/moderations.ts#L12-L17
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Speech.create
create( body: SpeechCreateParams, options?: Core.RequestOptions, ): Core.APIPromise<Response> { return this._client.post("/audio/speech", { body, ...options, __binaryResponse: true, }); }
/** * Generates audio from the input text. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/audio/speech.ts#L12-L21
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Assistants.create
create( body: AssistantCreateParams, options?: Core.RequestOptions, ): Core.APIPromise<Assistant> { return this._client.post("/assistants", { body, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Create an assistant with a model and instructions. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/assistants.ts#L20-L29
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Assistants.retrieve
retrieve( assistantId: string, options?: Core.RequestOptions, ): Core.APIPromise<Assistant> { return this._client.get(`/assistants/${assistantId}`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Retrieves an assistant. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/assistants.ts#L34-L42
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Assistants.update
update( assistantId: string, body: AssistantUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise<Assistant> { return this._client.post(`/assistants/${assistantId}`, { body, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Modifies an assistant. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/assistants.ts#L47-L57
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Assistants.del
del( assistantId: string, options?: Core.RequestOptions, ): Core.APIPromise<AssistantDeleted> { return this._client.delete(`/assistants/${assistantId}`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Delete an assistant. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/assistants.ts#L86-L94
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Completions.stream
stream< Params extends ChatCompletionStreamParams, ParsedT = ExtractParsedContentFromParams<Params>, >( body: Params, options?: Core.RequestOptions, ): ChatCompletionStream<ParsedT> { return ChatCompletionStream.createChatCompletion( this._client, body, options, ); }
/** * Creates a chat completion stream */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/chat/completions.ts#L180-L192
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Messages.create
create( threadId: string, body: MessageCreateParams, options?: Core.RequestOptions, ): Core.APIPromise<Message> { return this._client.post(`/threads/${threadId}/messages`, { body, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Create a message. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/messages.ts#L14-L24
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Messages.retrieve
retrieve( threadId: string, messageId: string, options?: Core.RequestOptions, ): Core.APIPromise<Message> { return this._client.get(`/threads/${threadId}/messages/${messageId}`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Retrieve a message. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/messages.ts#L29-L38
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Messages.update
update( threadId: string, messageId: string, body: MessageUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise<Message> { return this._client.post(`/threads/${threadId}/messages/${messageId}`, { body, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.h...
/** * Modifies a message. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/messages.ts#L43-L54
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Messages.del
del( threadId: string, messageId: string, options?: Core.RequestOptions, ): Core.APIPromise<MessageDeleted> { return this._client.delete(`/threads/${threadId}/messages/${messageId}`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Deletes a message. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/messages.ts#L90-L99
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Threads.retrieve
retrieve( threadId: string, options?: Core.RequestOptions, ): Core.APIPromise<Thread> { return this._client.get(`/threads/${threadId}`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Retrieves a thread. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/threads.ts#L49-L57
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Threads.update
update( threadId: string, body: ThreadUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise<Thread> { return this._client.post(`/threads/${threadId}`, { body, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Modifies a thread. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/threads.ts#L62-L72
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Threads.del
del( threadId: string, options?: Core.RequestOptions, ): Core.APIPromise<ThreadDeleted> { return this._client.delete(`/threads/${threadId}`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Delete a thread. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/threads.ts#L77-L85
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Threads.createAndRunPoll
async createAndRunPoll( body: ThreadCreateAndRunParamsNonStreaming, options?: Core.RequestOptions & { pollIntervalMs?: number }, ): Promise<Threads.Run> { const run = await this.createAndRun(body, options); return await this.runs.poll(run.thread_id, run.id, options); }
/** * A helper to create a thread, start a run and then poll for a terminal state. * More information on Run lifecycles can be found here: * https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/threads.ts#L123-L129
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Threads.createAndRunStream
createAndRunStream( body: ThreadCreateAndRunParamsBaseStream, options?: Core.RequestOptions, ): AssistantStream { return AssistantStream.createThreadAssistantStream( body, this._client.beta.threads, options, ); }
/** * Create a thread and stream the run back */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/threads.ts#L134-L143
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.retrieve
retrieve( threadId: string, runId: string, options?: Core.RequestOptions, ): Core.APIPromise<Run> { return this._client.get(`/threads/${threadId}/runs/${runId}`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Retrieves a run. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L63-L72
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.update
update( threadId: string, runId: string, body: RunUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise<Run> { return this._client.post(`/threads/${threadId}/runs/${runId}`, { body, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); ...
/** * Modifies a run. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L77-L88
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.cancel
cancel( threadId: string, runId: string, options?: Core.RequestOptions, ): Core.APIPromise<Run> { return this._client.post(`/threads/${threadId}/runs/${runId}/cancel`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }, }); }
/** * Cancels a run that is `in_progress`. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L120-L129
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.createAndPoll
async createAndPoll( threadId: string, body: RunCreateParamsNonStreaming, options?: Core.RequestOptions & { pollIntervalMs?: number }, ): Promise<Run> { const run = await this.create(threadId, body, options); return await this.poll(threadId, run.id, options); }
/** * A helper to create a run an poll for a terminal state. More information on Run * lifecycles can be found here: * https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L136-L143
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.createAndStream
createAndStream( threadId: string, body: RunCreateParamsBaseStream, options?: Core.RequestOptions, ): AssistantStream { return AssistantStream.createAssistantStream( threadId, this._client.beta.threads.runs, body, options, ); }
/** * Create a Run stream * * @deprecated use `stream` instead */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L150-L161
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.poll
async poll( threadId: string, runId: string, options?: Core.RequestOptions & { pollIntervalMs?: number }, ): Promise<Run> { const headers: { [key: string]: string } = { ...options?.headers, "X-Stainless-Poll-Helper": "true", }; if (options?.pollIntervalMs) { headers["X-Stain...
/** * A helper to poll a run status until it reaches a terminal state. More * information on Run lifecycles can be found here: * https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L168-L219
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.stream
stream( threadId: string, body: RunCreateParamsBaseStream, options?: Core.RequestOptions, ): AssistantStream { return AssistantStream.createAssistantStream( threadId, this._client.beta.threads.runs, body, options, ); }
/** * Create a Run stream */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L224-L235
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.submitToolOutputsAndPoll
async submitToolOutputsAndPoll( threadId: string, runId: string, body: RunSubmitToolOutputsParamsNonStreaming, options?: Core.RequestOptions & { pollIntervalMs?: number }, ): Promise<Run> { const run = await this.submitToolOutputs(threadId, runId, body, options); return await this.poll(threadI...
/** * A helper to submit a tool output to a run and poll for a terminal run state. * More information on Run lifecycles can be found here: * https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L285-L293
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
Runs.submitToolOutputsStream
submitToolOutputsStream( threadId: string, runId: string, body: RunSubmitToolOutputsParamsStream, options?: Core.RequestOptions, ): AssistantStream { return AssistantStream.createToolAssistantStream( threadId, runId, this._client.beta.threads.runs, body, options, ...
/** * Submit the tool outputs from a previous run and stream the run to a terminal * state. More information on Run lifecycles can be found here: * https://platform.openai.com/docs/assistants/how-it-works/runs-and-run-steps */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/threads/runs/runs.ts#L300-L313
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
FileBatches.create
create( vectorStoreId: string, body: FileBatchCreateParams, options?: Core.RequestOptions, ): Core.APIPromise<VectorStoreFileBatch> { return this._client.post(`/vector_stores/${vectorStoreId}/file_batches`, { body, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.he...
/** * Create a vector store file batch. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/vector-stores/file-batches.ts#L19-L29
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
FileBatches.retrieve
retrieve( vectorStoreId: string, batchId: string, options?: Core.RequestOptions, ): Core.APIPromise<VectorStoreFileBatch> { return this._client.get( `/vector_stores/${vectorStoreId}/file_batches/${batchId}`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...option...
/** * Retrieves a vector store file batch. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/vector-stores/file-batches.ts#L34-L46
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
FileBatches.cancel
cancel( vectorStoreId: string, batchId: string, options?: Core.RequestOptions, ): Core.APIPromise<VectorStoreFileBatch> { return this._client.post( `/vector_stores/${vectorStoreId}/file_batches/${batchId}/cancel`, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ......
/** * Cancel a vector store file batch. This attempts to cancel the processing of * files in this batch as soon as possible. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/vector-stores/file-batches.ts#L52-L64
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
FileBatches.createAndPoll
async createAndPoll( vectorStoreId: string, body: FileBatchCreateParams, options?: Core.RequestOptions & { pollIntervalMs?: number }, ): Promise<VectorStoreFileBatch> { const batch = await this.create(vectorStoreId, body); return await this.poll(vectorStoreId, batch.id, options); }
/** * Create a vector store batch and poll until all files have been processed. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/vector-stores/file-batches.ts#L69-L76
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe
openai-deno-build
github_2023
openai
typescript
FileBatches.poll
async poll( vectorStoreId: string, batchId: string, options?: Core.RequestOptions & { pollIntervalMs?: number }, ): Promise<VectorStoreFileBatch> { const headers: { [key: string]: string } = { ...options?.headers, "X-Stainless-Poll-Helper": "true", }; if (options?.pollIntervalMs) {...
/** * Wait for the given file batch to be processed. * * Note: this will return even if one of the files failed to process, you need to * check batch.file_counts.failed_count to handle this case. */
https://github.com/openai/openai-deno-build/blob/28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe/resources/beta/vector-stores/file-batches.ts#L118-L165
28ffdaa2c107c98db5eec50cf284f4fd37ad8fbe