vern-llm 1.7.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,6 @@
13
13
  <p align="center">
14
14
  <a href="https://www.npmjs.com/package/vern-llm"><img src="https://img.shields.io/npm/v/vern-llm.svg" alt="npm version" /></a>
15
15
  <a href="https://www.npmjs.com/package/vern-llm"><img src="https://img.shields.io/npm/dm/vern-llm.svg" alt="npm downloads" /></a>
16
- <a href="https://bundlephobia.com/package/vern-llm"><img src="https://img.shields.io/bundlephobia/minzip/vern-llm.svg" alt="bundle size" /></a>
17
16
  <a href="https://github.com/LakBud/vernLLM/actions/workflows/test.yml"><img src="https://github.com/LakBud/vernLLM/actions/workflows/test.yml/badge.svg" alt="test status" /></a>
18
17
  <a href="https://github.com/LakBud/vernLLM/blob/main/LICENSE.md"><img src="https://img.shields.io/npm/l/vern-llm.svg" alt="license" /></a>
19
18
  <img src="https://img.shields.io/node/v/vern-llm.svg" alt="node version" />
@@ -46,21 +45,41 @@ const llm = new VernLLM({
46
45
  circuitBreaker: true,
47
46
  });
48
47
 
49
- const result = await llm.call({
50
- systemPrompt: 'Return JSON: { "skills": string[] }',
51
- userContent: 'Extract skills from: ...',
48
+ const getWeather = {
49
+ name: 'get_weather',
50
+ description: 'Gets the current weather for a city',
51
+ parameters: { type: 'object', properties: { city: { type: 'string' } }, required: ['city'] },
52
+ };
53
+
54
+ const { chunks, finalResult } = await llm.cachedCall({
55
+ cacheKey: 'weather-demo-001',
56
+ ttl: 60,
57
+ call: {
58
+ userContent: "What's the weather in New York?",
59
+ tools: [getWeather],
60
+ stream: true,
61
+ },
52
62
  });
63
+
64
+ for await (const chunk of chunks) {
65
+ if (chunk.type === 'text-delta') process.stdout.write(chunk.delta);
66
+ }
67
+
68
+ const result = await finalResult; // cached, retried, and streamed, tool calls included
53
69
  ```
54
70
 
55
71
  ## Why vern-llm?
56
72
 
57
73
  - **Retries with backoff**: transient failures retry automatically; validation errors and non-retryable status codes fail fast instead
58
74
  - **Structured output**: pass a Zod schema, get a typed, validated result back
75
+ - **Tool calling**: pass `tools`, vern-llm handles retries and validation around them the same as any other call; you run the tools and continue the conversation
76
+ - **Streaming**: set `stream: true` on any call and get live chunks alongside the same validated result the call would otherwise resolve to
59
77
  - **Provider-native JSON Schema mode**: constrain generation itself, not just validate after the fact
60
- - **Caching**: wrap any call with `cachedCall`/`cachedLLMCall`, bring your own cache adapter
78
+ - **Caching**: wrap any LLM call with `cachedCall`, bring your own cache adapter
61
79
  - **Circuit breaker**: trips after repeated failures, recovers automatically once the provider's back
80
+ - **Usage tracking**: `onUsage` and `onUsageFailure` report token spend on success and on failure, so nothing goes unaccounted for when a call fails after the provider already responded
62
81
  - **One interface, every provider**: OpenAI, Groq, Mistral, DeepSeek, Cerebras, Together, Fireworks, Ollama, Anthropic, Gemini, Bedrock, or raw HTTP via `fromFetch`
63
- - **Zero bundled deps**: `zod` and provider SDKs are peer dependencies; this package only relies on their shapes structurally
82
+ - **Zero runtime dependencies**: `zod` and provider SDKs are not required dependencies; vern-llm relies on compatible interfaces rather than specific implementations.
64
83
 
65
84
  See the [docs](https://vernllm.vercel.app) for adapter setup, caching, the circuit breaker, and structured output in depth.
66
85