@triplef/ai-sdk
v1.0.1
Published
A NestJS module for the Vercel AI SDK with Ollama — streaming/generation clients, model catalog, and warm-up.
Downloads
149
Readme
@triplef/ai-sdk
A NestJS module for the Vercel AI SDK with Ollama — streaming and generation clients, model catalog, and model warm-up.
This library is **ESM-only** and does not support CommonJS.Your project must use ES modules.
StatusBadges
DevDependencies
PeerDependencies
Features
- NestJS-native — a dynamic module (
registerAsync) wiring the AI SDK services to caller-suppliedAiSdkConfig. - Streaming & generation —
streamChat,generateChat,compactContent, andgenerateWithToolsbacked byollama-ai-provider-v2.
Installation
pnpm add @triplef/ai-sdkUsage
Module setup
The library ships no env-driven config — supply the AiSdkConfig through a
factory, and validate it with the exported AiSdkConfigSchema.
import { AiSdkModule, AiSdkConfigSchema } from '@triplef/ai-sdk';
import { ValidateReturnValue } from '@triplef/config-factory/validate-return-value';
@Module({
imports: [
AiSdkModule.registerAsync({
global: true,
inject: [MyAiSdkConfigService],
useFactory: (config: MyAiSdkConfigService) => config.options,
}),
],
})
export class AppModule {}Streaming a chat
import { AiSdkService } from '@triplef/ai-sdk';
@Injectable()
export class ChatService {
constructor(private readonly aiSdk: AiSdkService) {}
async stream(messages: InputMessage[]) {
return this.aiSdk.streamChat({ model: 'llama3.2', messages });
}
}