{"id":25694084,"url":"https://github.com/algunion/describedtypes.jl","last_synced_at":"2026-02-17T17:02:56.941Z","repository":{"id":276495198,"uuid":"929453562","full_name":"algunion/DescribedTypes.jl","owner":"algunion","description":"LLM-friendly annotated Julia types.","archived":false,"fork":false,"pushed_at":"2026-02-14T14:44:09.000Z","size":255,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-14T22:34:07.170Z","etag":null,"topics":["julia","julialang","llms","structured-output"],"latest_commit_sha":null,"homepage":"","language":"Julia","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/algunion.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-08T15:34:35.000Z","updated_at":"2026-02-14T14:35:21.000Z","dependencies_parsed_at":"2025-02-08T16:32:35.552Z","dependency_job_id":"c2915f76-ed05-4f4d-afc5-5f01ccd92a62","html_url":"https://github.com/algunion/DescribedTypes.jl","commit_stats":null,"previous_names":["algunion/describedtypes.jl"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/algunion/DescribedTypes.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algunion%2FDescribedTypes.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algunion%2FDescribedTypes.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algunion%2FDescribedTypes.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algunion%2FDescribedTypes.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/algunion","download_url":"https://codeload.github.com/algunion/DescribedTypes.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algunion%2FDescribedTypes.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29548208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T14:33:00.708Z","status":"ssl_error","status_checked_at":"2026-02-17T14:32:58.657Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["julia","julialang","llms","structured-output"],"created_at":"2025-02-24T23:50:08.171Z","updated_at":"2026-02-17T17:02:56.935Z","avatar_url":"https://github.com/algunion.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DescribedTypes\n\n[![Build Status](https://github.com/algunion/DescribedTypes.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/algunion/DescribedTypes.jl/actions/workflows/CI.yml?query=branch%3Amain)\n[![codecov](https://codecov.io/gh/algunion/DescribedTypes.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/algunion/DescribedTypes.jl)\n[![Stable Docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://algunion.github.io/DescribedTypes.jl/stable/)\n[![Dev Docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://algunion.github.io/DescribedTypes.jl/dev/)\n\nThis package provides a way to annotate Julia types with descriptions, which are\nthen used to generate JSON Schemas compatible with LLM provider APIs (for\nstructured-output functionality).\n\nOpenAI uses JSON Schema in two different places, and the package supports both:\n\n- **`OPENAI`** — for [structured output via `response_format`](https://developers.openai.com/api/docs/guides/structured-outputs)\n  (the model's direct response). Wraps the schema under a `\"schema\"` key.\n- **`OPENAI_TOOLS`** — for [function / tool calling](https://developers.openai.com/api/docs/guides/function-calling)\n  (arguments the model passes to your code). Wraps the schema under a `\"parameters\"` key.\n\n## Example — Response Format (`OPENAI`)\n\n```julia\nusing DescribedTypes\nusing JSON\n\nstruct Person\n    name::String\n    age::Int\nend\n\nDescribedTypes.annotate(::Type{Person}) = Annotation(\n    name=\"Person\",\n    description=\"A schema for a person.\",\n    parameters=Dict(\n        :name =\u003e Annotation(name=\"name\", description=\"The name of the person\", enum=[\"Alice\", \"Bob\"]),\n        :age  =\u003e Annotation(name=\"age\", description=\"The age of the person\")\n    )\n)\n\nschema_dict = schema(Person, llm_adapter=OPENAI)\nprintln(JSON.json(schema_dict, 2))\n```\n\nOutput *(generated automatically by [`docs/generate_readme.jl`](docs/generate_readme.jl))*:\n```json\n{\n  \"name\": \"Person\",\n  \"description\": \"A schema for a person.\",\n  \"strict\": true,\n  \"schema\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"name\": {\n        \"type\": \"string\",\n        \"description\": \"The name of the person\",\n        \"enum\": [\n          \"Alice\",\n          \"Bob\"\n        ]\n      },\n      \"age\": {\n        \"type\": \"integer\",\n        \"description\": \"The age of the person\"\n      }\n    },\n    \"required\": [\n      \"name\",\n      \"age\"\n    ],\n    \"additionalProperties\": false\n  }\n}\n```\n\n## Example — Tool / Function Calling (`OPENAI_TOOLS`)\n\n```julia\nDescribedTypes.annotate(::Type{Person}) = Annotation(\n    name=\"get_person\",\n    description=\"Fetches information about a person.\",\n    parameters=Dict(\n        :name =\u003e Annotation(name=\"name\", description=\"The name of the person\", enum=[\"Alice\", \"Bob\"]),\n        :age  =\u003e Annotation(name=\"age\", description=\"The age of the person\")\n    )\n)\n\nschema_dict = schema(Person, llm_adapter=OPENAI_TOOLS)\nprintln(JSON.json(schema_dict, 2))\n```\n\nOutput:\n```json\n{\n  \"type\": \"function\",\n  \"name\": \"get_person\",\n  \"description\": \"Fetches information about a person.\",\n  \"strict\": true,\n  \"parameters\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"name\": {\n        \"type\": \"string\",\n        \"description\": \"The name of the person\",\n        \"enum\": [\n          \"Alice\",\n          \"Bob\"\n        ]\n      },\n      \"age\": {\n        \"type\": \"integer\",\n        \"description\": \"The age of the person\"\n      }\n    },\n    \"required\": [\n      \"name\",\n      \"age\"\n    ],\n    \"additionalProperties\": false\n  }\n}\n```\n\n## Optional Fields\n\nBoth `OPENAI` and `OPENAI_TOOLS` modes enforce that all fields are listed in\n`\"required\"`. Optional fields (`Union{Nothing, T}`) are represented as\n`[\"type\", \"null\"]`, following the\n[OpenAI structured-output requirement](https://developers.openai.com/api/docs/guides/structured-outputs):\n\n\u003e Although all fields must be required (and the model will return a value for\n\u003e each parameter), it is possible to emulate an optional parameter by using a\n\u003e union type with null.\n\n**Standard schema** (optional field excluded from `required`):\n\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\"\n    },\n    \"nickname\": {\n      \"type\": \"string\"\n    }\n  },\n  \"required\": [\n    \"name\"\n  ]\n}\n```\n\n**OpenAI schema** (optional field uses `[\"type\", \"null\"]`):\n\n```json\n{\n  \"name\": \"PersonOpt\",\n  \"description\": \"A person with an optional nickname.\",\n  \"strict\": true,\n  \"schema\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"name\": {\n        \"type\": \"string\",\n        \"description\": \"Full name\"\n      },\n      \"nickname\": {\n        \"type\": [\n          \"string\",\n          \"null\"\n        ],\n        \"description\": \"Optional nickname\"\n      }\n    },\n    \"required\": [\n      \"name\",\n      \"nickname\"\n    ],\n    \"additionalProperties\": false\n  }\n}\n```\n\n---\n\n*Output blocks in this README were generated by running `julia docs/generate_readme.jl`.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgunion%2Fdescribedtypes.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falgunion%2Fdescribedtypes.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgunion%2Fdescribedtypes.jl/lists"}