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

Added Generics to the Contexts in the Typescript SDK models #73

Merged
merged 3 commits into from
Sep 19, 2024
Merged
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
32 changes: 22 additions & 10 deletions sdk/js/packages/client/src/model/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,50 @@ import { ClientOptions, OperationOptions } from "@typespec/ts-http-runtime";

export type AIChatRole = "user" | "assistant" | "system";

type GenericContext = Record<string, unknown>;

export interface AIChatFile {
contentType: string;
data: Uint8Array | File | Buffer;
}

export interface AIChatMessage {
export interface AIChatMessage<
ContextType extends GenericContext = GenericContext,
> {
role: AIChatRole;
content: string;
context?: object;
context?: ContextType;
files?: AIChatFile[];
}

export interface AIChatMessageDelta {
export interface AIChatMessageDelta<
ContextType extends GenericContext = GenericContext,
> {
role?: AIChatRole;
content?: string;
context?: object;
context?: ContextType;
}

export interface AIChatCompletion {
export interface AIChatCompletion<
ContextType extends GenericContext = GenericContext,
> {
message: AIChatMessage;
sessionState?: unknown;
context?: object;
context?: ContextType;
}

export interface AIChatCompletionDelta {
export interface AIChatCompletionDelta<
ContextType extends GenericContext = GenericContext,
> {
delta: AIChatMessageDelta;
sessionState?: unknown;
context?: object;
context?: ContextType;
}

export interface AIChatCompletionOptions {
context?: object;
export interface AIChatCompletionOptions<
ContextType extends GenericContext = GenericContext,
> {
context?: ContextType;
sessionState?: unknown;
}

Expand Down