Skip to content

A TypeScript-based parser implementation that uses Zod for schema validation with retries to force an LLM to return a structured output.

Notifications You must be signed in to change notification settings

inferablehq/ollama-structured-outputs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Parser Project

A TypeScript-based parser implementation that uses Zod for schema validation with retries to force an LLM to return a structured output. Uses Ollama as the LLM provider with llama3.2. This is a companion project to the Adding structured outputs as a feature to any LLM blog post.

Prerequisites

  • Node.js and npm installed
  • Ollama running locally with the llama3.2 model

Setup

  1. Install dependencies:
npm install

Usage

tsx index.ts

This should return a JSON object with a movie recommendation.

{
  "title": "The Shawshank Redemption",
  "year": 1994,
  "rating": 9,
  "genres": ["Drama", "Thriller"]
}

License

This project is licensed under the MIT License.

About

A TypeScript-based parser implementation that uses Zod for schema validation with retries to force an LLM to return a structured output.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published