Skip to content
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

[OpenAI] Precise Typechecking #31786

Merged
merged 13 commits into from
Nov 20, 2024
Merged
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
4 changes: 2 additions & 2 deletions sdk/openai/openai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ There are several ways to authenticate with the Azure OpenAI service and the rec

2. Create a token provider by calling the `getBearerTokenProvider` with the desired credential type. For example, [DefaultAzureCredential][azure_identity_dac]:

```js
```ts
import { DefaultAzureCredential, getBearerTokenProvider } from "@azure/identity";

const credential = new DefaultAzureCredential();
Expand All @@ -56,7 +56,7 @@ There are several ways to authenticate with the Azure OpenAI service and the rec

3. Create the client by passing in the token provider:

```js
```ts
import { AzureOpenAI } from "openai";

const deployment = "Your deployment name";
Expand Down
4 changes: 1 addition & 3 deletions sdk/openai/openai/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
"reportFolder": "./review"
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "dist/openai.d.ts"
"enabled": false
},
"messages": {
"tsdocMessageReporting": {
Expand Down
20 changes: 13 additions & 7 deletions sdk/openai/openai/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
export default [
...azsdkEslint.configs.recommended,
{
rules: {
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
"@azure/azure-sdk/ts-package-json-module": "off",
"@azure/azure-sdk/ts-package-json-main-is-cjs": "off",
"@azure/azure-sdk/ts-package-json-types": "off",
"@azure/azure-sdk/ts-package-json-files-required": "off",
"no-restricted-imports": "warn",
files: ["**/*.ts", "**/*.cts", "**/*.mts"],
languageOptions: {
parserOptions: {
project: ["./tsconfig.src.json", "./tsconfig.tests.json"],
},
},
},
{
files: ["*.md/*.ts"],
minhanh-phan marked this conversation as resolved.
Show resolved Hide resolved
languageOptions: {
parserOptions: {
project: null,
},
},
},
];
5 changes: 3 additions & 2 deletions sdk/openai/openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"LICENSE"
],
"tshy": {
"project": "./tsconfig.src.json",
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts",
Expand All @@ -69,8 +70,8 @@
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"integration-test:browser": "dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --no-test-proxy --browser",
"integration-test:node": "dev-tool run test:vitest --no-test-proxy",
"lint": "eslint README.md package.json api-extractor.json src",
"lint:fix": "eslint README.md package.json api-extractor.json src --fix --fix-type [problem,suggestion]",
"lint": "eslint README.md package.json api-extractor.json src test",
"lint:fix": "eslint README.md package.json api-extractor.json src test --fix --fix-type [problem,suggestion]",
"pack": "npm pack 2>&1",
"test": "npm run clean && dev-tool run build-package && npm run unit-test:node && dev-tool run build-test && npm run unit-test:browser && npm run integration-test",
"test:browser": "npm run clean && npm run build:test && npm run integration-test:browser",
Expand Down
2 changes: 1 addition & 1 deletion sdk/openai/openai/test/public/completions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from "./utils/utils.js";
import { type ChatCompletionMessageParam } from "openai/resources/chat/completions.mjs";
import { completionsModelsToSkip, functionCallModelsToSkip } from "./utils/models.js";
import "../../src/types/index.js";
import "@azure/openai/types";

describe("Completions", function () {
let deployments: DeploymentInfo[] = [];
Expand Down
2 changes: 1 addition & 1 deletion sdk/openai/openai/test/public/utils/asserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
ContentFilterResultDetailsForPromptOutput,
ContentFilterResultsForChoiceOutput,
ContentFilterResultsForPromptOutput,
} from "../../../src/types/index.js";
} from "@azure/openai/types";
import type { Assistant, AssistantCreateParams } from "openai/resources/beta/assistants.mjs";
import type {
Batch,
Expand Down
2 changes: 1 addition & 1 deletion sdk/openai/openai/test/public/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from "./envVars.js";
import type { Run } from "openai/resources/beta/threads/runs/runs.mjs";
import { createClientLogger } from "@azure/logger";
import type { AzureChatExtensionConfiguration } from "../../../src/types/models.js";
import type { AzureChatExtensionConfiguration } from "@azure/openai/types";

const logger = createClientLogger("openai");

Expand Down
6 changes: 2 additions & 4 deletions sdk/openai/openai/tsconfig.browser.config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"extends": "./.tshy/build.json",
"extends": ["./.tshy/build.json", "./tsconfig.tests.json"],
"include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.ts", "./test/**/*.mts"],
"exclude": ["./test/**/node/**/*.ts"],
"compilerOptions": {
"outDir": "./dist-test/browser",
"lib": ["DOM"],
"rootDir": ".",
"skipLibCheck": true
"composite": true
}
}
23 changes: 6 additions & 17 deletions sdk/openai/openai/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"paths": {
"@azure/openai": ["./src/index.js"]
},
"module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": "."
},
"exclude": ["./samples/**/*.ts"],
"include": [
"./src/**/*.ts",
"./src/**/*.mts",
"./src/**/*.cts",
"./samples-dev/**/*.ts",
"./test/**/*.ts",
"./test/**/*.mts"
]
"references": [
{ "path": "./tsconfig.src.json" },
{ "path": "./tsconfig.samples.json" },
{ "path": "./tsconfig.tests.json" }
],
"files": []
}
14 changes: 14 additions & 0 deletions sdk/openai/openai/tsconfig.samples.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"target": "ES2023",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"paths": {
"@azure/openai": ["./dist/esm/index.js"]
},
"noEmit": true,
"composite": true
},
"include": ["./samples-dev"]
}
9 changes: 9 additions & 0 deletions sdk/openai/openai/tsconfig.src.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"composite": true
},
"include": ["./src"]
}
13 changes: 13 additions & 0 deletions sdk/openai/openai/tsconfig.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../../tsconfig",
"compilerOptions": {
"target": "ES2023",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"lib": ["DOM"],
"skipLibCheck": true,
"noEmit": true,
"composite": true
},
"include": ["./test"]
}
5 changes: 5 additions & 0 deletions sdk/openai/openai/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export default mergeConfig(
hookTimeout: 25000,
fileParallelism: false,
include: ["test/public/**/*.spec.ts"],
typecheck: {
enabled: true,
tsconfig: "tsconfig.tests.json",
include: ["test/**/*.ts", "test/**/*.mts", "test/**/*.cts"]
}
},
}),
);
Loading