[OpenAI] Lint test (#31854)
This commit is contained in:
Родитель
93ad213554
Коммит
de56a388eb
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
import { assert, describe, beforeEach, it } from "vitest";
|
import { assert, describe, beforeEach, it } from "vitest";
|
||||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||||
import OpenAI, { AzureOpenAI } from "openai";
|
import type { OpenAI, AzureOpenAI } from "openai";
|
||||||
import { createClient } from "./utils/createClient.js";
|
import { createClient } from "./utils/createClient.js";
|
||||||
import { APIMatrix, APIVersion } from "./utils/utils.js";
|
import { APIMatrix, type APIVersion } from "./utils/utils.js";
|
||||||
|
|
||||||
describe("AbortSignal", () => {
|
describe("AbortSignal", () => {
|
||||||
let client: AzureOpenAI | OpenAI;
|
let client: AzureOpenAI | OpenAI;
|
||||||
|
@ -31,7 +31,6 @@ describe("AbortSignal", () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
const deploymentName = "gpt-35-turbo";
|
const deploymentName = "gpt-35-turbo";
|
||||||
let currentMessage = "";
|
|
||||||
try {
|
try {
|
||||||
const events = client.beta.chat.completions.stream({
|
const events = client.beta.chat.completions.stream({
|
||||||
model: deploymentName,
|
model: deploymentName,
|
||||||
|
@ -46,7 +45,6 @@ describe("AbortSignal", () => {
|
||||||
assert.isDefined(event);
|
assert.isDefined(event);
|
||||||
events.abort();
|
events.abort();
|
||||||
}
|
}
|
||||||
assert.isDefined(currentMessage);
|
|
||||||
assert.fail("Expected to abort streaming");
|
assert.fail("Expected to abort streaming");
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
assert.isTrue(error.message.includes("aborted"));
|
assert.isTrue(error.message.includes("aborted"));
|
||||||
|
|
|
@ -5,8 +5,8 @@ import { matrix } from "@azure-tools/test-utils-vitest";
|
||||||
import { assert, describe, beforeEach, it } from "vitest";
|
import { assert, describe, beforeEach, it } from "vitest";
|
||||||
import { assertAssistantEquality } from "./utils/asserts.js";
|
import { assertAssistantEquality } from "./utils/asserts.js";
|
||||||
import { createClient } from "./utils/createClient.js";
|
import { createClient } from "./utils/createClient.js";
|
||||||
import OpenAI, { AzureOpenAI } from "openai";
|
import type { OpenAI, AzureOpenAI } from "openai";
|
||||||
import { APIVersion, isRateLimitRun, Metadata } from "./utils/utils.js";
|
import { APIVersion, isRateLimitRun, type Metadata } from "./utils/utils.js";
|
||||||
|
|
||||||
describe("OpenAIAssistants", () => {
|
describe("OpenAIAssistants", () => {
|
||||||
matrix([[APIVersion.Preview]] as const, async function (apiVersion: APIVersion) {
|
matrix([[APIVersion.Preview]] as const, async function (apiVersion: APIVersion) {
|
||||||
|
@ -217,7 +217,7 @@ describe("OpenAIAssistants", () => {
|
||||||
}
|
}
|
||||||
const instructions =
|
const instructions =
|
||||||
"Please address the user as Jane Doe. The user has a premium account.";
|
"Please address the user as Jane Doe. The user has a premium account.";
|
||||||
let run = await client.beta.threads.runs.createAndPoll(thread.id, {
|
const run = await client.beta.threads.runs.createAndPoll(thread.id, {
|
||||||
assistant_id: assistant.id,
|
assistant_id: assistant.id,
|
||||||
instructions,
|
instructions,
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||||
import { assert, describe, beforeEach, it, beforeAll } from "vitest";
|
import { assert, describe, beforeEach, it, beforeAll } from "vitest";
|
||||||
import { createClient } from "./utils/createClient.js";
|
import { createClient } from "./utils/createClient.js";
|
||||||
import { APIMatrix, APIVersion, DeploymentInfo } from "./utils/utils.js";
|
import { APIMatrix, type APIVersion, type DeploymentInfo } from "./utils/utils.js";
|
||||||
import OpenAI, { AzureOpenAI } from "openai";
|
import type { OpenAI, AzureOpenAI } from "openai";
|
||||||
import {
|
import {
|
||||||
assertChatCompletions,
|
assertChatCompletions,
|
||||||
assertChatCompletionsList,
|
assertChatCompletionsList,
|
||||||
|
@ -20,7 +20,7 @@ import {
|
||||||
updateWithSucceeded,
|
updateWithSucceeded,
|
||||||
withDeployments,
|
withDeployments,
|
||||||
} from "./utils/utils.js";
|
} from "./utils/utils.js";
|
||||||
import { ChatCompletionMessageParam } from "openai/resources/chat/completions.mjs";
|
import { type ChatCompletionMessageParam } from "openai/resources/chat/completions.mjs";
|
||||||
import { completionsModelsToSkip, functionCallModelsToSkip } from "./utils/models.js";
|
import { completionsModelsToSkip, functionCallModelsToSkip } from "./utils/models.js";
|
||||||
import "../../src/types/index.js";
|
import "../../src/types/index.js";
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ describe("Completions", function () {
|
||||||
if (!content) assert.fail("Undefined content");
|
if (!content) assert.fail("Undefined content");
|
||||||
try {
|
try {
|
||||||
JSON.parse(content);
|
JSON.parse(content);
|
||||||
} catch (e) {
|
} catch {
|
||||||
assert.fail(`Invalid JSON: ${content}`);
|
assert.fail(`Invalid JSON: ${content}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,12 +6,12 @@ import { describe, it, beforeAll } from "vitest";
|
||||||
import { createClient } from "./utils/createClient.js";
|
import { createClient } from "./utils/createClient.js";
|
||||||
import {
|
import {
|
||||||
APIMatrix,
|
APIMatrix,
|
||||||
APIVersion,
|
type APIVersion,
|
||||||
DeploymentInfo,
|
type DeploymentInfo,
|
||||||
getDeployments,
|
getDeployments,
|
||||||
withDeployments,
|
withDeployments,
|
||||||
} from "./utils/utils.js";
|
} from "./utils/utils.js";
|
||||||
import OpenAI, { AzureOpenAI } from "openai";
|
import type { OpenAI, AzureOpenAI } from "openai";
|
||||||
import { assertEmbeddings } from "./utils/asserts.js";
|
import { assertEmbeddings } from "./utils/asserts.js";
|
||||||
|
|
||||||
describe("Embeddings", function () {
|
describe("Embeddings", function () {
|
||||||
|
|
|
@ -5,15 +5,15 @@ import { matrix } from "@azure-tools/test-utils-vitest";
|
||||||
import { createClient } from "./utils/createClient.js";
|
import { createClient } from "./utils/createClient.js";
|
||||||
import {
|
import {
|
||||||
APIMatrix,
|
APIMatrix,
|
||||||
APIVersion,
|
type APIVersion,
|
||||||
DeploymentInfo,
|
type DeploymentInfo,
|
||||||
getDeployments,
|
getDeployments,
|
||||||
getSucceeded,
|
getSucceeded,
|
||||||
updateWithSucceeded,
|
updateWithSucceeded,
|
||||||
withDeployments,
|
withDeployments,
|
||||||
} from "./utils/utils.js";
|
} from "./utils/utils.js";
|
||||||
import { assertImagesWithJSON, assertImagesWithURLs } from "./utils/asserts.js";
|
import { assertImagesWithJSON, assertImagesWithURLs } from "./utils/asserts.js";
|
||||||
import OpenAI, { AzureOpenAI } from "openai";
|
import type { OpenAI, AzureOpenAI } from "openai";
|
||||||
import { describe, it, beforeAll } from "vitest";
|
import { describe, it, beforeAll } from "vitest";
|
||||||
|
|
||||||
describe("Images", function () {
|
describe("Images", function () {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||||
import { assert, describe, beforeEach, it } from "vitest";
|
import { assert, describe, beforeEach, it } from "vitest";
|
||||||
import OpenAI, { AzureOpenAI, toFile } from "openai";
|
import { type OpenAI, type AzureOpenAI, toFile } from "openai";
|
||||||
import { createClient } from "../utils/createClient.js";
|
import { createClient } from "../utils/createClient.js";
|
||||||
import { APIVersion } from "../utils/utils.js";
|
import { APIVersion } from "../utils/utils.js";
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,19 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||||
import { describe, beforeEach, it } from "vitest";
|
import { describe, beforeEach, it } from "vitest";
|
||||||
import OpenAI, { AzureOpenAI, toFile } from "openai";
|
import { type OpenAI, type AzureOpenAI, toFile } from "openai";
|
||||||
import { createClient } from "../utils/createClient.js";
|
import { createClient } from "../utils/createClient.js";
|
||||||
import { APIVersion, DeploymentInfo, getDeployments, withDeployments } from "../utils/utils.js";
|
import {
|
||||||
|
APIVersion,
|
||||||
|
type DeploymentInfo,
|
||||||
|
getDeployments,
|
||||||
|
withDeployments,
|
||||||
|
} from "../utils/utils.js";
|
||||||
import { assertBatch, assertNonEmptyArray } from "../utils/asserts.js";
|
import { assertBatch, assertNonEmptyArray } from "../utils/asserts.js";
|
||||||
import { delay } from "@azure-tools/test-recorder";
|
import { delay } from "@azure-tools/test-recorder";
|
||||||
|
import type { FileObject } from "openai/resources/index";
|
||||||
|
|
||||||
describe("Batches", () => {
|
describe("Batches", () => {
|
||||||
matrix([[APIVersion.Preview]] as const, async function (apiVersion: APIVersion) {
|
matrix([[APIVersion.Preview]] as const, async function (apiVersion: APIVersion) {
|
||||||
|
@ -21,9 +27,9 @@ describe("Batches", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("all CRUD APIs", function () {
|
describe("all CRUD APIs", function () {
|
||||||
async function createBatchFile(deploymentName: string) {
|
async function createBatchFile(deploymentName: string): Promise<FileObject> {
|
||||||
const inputObject = `{ "custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": { "model": "${deploymentName}", "messages": [{ "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is 2+2?" }] } }`;
|
const inputObject = `{ "custom_id": "request-1", "method": "POST", "url": "/v1/chat/completions", "body": { "model": "${deploymentName}", "messages": [{ "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is 2+2?" }] } }`;
|
||||||
let file = await client.files.create({
|
const file = await client.files.create({
|
||||||
file: await toFile(Buffer.from(inputObject), "batch.jsonl"),
|
file: await toFile(Buffer.from(inputObject), "batch.jsonl"),
|
||||||
purpose: "batch",
|
purpose: "batch",
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,17 +5,17 @@ import { createReadStream } from "fs";
|
||||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||||
import { describe, it, beforeAll } from "vitest";
|
import { describe, it, beforeAll } from "vitest";
|
||||||
import { createClient } from "../utils/createClient.js";
|
import { createClient } from "../utils/createClient.js";
|
||||||
import OpenAI, { AzureOpenAI } from "openai";
|
import type { OpenAI, AzureOpenAI } from "openai";
|
||||||
import {
|
import {
|
||||||
APIMatrix,
|
APIMatrix,
|
||||||
APIVersion,
|
type APIVersion,
|
||||||
DeploymentInfo,
|
type DeploymentInfo,
|
||||||
getDeployments,
|
getDeployments,
|
||||||
maxRetriesOption,
|
maxRetriesOption,
|
||||||
withDeployments,
|
withDeployments,
|
||||||
} from "../utils/utils.js";
|
} from "../utils/utils.js";
|
||||||
import { assertAudioResult } from "../utils/asserts.js";
|
import { assertAudioResult } from "../utils/asserts.js";
|
||||||
import { AudioResultFormat } from "../utils/audioTypes.js";
|
import type { AudioResultFormat } from "../utils/audioTypes.js";
|
||||||
|
|
||||||
describe("OpenAI", function () {
|
describe("OpenAI", function () {
|
||||||
matrix([APIMatrix] as const, async function (apiVersion: APIVersion) {
|
matrix([APIMatrix] as const, async function (apiVersion: APIVersion) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||||
import { describe, beforeEach, it, assert, beforeAll } from "vitest";
|
import { describe, beforeEach, it, assert, beforeAll } from "vitest";
|
||||||
import { createClient } from "./utils/createClient.js";
|
import { createClient } from "./utils/createClient.js";
|
||||||
import { APIVersion, DeploymentInfo, getDeployments, withDeployments } from "./utils/utils.js";
|
import { APIVersion, type DeploymentInfo, getDeployments, withDeployments } from "./utils/utils.js";
|
||||||
import OpenAI, { AzureOpenAI } from "openai";
|
import type { OpenAI, AzureOpenAI } from "openai";
|
||||||
import { ttsModelsToSkip } from "./utils/models.js";
|
import { ttsModelsToSkip } from "./utils/models.js";
|
||||||
|
|
||||||
describe("OpenAI", function () {
|
describe("OpenAI", function () {
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
|
// Copyright (c) Microsoft Corporation.
|
||||||
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
import { assert } from "vitest";
|
import { assert } from "vitest";
|
||||||
import { get, Metadata } from "./utils.js";
|
import { get, type Metadata } from "./utils.js";
|
||||||
import { getImageDimensionsFromResponse, getImageDimensionsFromString } from "./images.js";
|
import { getImageDimensionsFromResponse, getImageDimensionsFromString } from "./images.js";
|
||||||
import {
|
import type {
|
||||||
AzureChatExtensionDataSourceResponseCitationOutput,
|
AzureChatExtensionDataSourceResponseCitationOutput,
|
||||||
AzureChatExtensionsMessageContextOutput,
|
AzureChatExtensionsMessageContextOutput,
|
||||||
ContentFilterCitedDetectionResultOutput,
|
ContentFilterCitedDetectionResultOutput,
|
||||||
|
@ -11,8 +14,8 @@ import {
|
||||||
ContentFilterResultsForChoiceOutput,
|
ContentFilterResultsForChoiceOutput,
|
||||||
ContentFilterResultsForPromptOutput,
|
ContentFilterResultsForPromptOutput,
|
||||||
} from "../../../src/types/index.js";
|
} from "../../../src/types/index.js";
|
||||||
import { Assistant, AssistantCreateParams } from "openai/resources/beta/assistants.mjs";
|
import type { Assistant, AssistantCreateParams } from "openai/resources/beta/assistants.mjs";
|
||||||
import {
|
import type {
|
||||||
Batch,
|
Batch,
|
||||||
BatchError,
|
BatchError,
|
||||||
BatchRequestCounts,
|
BatchRequestCounts,
|
||||||
|
@ -25,13 +28,13 @@ import {
|
||||||
CreateEmbeddingResponse,
|
CreateEmbeddingResponse,
|
||||||
ImagesResponse,
|
ImagesResponse,
|
||||||
} from "openai/resources/index";
|
} from "openai/resources/index";
|
||||||
import { ErrorModel } from "@azure-rest/core-client";
|
import type { ErrorModel } from "@azure-rest/core-client";
|
||||||
import {
|
import type {
|
||||||
ChatCompletion,
|
ChatCompletion,
|
||||||
ChatCompletionMessageToolCall,
|
ChatCompletionMessageToolCall,
|
||||||
} from "openai/resources/chat/completions.mjs";
|
} from "openai/resources/chat/completions.mjs";
|
||||||
import { Transcription } from "openai/resources/audio/transcriptions.mjs";
|
import type { Transcription } from "openai/resources/audio/transcriptions.mjs";
|
||||||
import { AudioSegment, AudioResultVerboseJson, AudioResultFormat } from "./audioTypes.js";
|
import type { AudioSegment, AudioResultVerboseJson, AudioResultFormat } from "./audioTypes.js";
|
||||||
|
|
||||||
export function assertAudioResult(responseFormat: AudioResultFormat, result: Transcription): void {
|
export function assertAudioResult(responseFormat: AudioResultFormat, result: Transcription): void {
|
||||||
switch (responseFormat) {
|
switch (responseFormat) {
|
||||||
|
@ -83,7 +86,7 @@ export function assertChatCompletions(
|
||||||
|
|
||||||
function assertChatCompletionsNoUsage(
|
function assertChatCompletionsNoUsage(
|
||||||
completions: ChatCompletion,
|
completions: ChatCompletion,
|
||||||
{ allowEmptyChoices, allowEmptyId, ...opts }: ChatCompletionTestOptions,
|
{ allowEmptyChoices, ...opts }: ChatCompletionTestOptions,
|
||||||
): void {
|
): void {
|
||||||
if (!allowEmptyChoices || completions.choices.length > 0) {
|
if (!allowEmptyChoices || completions.choices.length > 0) {
|
||||||
assertNonEmptyArray(completions.choices, (choice) => assertChoice(choice, opts));
|
assertNonEmptyArray(completions.choices, (choice) => assertChoice(choice, opts));
|
||||||
|
@ -93,7 +96,7 @@ function assertChatCompletionsNoUsage(
|
||||||
|
|
||||||
function assertChatCompletionsChunkNoUsage(
|
function assertChatCompletionsChunkNoUsage(
|
||||||
completions: ChatCompletionChunk,
|
completions: ChatCompletionChunk,
|
||||||
{ allowEmptyChoices, allowEmptyId, ...opts }: ChatCompletionTestOptions,
|
{ allowEmptyChoices, ...opts }: ChatCompletionTestOptions,
|
||||||
): void {
|
): void {
|
||||||
if (!allowEmptyChoices || completions.choices.length > 0) {
|
if (!allowEmptyChoices || completions.choices.length > 0) {
|
||||||
assertNonEmptyArray(completions.choices, (choice) => assertChoice(choice, opts));
|
assertNonEmptyArray(completions.choices, (choice) => assertChoice(choice, opts));
|
||||||
|
@ -220,8 +223,8 @@ function assertChoice(
|
||||||
if (stream) {
|
if (stream) {
|
||||||
const delta = (choice as ChatCompletionChunk.Choice).delta;
|
const delta = (choice as ChatCompletionChunk.Choice).delta;
|
||||||
// TODO: Relevant issue https://github.com/openai/openai-python/issues/1677
|
// TODO: Relevant issue https://github.com/openai/openai-python/issues/1677
|
||||||
ifDefined(delta, (delta) => {
|
ifDefined(delta, (d) => {
|
||||||
assertMessage(delta, options);
|
assertMessage(d, options);
|
||||||
});
|
});
|
||||||
assert.isFalse("message" in choice);
|
assert.isFalse("message" in choice);
|
||||||
} else {
|
} else {
|
||||||
|
@ -384,7 +387,7 @@ export function assertImagesWithJSON(image: ImagesResponse, height: number, widt
|
||||||
export function assertEmbeddings(
|
export function assertEmbeddings(
|
||||||
embeddings: CreateEmbeddingResponse,
|
embeddings: CreateEmbeddingResponse,
|
||||||
options?: EmbeddingTestOptions,
|
options?: EmbeddingTestOptions,
|
||||||
) {
|
): void {
|
||||||
assert.isNotNull(embeddings.data);
|
assert.isNotNull(embeddings.data);
|
||||||
assert.equal(embeddings.data.length > 0, true);
|
assert.equal(embeddings.data.length > 0, true);
|
||||||
assert.isNotNull(embeddings.data[0].embedding);
|
assert.isNotNull(embeddings.data[0].embedding);
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import { Transcription } from "openai/resources/audio/transcriptions.mjs";
|
// Copyright (c) Microsoft Corporation.
|
||||||
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
import type { Transcription } from "openai/resources/audio/transcriptions.mjs";
|
||||||
|
|
||||||
export type AudioResultFormat = "json" | "verbose_json" | "text" | "srt" | "vtt";
|
export type AudioResultFormat = "json" | "verbose_json" | "text" | "srt" | "vtt";
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Recorder,
|
Recorder,
|
||||||
RecorderStartOptions,
|
type RecorderStartOptions,
|
||||||
TestInfo,
|
type TestInfo,
|
||||||
assertEnvironmentVariable,
|
assertEnvironmentVariable,
|
||||||
} from "@azure-tools/test-recorder";
|
} from "@azure-tools/test-recorder";
|
||||||
import OpenAI, { AzureClientOptions, AzureOpenAI } from "openai";
|
import OpenAI, { type AzureClientOptions, AzureOpenAI } from "openai";
|
||||||
import { getBearerTokenProvider } from "@azure/identity";
|
import { getBearerTokenProvider } from "@azure/identity";
|
||||||
import {
|
import {
|
||||||
EnvironmentVariableNames,
|
EnvironmentVariableNames,
|
||||||
|
@ -15,7 +15,7 @@ import {
|
||||||
EnvironmentVariableNamesForVision,
|
EnvironmentVariableNamesForVision,
|
||||||
EnvironmentVariableNamesForAudio,
|
EnvironmentVariableNamesForAudio,
|
||||||
} from "./envVars.js";
|
} from "./envVars.js";
|
||||||
import { APIVersion, DeploymentType } from "./utils.js";
|
import { APIVersion, type DeploymentType } from "./utils.js";
|
||||||
import { createTestCredential } from "@azure-tools/test-credential";
|
import { createTestCredential } from "@azure-tools/test-credential";
|
||||||
|
|
||||||
const scope = "https://cognitiveservices.azure.com/.default";
|
const scope = "https://cognitiveservices.azure.com/.default";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
import { PipelineResponse } from "@azure/core-rest-pipeline";
|
import type { PipelineResponse } from "@azure/core-rest-pipeline";
|
||||||
|
|
||||||
interface Dimensions {
|
interface Dimensions {
|
||||||
width: number;
|
width: number;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) Microsoft Corporation.
|
// Copyright (c) Microsoft Corporation.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
import { PipelineResponse } from "@azure/core-rest-pipeline";
|
import type { PipelineResponse } from "@azure/core-rest-pipeline";
|
||||||
|
|
||||||
export interface Dimensions {
|
export interface Dimensions {
|
||||||
width: number;
|
width: number;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
import { afterAll, beforeAll, inject } from "vitest";
|
import { afterAll, beforeAll, inject } from "vitest";
|
||||||
import { AzureLogLevel, setLogLevel } from "@azure/logger";
|
import { type AzureLogLevel, setLogLevel } from "@azure/logger";
|
||||||
|
|
||||||
const logLevel = inject("AZURE_LOG_LEVEL") as AzureLogLevel;
|
const logLevel = inject("AZURE_LOG_LEVEL") as AzureLogLevel;
|
||||||
const localStorage: { debug?: string } = {};
|
const localStorage: { debug?: string } = {};
|
||||||
|
|
|
@ -6,10 +6,10 @@ enum EnvVarKeys {
|
||||||
AZURE_LOG_LEVEL = "AZURE_LOG_LEVEL",
|
AZURE_LOG_LEVEL = "AZURE_LOG_LEVEL",
|
||||||
}
|
}
|
||||||
declare module "vitest" {
|
declare module "vitest" {
|
||||||
type MyEnvVarKeys = {
|
type MyEnvVarKey = {
|
||||||
[K in keyof typeof EnvVarKeys]: string;
|
[K in keyof typeof EnvVarKeys]: string;
|
||||||
};
|
};
|
||||||
export interface ProvidedContext extends MyEnvVarKeys {}
|
export interface ProvidedContext extends MyEnvVarKey {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultLogLevel = "info";
|
const defaultLogLevel = "info";
|
||||||
|
@ -28,7 +28,7 @@ function assertEnvironmentVariable(key: string): string {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function ({ provide }: GlobalSetupContext) {
|
export default async function ({ provide }: GlobalSetupContext): Promise<() => void> {
|
||||||
for (const key of Object.values(EnvVarKeys)) {
|
for (const key of Object.values(EnvVarKeys)) {
|
||||||
provide(key, assertEnvironmentVariable(key));
|
provide(key, assertEnvironmentVariable(key));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
import { assert } from "vitest";
|
import { assert } from "vitest";
|
||||||
import {
|
import {
|
||||||
PipelineRequest,
|
type PipelineRequest,
|
||||||
PipelineResponse,
|
type PipelineResponse,
|
||||||
RestError,
|
RestError,
|
||||||
createDefaultHttpClient,
|
createDefaultHttpClient,
|
||||||
createEmptyPipeline,
|
createEmptyPipeline,
|
||||||
|
@ -21,9 +21,9 @@ import {
|
||||||
EnvironmentVariableNamesForVision,
|
EnvironmentVariableNamesForVision,
|
||||||
EnvironmentVariableNamesForAudio,
|
EnvironmentVariableNamesForAudio,
|
||||||
} from "./envVars.js";
|
} from "./envVars.js";
|
||||||
import { Run } from "openai/resources/beta/threads/runs/runs.mjs";
|
import type { Run } from "openai/resources/beta/threads/runs/runs.mjs";
|
||||||
import { createClientLogger } from "@azure/logger";
|
import { createClientLogger } from "@azure/logger";
|
||||||
import { AzureChatExtensionConfiguration } from "../../../src/types/models.js";
|
import type { AzureChatExtensionConfiguration } from "../../../src/types/models.js";
|
||||||
|
|
||||||
const logger = createClientLogger("openai");
|
const logger = createClientLogger("openai");
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ import { createClient } from "./utils/createClient.js";
|
||||||
import { assertChatCompletions } from "./utils/asserts.js";
|
import { assertChatCompletions } from "./utils/asserts.js";
|
||||||
import {
|
import {
|
||||||
APIMatrix,
|
APIMatrix,
|
||||||
APIVersion,
|
type APIVersion,
|
||||||
DeploymentInfo,
|
type DeploymentInfo,
|
||||||
getDeployments,
|
getDeployments,
|
||||||
withDeployments,
|
withDeployments,
|
||||||
} from "./utils/utils.js";
|
} from "./utils/utils.js";
|
||||||
import OpenAI, { AzureOpenAI } from "openai";
|
import type { OpenAI, AzureOpenAI } from "openai";
|
||||||
import { logger } from "@azure/identity";
|
import { logger } from "@azure/identity";
|
||||||
import { RestError } from "@azure/core-rest-pipeline";
|
import { RestError } from "@azure/core-rest-pipeline";
|
||||||
import { visionModelsToSkip } from "./utils/models.js";
|
import { visionModelsToSkip } from "./utils/models.js";
|
||||||
|
|
Загрузка…
Ссылка в новой задаче