frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: Painless structured data from LLMs in Rust: rstructor

https://github.com/clifton/rstructor
2•cliftonk•6h ago
I built rstructor, a Rust library for structured LLM outputs. It's like Python's Instructor/Pydantic, but with the power and type-safety of Rust.

You define your data models as Rust structs/enums, and rstructor handles the rest: JSON Schema generation, LLM communication (OpenAI, Anthropic, etc.), parsing, and validation.

Example - extracting structured data from unstructured text:

    use rstructor::{Instructor, LLMClient, OpenAIClient, OpenAIModel};
    use serde::{Serialize, Deserialize};

    #[derive(Instructor, Serialize, Deserialize, Debug)]
    enum Severity { Low, Medium, High, Critical }

    #[derive(Instructor, Serialize, Deserialize, Debug)]
    enum IssueType {
        Bug { severity: Severity },
        FeatureRequest,
        Performance { ms_impact: u32 },
    }

    #[derive(Instructor, Serialize, Deserialize, Debug)]
    struct TriagedIssue {
        title: String,
        issue_type: IssueType,
    }

    let client = OpenAIClient::new(env::var("OPENAI_API_KEY")?)?
        .model(OpenAIModel::Gpt4OMini);

    // Performance issue example
    let perf_issue: TriagedIssue = client.materialize(
        "The login page takes about 500ms to load, which feels really slow compared to other pages."
    ).await?;

    // Bug report example
    let bug_issue: TriagedIssue = client.materialize(
        "When I enter an invalid email address, the login page crashes with a null pointer exception."
    ).await?;

    // Now you have type-safe data - leverage Rust's pattern matching
    match perf_issue.issue_type {
        IssueType::Performance { ms_impact } => {
            println!("Performance issue detected: {}ms impact", ms_impact);
        }
        IssueType::Bug { severity } => {
            println!("Bug found with severity: {:?}", severity);
        }
        _ => {}
    }


    Key features:
    * Support for OpenAI, Anthropic, Grok (xAI), and Gemini
    * Custom validation rules with automatic detection
    * Nested structures, arrays, and enums with associated data
    * Automatic retry with validation error feedback
Crate: https://crates.io/crates/rstructor

GitHub: https://github.com/clifton/rstructor

Docs: https://docs.rs/rstructor

Would love feedback from anyone building LLM-powered tools in Rust!

Nicholas Carlini – Are LLMs worth it? [video]

https://www.youtube.com/watch?v=PngHcmMmwWI
1•teddykoker•4m ago•0 comments

SQLite Cache Schema

https://gist.github.com/ewaldbenes/e48b9b4c1d0e1cb7175dfdd868addd58
1•thunderbong•8m ago•0 comments

Palantir tops estimates, boosts fourth-quarter guidance on AI adoption

https://www.cnbc.com/2025/11/03/palantir-pltr-q3-earnings-2025.html
2•mgh2•10m ago•0 comments

Looking for Input

1•tigydavid•12m ago•0 comments

Trump readies US troops for ground invasion in Mexico to go after drug cartels

https://www.independent.co.uk/news/world/americas/us-politics/trump-drug-cartels-mexico-plans-mil...
4•saubeidl•20m ago•0 comments

We Used to Read Things in This Country

https://thebaffler.com/salvos/we-used-to-read-things-in-this-country-mccormack
3•samclemens•22m ago•0 comments

Cost-neutral food tax reforms for healthier and more sustainable diets

https://www.sciencedirect.com/science/article/pii/S0921800925003052
2•PaulHoule•31m ago•0 comments

Visualizee.ai

https://visualizee.ai
1•bellamoon544•31m ago•1 comments

Fusion Energy in 2025: Six Global Trends to Watch

https://www.iaea.org:443/newscenter/news/fusion-energy-in-2025-six-global-trends-to-watch
1•mpweiher•33m ago•0 comments

Claude Code refused to add rainbows and unicorns to my app

7•glamp•34m ago•3 comments

A Friendly Tour of Process Memory on Linux

https://www.0xkato.xyz/linux-process-memory/
4•0xkato•34m ago•2 comments

Bay Area man creates prehistoric Halloween by bringing "Doloresaurus" to life [video]

https://www.youtube.com/watch?v=BXiNtT6cRc4
1•guerrilla•34m ago•0 comments

A confidential manifesto lays out a billionaire's new vision for NASA

https://www.politico.com/news/2025/11/03/jared-isaacman-confidential-manifesto-nasa-00633858
2•c420•35m ago•0 comments

Linkers: A 20 Part Series (2007)

https://www.airs.com/blog/archives/38
2•mattrighetti•37m ago•0 comments

2025 United States federal government shutdown

https://en.wikipedia.org/wiki/2025_United_States_federal_government_shutdown
1•wslh•39m ago•1 comments

KitteHub: Python projects in the cloud in a few clicks

https://github.com/autokitteh/kittehub
1•itayd•40m ago•0 comments

OneBusAway: Open-source transit app for real-time information

https://github.com/OneBusAway
1•thunderbong•42m ago•0 comments

Guideline has been acquired by Gusto

https://help.guideline.com/en/articles/12694322-guideline-has-joined-gusto-faqs-about-our-recent-...
26•surprisetalk•44m ago•7 comments

Physical activity as a modifiable risk factor in preclinical Alzheimer's disease

https://www.nature.com/articles/s41591-025-03955-6
2•bookofjoe•45m ago•0 comments

No space, no time, no particles: a vision of quantum reality

https://www.newscientist.com/article/2500081-no-space-no-time-no-particles-a-radical-vision-of-qu...
3•fnord77•46m ago•0 comments

DJI's Drones, Both Branded and Disguised, Are Even Closer to a US Ban

https://petapixel.com/2025/11/03/djis-drones-both-branded-and-disguised-are-even-closer-to-a-us-ban/
4•bookofjoe•51m ago•2 comments

What's Next in Customer Identity and Access Management

https://www.kuppingercole.com/blog/tolbert/whats-next-in-customer-identity-and-access-management
1•mooreds•52m ago•0 comments

Norway's Public Buses Can Be Shut Down Remotely from China

https://www.carscoops.com/2025/11/norways-public-buses-can-be-shut-down-remotely-from-china/
5•josephcsible•53m ago•0 comments

Ask HN: What Is the State of Mobile Development in 2025?

1•sarimkx•54m ago•0 comments

PocketBook – DIY pocket-sized Project Gutenberg books

https://github.com/sieste/pocketbook
2•sieste•1h ago•0 comments

LLM Security Guide – 100 tools and real-world attacks from 370 experts

https://github.com/requie/LLMSecurityGuide
2•tarique192•1h ago•1 comments

Why Does the Universe Exist? (1991) [pdf]

https://philosophy.fas.harvard.edu/sites/g/files/omnuum4436/files/phildept/files/parfit_-_why_doe...
3•measurablefunc•1h ago•1 comments

Scaling up Prime Video monitoring service reduced costs 90% (archive) (2023)

https://web.archive.org/web/20240325042615/https://www.primevideotech.com/video-streaming/scaling...
1•Ellipsis753•1h ago•2 comments

Do I want Coders to Code?

https://yeikoff.xyz/blog/11-02-2025-do-i-want-coders-to-code/
1•iglesiastj•1h ago•0 comments

Trump Officials Torpedoed Nvidia's Push to Export AI Chips to China

https://www.wsj.com/world/china/trump-nvidia-china-chip-exports-51e00415
2•doener•1h ago•0 comments