{"id":13564786,"url":"https://github.com/kyang6/llmparser","last_synced_at":"2025-04-03T21:31:45.700Z","repository":{"id":148776431,"uuid":"619973796","full_name":"kyang6/llmparser","owner":"kyang6","description":"Classify and extract structured data with LLMs","archived":false,"fork":false,"pushed_at":"2023-07-20T09:10:33.000Z","size":682,"stargazers_count":425,"open_issues_count":6,"forks_count":26,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-08T15:48:59.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://llmparser.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kyang6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-03-27T19:28:50.000Z","updated_at":"2025-02-18T16:06:29.000Z","dependencies_parsed_at":"2024-01-14T03:48:53.641Z","dependency_job_id":"0d8b08ba-6bc7-485d-a975-164b35d79efb","html_url":"https://github.com/kyang6/llmparser","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyang6%2Fllmparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyang6%2Fllmparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyang6%2Fllmparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyang6%2Fllmparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyang6","download_url":"https://codeload.github.com/kyang6/llmparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247083687,"owners_count":20880892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:01:35.857Z","updated_at":"2025-04-03T21:31:45.031Z","avatar_url":"https://github.com/kyang6.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# 🏷 LLMParser\n\nLLMParser is a simple and flexible tool to classify and extract structured data from text with large language models.\n\n📖 Full documentation available [here](https://llmparser.com)\n\n[![npm package][npm-img]][npm-url]\n[![Build Status][build-img]][build-url]\n\n## Why?\n\nWhile LLMs are extremely powerful, producing reliable JSON output is challenging.\n\nLLMParser aims to solve this by enforcing a consistent JSON input and output format for classifying and extracting text with LLMs.\n\n## What can you do?\n\nLLMParser is a fairly general purpose tool. You can use it to extract job titles from LinkedIn profiles, dishes from restaurant menus, or even classify reviews as positive or negative. Here are some more examples:\n\n- Extracting name, school, current job title from resumes\n- Classifying corporate contracts as NDA, MSA, etc. and extracting important fields like effective date and counterparty name\n- Extracting place names from Apple Notes\n\n## Install\n\n```bash\nnpm install llmparser\n```\n\n## Usage\n\nQuick note: this library is meant for server-side usage, as using it in client-side browser code will expose your secret API key. Go [here](https://platform.openai.com/docs/api-reference/authentication) to get an OpenAI API key.\n\n```ts\nimport { LLMParser } from llmparser;\n\nconst categories = [\n  {\n    name: \"MSA\",\n    description: \"Master service agreement\",\n  },\n  {\n    name: \"NDA\",\n    description: \"Non disclosure agreement\",\n    fields: [\n      {\n        name: \"effective_date\",\n        description: \"effective date or start date\", // instruction for LLM\n        type: \"string\"\n      },\n      {\n        name: \"company\",\n        description: \"name of the company\",\n        type: \"string\"\n      },\n      {\n        name: \"counterparty\",\n        description: \"name of the counterparty\",\n        type: \"string\"\n      }\n    ]\n  }\n]\n\nconst parser = new LLMParser({\n  categories,\n  apiKey: process.env.OPENAI_API_KEY\n})\n\nconst ndaText = await loadPDFAsText(\"src/nda.pdf\") // get text of PDF\nconst extraction = await parser.parse(ndaText);\n```\n\nClassified as an NDA and extracted 3 fields.\n\n```json\n{\n  \"type\": \"NDA\",\n  \"confidence\": 1,\n  \"source\": \"This is a Mutual Non-Disclosure Agreement (this “Agreement”), effective as of the date stated below (the “Effective Date”), between Technology Research Corporation, a Florida corporation (the “Company”), and Kevin Yang (the “Counterparty”).\",\n  \"fields\": {\n    \"effective_date\": {\n        \"value\": \"2022-01-11T06:00:00.000Z\",\n        \"source\": \"Effective date of January 11, 2022\",\n        \"confidence\": 1\n    },\n    \"company\": {\n        \"value\": \"Technology Research Corporation\",\n        \"source\": \"between Technology Research Corporation, a Florida corporation\",\n        \"confidence\": 0.9\n    },\n    \"counterparty\": {\n        \"value\": \"Kevin Yang\",\n        \"source\": \"and Kevin Yang (the “Counterparty”)\",\n        \"confidence\": 0.9\n    }\n  }\n}\n```\n\n[build-img]:https://github.com/kyang6/llmparser/actions/workflows/release.yml/badge.svg\n[build-url]:https://github.com/kyang6/llmparser/actions/workflows/release.yml\n[npm-img]:https://img.shields.io/npm/v/llmparser\n[npm-url]:https://www.npmjs.com/package/llmparser\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyang6%2Fllmparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyang6%2Fllmparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyang6%2Fllmparser/lists"}