@letsrunit/ai
v0.1.0
Published
AI integration for test generation with letsrunit
Readme
AI Package (@letsrunit/ai)
Installation
npm install @letsrunit/ai
# or
yarn add @letsrunit/aiProvides AI-driven capabilities for the letsrunit platform, leveraging the AI SDK. It serves as a unified interface for generating text or structured objects using LLMs.
Exported Functions
generate<T>(system, prompt, opts)
The primary function for interacting with LLMs. It supports both text generation and structured object generation (via Zod schemas).
system: The system prompt. Can be a string or a template object{ template: string; vars: object }(rendered using Mustache).prompt: The user prompt (string) or an array ofModelMessage.opts:model:'large' | 'medium' | 'small'(defaults tomedium).reasoningEffort:'minimal' | 'low' | 'medium'(defaults tolow).schema: A Zod schema. If provided,generatereturns a typed object.tools: A set of AI SDK tools (cannot be used withschema).abortSignal: AnAbortSignalto cancel the request.
translate<T>(input, lang, options)
Translates text or JSON objects from English to a target language.
input: A string or a JSON-serializable value.lang: Target language code (e.g.,'nl','fr').options:cache: An optionalcache-managerinstance to cache translations.prompt: An optional custom translation prompt.reasoningEffort: LLM reasoning effort level.
Environment Variables
OPENAI_API_KEYTOGETHER_AI_API_KEY
LangSmith tracing (optional)
LANGSMITH_TRACINGLANGSMITH_WORKSPACE_IDLANGSMITH_API_KEYLANGSMITH_ENDPOINT
Testing
Run tests for this package:
yarn test