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 = {
name: string;
key: string;
@@ -25,10 +27,59 @@ type ModelWithProvider = {
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 {
Model,
ModelList,
ProviderMetadata,
MinimalProvider,
ModelWithProvider,
GenerateOptions,
GenerateTextInput,
GenerateTextOutput,
StreamTextOutput,
GenerateObjectInput,
GenerateObjectOutput,
StreamObjectOutput,
};

View File

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