feat(types): add llm types

This commit is contained in:
ItzCrazyKns
2025-11-18 14:39:43 +05:30
parent 4bcbdad6cb
commit f44ad973aa
2 changed files with 57 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
import z from 'zod';
type Model = { type Model = {
name: string; name: string;
key: string; key: string;
@@ -25,10 +27,59 @@ type ModelWithProvider = {
providerId: string; providerId: string;
}; };
type GenerateOptions = {
temperature?: number;
maxTokens?: number;
topP?: number;
stopSequences?: string[];
frequencyPenalty?: number;
presencePenalty?: number;
};
type GenerateTextInput = {
messages: Message[];
options?: GenerateOptions;
};
type GenerateTextOutput = {
content: string;
additionalInfo?: Record<string, any>;
};
type StreamTextOutput = {
contentChunk: string;
additionalInfo?: Record<string, any>;
done?: boolean;
};
type GenerateObjectInput = {
schema: z.ZodTypeAny;
messages: Message[];
options?: GenerateOptions;
};
type GenerateObjectOutput<T> = {
object: T;
additionalInfo?: Record<string, any>;
};
type StreamObjectOutput<T> = {
objectChunk: Partial<T>;
additionalInfo?: Record<string, any>;
done?: boolean;
};
export type { export type {
Model, Model,
ModelList, ModelList,
ProviderMetadata, ProviderMetadata,
MinimalProvider, MinimalProvider,
ModelWithProvider, ModelWithProvider,
GenerateOptions,
GenerateTextInput,
GenerateTextOutput,
StreamTextOutput,
GenerateObjectInput,
GenerateObjectOutput,
StreamObjectOutput,
}; };

View File

@@ -1,9 +1,9 @@
type Message = { type Message = {
role: 'user' | 'assistant' | 'system'; role: 'user' | 'assistant' | 'system';
content: string; content: string;
} };
type Chunk = { type Chunk = {
content: string; content: string;
metadata: Record<string, any>; metadata: Record<string, any>;
} };