Skip to content
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
2 changes: 1 addition & 1 deletion ts/examples/workflow/engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"tsc": "tsc -b"
},
"dependencies": {
"@github/copilot-sdk": "^0.3.0",
"@github/copilot-sdk": "^1.0.5",
"@typeagent/aiclient": "workspace:*",
"ajv": "^8.17.1",
"debug": "^4.3.4",
Expand Down
9 changes: 8 additions & 1 deletion ts/examples/workflow/engine/test/copilotInvoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ class MockSession implements MinimalCopilotSession {
) {
this.sessionId = `mock-${Math.random().toString(36).slice(2, 8)}`;
}
async sendAndWait(opts: MessageOptions, timeout?: number) {
async sendAndWait(
promptOrOptions: string | MessageOptions,
timeout?: number,
) {
const opts: MessageOptions =
typeof promptOrOptions === "string"
? { prompt: promptOrOptions }
: promptOrOptions;
this.sentPrompts.push(opts.prompt);
this.sentTimeouts.push(timeout);
const script = this.nextScript();
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/aiclient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@azure/identity": "^4.10.0",
"@github/copilot-sdk": "0.2.0",
"@github/copilot-sdk": "1.0.5",
"@huggingface/transformers": "^3.8.1",
"@typeagent/config": "workspace:*",
"async": "^3.2.5",
Expand Down
3 changes: 2 additions & 1 deletion ts/packages/aiclient/src/apiSettingsFromConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import {
createAzureTokenProvider,
} from "./auth.js";
import type { AzureApiSettings } from "./azureSettings.js";
import { ApiSettings, ModelType } from "./openai.js";
import { ModelType } from "./apiTypes.js";
import type { ApiSettings } from "./openai.js";
import type { OpenAIApiSettings } from "./openaiSettings.js";

const azureTokenProvider = createAzureTokenProvider(
Expand Down
78 changes: 78 additions & 0 deletions ts/packages/aiclient/src/apiTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Foundational, dependency-free API types shared across the aiclient
// provider modules. Kept in a leaf module (no intra-package imports) so that
// openai.ts and the provider/settings modules can share these enums and types
// without importing each other, which would form circular dependencies.

export enum ModelType {
Chat = "chat",
Embedding = "embedding",
Image = "image",
Video = "video",
}

export type ModelInfo<T> = {
type: ModelType;
model: T;
endpointName?: string;
maxTokens: number;
};

export type ModelProviders = "openai" | "azure" | "ollama" | "copilot";

export type CompletionUsageStats = {
// Number of tokens in the generated completion
completion_tokens: number;
// Number of tokens in the prompt
prompt_tokens: number;
// Total tokens (prompt + completion)
total_tokens: number;
};

/**
* Environment variables used to configure OpenAI clients
*/
export enum EnvVars {
OPENAI_API_KEY = "OPENAI_API_KEY",
OPENAI_ENDPOINT = "OPENAI_ENDPOINT",
OPENAI_ENDPOINT_EMBEDDING = "OPENAI_ENDPOINT_EMBEDDING",

OPENAI_ORGANIZATION = "OPENAI_ORGANIZATION",
OPENAI_MODEL = "OPENAI_MODEL",
OPENAI_RESPONSE_FORMAT = "OPENAI_RESPONSE_FORMAT",
OPENAI_MAX_CONCURRENCY = "AZURE_OPENAI_MAX_CONCURRENCY",
OPENAI_MAX_TIMEOUT = "OPENAI_MAX_TIMEOUT",
OPENAI_MAX_RETRYATTEMPTS = "OPENAI_MAX_RETRYATTEMPTS",
OPENAI_MODEL_EMBEDDING = "OPENAI_MODEL_EMBEDDING",

AZURE_OPENAI_API_KEY = "AZURE_OPENAI_API_KEY",
AZURE_OPENAI_ENDPOINT = "AZURE_OPENAI_ENDPOINT",
AZURE_OPENAI_RESPONSE_FORMAT = "AZURE_OPENAI_RESPONSE_FORMAT",
AZURE_OPENAI_MAX_CONCURRENCY = "AZURE_OPENAI_MAX_CONCURRENCY",
AZURE_OPENAI_MAX_TIMEOUT = "AZURE_OPENAI_MAX_TIMEOUT",
AZURE_OPENAI_MAX_RETRYATTEMPTS = "AZURE_OPENAI_MAX_RETRYATTEMPTS",
AZURE_OPENAI_MAX_CHARS = "AZURE_OPENAI_MAX_CHARS",

AZURE_OPENAI_API_KEY_EMBEDDING = "AZURE_OPENAI_API_KEY_EMBEDDING",
AZURE_OPENAI_ENDPOINT_EMBEDDING = "AZURE_OPENAI_ENDPOINT_EMBEDDING",

AZURE_OPENAI_API_KEY_GPT_IMAGE_1_5 = "AZURE_OPENAI_API_KEY_GPT_IMAGE_1_5",
AZURE_OPENAI_ENDPOINT_GPT_IMAGE_1_5 = "AZURE_OPENAI_ENDPOINT_GPT_IMAGE_1_5",
// Generic fallback for any current/future image model
AZURE_OPENAI_API_KEY_GPT_IMAGE = "AZURE_OPENAI_API_KEY_GPT_IMAGE",
AZURE_OPENAI_ENDPOINT_GPT_IMAGE = "AZURE_OPENAI_ENDPOINT_GPT_IMAGE",
AZURE_OPENAI_API_KEY_SORA_2 = "AZURE_OPENAI_API_KEY_SORA_2",
AZURE_OPENAI_ENDPOINT_SORA_2 = "AZURE_OPENAI_ENDPOINT_SORA_2",

OLLAMA_ENDPOINT = "OLLAMA_ENDPOINT",

AZURE_MAPS_ENDPOINT = "AZURE_MAPS_ENDPOINT",
AZURE_MAPS_CLIENTID = "AZURE_MAPS_CLIENTID",

ENABLE_MODEL_REQUEST_LOGGING = "ENABLE_MODEL_REQUEST_LOGGING",

AZURE_STORAGE_ACCOUNT = "AZURE_STORAGE_ACCOUNT",
AZURE_STORAGE_CONTAINER = "AZURE_STORAGE_CONTAINER",
}
3 changes: 2 additions & 1 deletion ts/packages/aiclient/src/azureSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
createAzureTokenProvider,
} from "./auth.js";
import { getEnvSetting, getIntFromEnv } from "./common.js";
import { CommonApiSettings, EnvVars, ModelType } from "./openai.js";
import { EnvVars, ModelType } from "./apiTypes.js";
import type { CommonApiSettings } from "./openai.js";
import { azureApiSettingsFromConfig } from "./apiSettingsFromConfig.js";
import { getRuntimeConfig } from "./runtimeConfig.js";
import registerDebug from "debug";
Expand Down
Loading
Loading