[{"data":1,"prerenderedAt":428},["ShallowReactive",2],{"project-35821748":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":36,"aspects":37,"strip":45,"post_text":46,"what":47,"said":78,"maker_in_thread":181,"shape":191,"grid":195,"attempts":389,"same_week":390,"maker_shows":39,"maker_hidden":420,"reader_version":421,"card":422},"35821748","GPT-JSON","Structured and typehinted GPT responses in Python","title","Show HN: GPT-JSON – Structured and typehinted GPT responses in Python","https:\u002F\u002Fgithub.com\u002Fpiercefreeman\u002Fgpt-json","github.com","icyfox",1683232797,2023,174,72,342,3109,12,"notable","ai","llm output parsing library","library",[24,25,26,27,28],"gpt json","structured output","pydantic","typehints","openai api","mixed",-0.141,{"positive":32,"neutral":33,"mixed":34,"critical":35},5,11,1,10,27,{"idea":38,"execution":41,"design":44},{"positive":39,"critical":40},3,7,{"positive":42,"critical":43},0,2,{"positive":42,"critical":34},[39,42,42,42,39,42,42,39,34,32,32,34,34,34,42,39,42,42,39,42,34,42,32,34,34,42,42,42,32,42,42,39,39,39,39,42,42,42,34,34],null,{"problem":48,"audience":55,"pricing":46,"motivation":61,"time_to_build":46,"stack":65,"openness":77,"stage":77,"team_size":77},{"value":49,"source":50,"evidence":51},"GPT JSON responses are often broken, wrong types or missing fields","maker",[52],{"id":53,"by":11,"text":54},"35822017","Hey HN, I've been using GPT a lot lately in some side projects around data generation and benchmarking. During the course of prompt tuning I ended up with a pretty complicated…",{"value":56,"source":50,"evidence":57},"developers running GPT calls in pipelines",[58],{"id":59,"by":11,"text":60},"35831889","You might not! Depends on what you're looking for. I've been finding this library most helpful in places where I have a lot of GPT calls in pipelines, so having typehinted schema…",{"value":62,"source":50,"evidence":63},"Consolidates logic built across 5 separate side projects for prompt tuning and data generation",[64],{"id":53,"by":11,"text":54},[66,70,73],{"value":67,"source":50,"evidence":68},"Python",[69],{"id":53,"by":11,"text":54},{"value":26,"source":50,"evidence":71},[72],{"id":53,"by":11,"text":54},{"value":74,"source":50,"evidence":75},"GPT",[76],{"id":53,"by":11,"text":54},"unknown",{"praise":79,"objections":85,"requests":111,"questions":127,"alternatives":141},[80],{"value":81,"source":82,"evidence":83},"Pydantic-based prompt-to-schema approach is useful for chaining GPT calls","commenter",[84],{"id":59,"by":11,"text":60},[86,97,104],{"value":87,"source":82,"evidence":88},"Prompt-only JSON instructions already work about 99% of the time",[89,93],{"id":90,"by":91,"text":92},"35830239","btbuildem","I've been interfacing with GPT programmatically for a little while now, leveraging it's \"soft and fuzzy\" interface to produce hard \u002F machine-readable results. JSON was the format…",{"id":94,"by":95,"text":96},"35831625","verdverm","It works fine 99% of the time by just using a small amount of extra instruction in the actual prompt. The method GP describes works in any language with just the basic building…",{"value":98,"source":82,"evidence":99},"A library is unnecessary overhead for this task",[100,101],{"id":94,"by":95,"text":96},{"id":102,"by":95,"text":103},"35833231","yeah, don't disagree, however this idea is better a function I use within gpt-index or langchain. There is a horse race and we're all making our bets about who's going to win",{"value":105,"source":82,"evidence":106},"Retry loops are questioned as unreliable",[107],{"id":108,"by":109,"text":110},"35827645","TeeWEE","I dont see how these infinite loops are a good idea... You never sure if you actually getting a good result ? What is the failure rate?",[112,123],{"value":113,"source":82,"evidence":114},"Support for YAML or markdown output instead of JSON",[115,119],{"id":116,"by":117,"text":118},"35831056","killthebuddha","In the last 24 hours I've seen a bunch of projects doing LLM -> JSON. I think we want to be focusing on markdown instead. An intuition I have developed is that an ideal prompt…",{"id":120,"by":121,"text":122},"35828442","mmaia","I'm having success with simple YAML schema. One thing that's very helpful for the prompt is to include \"description\" and \"example\": ``` - column name: salary_max format: number…",{"value":124,"source":82,"evidence":125},"Include examples in the schema prompt",[126],{"id":120,"by":121,"text":122},[128,135],{"value":129,"source":82,"evidence":130},"Why are retry errors appended as system messages rather than user messages",[131],{"id":132,"by":133,"text":134},"35826566","SeanA208","Very cool. Out of curiosity, for the retries why are the errors appended as system messages as opposed to appending to the user message? And in either case, would it help to…",{"value":136,"source":82,"evidence":137},"Is CUE validation better than pydantic or zod",[138],{"id":139,"by":11,"text":140},"35831721","Pretty good pitch from ChatGPT if you ask me! I haven't used cue outside of test projects before, so a few questions: 1. Is cue's validation a material improvement from something…",[142,149,156,163,170,174],{"value":143,"source":82,"evidence":144},"pydantic-chatcompletion",[145],{"id":146,"by":147,"text":148},"35825300","wskish","Here's 40 lines of python code that I've found to be unreasonably effective at accomplishing something similar:…",{"value":150,"source":82,"evidence":151},"Guardrails",[152],{"id":153,"by":154,"text":155},"35825482","armcat","Have you considered Guardrails, https:\u002F\u002Fshreyar.github.io\u002Fguardrails\u002F, it’s like Pydantic but for LLMs?",{"value":157,"source":82,"evidence":158},"Langchain output parser",[159],{"id":160,"by":161,"text":162},"35825909","lharries","Langchain also has a built in Pydantic output parser https:\u002F\u002Fpython.langchain.com\u002Fen\u002Flatest\u002Fmodules\u002Fprompts\u002Foutput_parsers\u002Fexamples\u002Fpydantic.html However I've found it to be…",{"value":164,"source":82,"evidence":165},"zod-chatgpt",[166],{"id":167,"by":168,"text":169},"35826130","olup","I built zod-chatgpt https:\u002F\u002Fgithub.com\u002Folup\u002Fzod-chatgpt a couple of weeks ago to serve same purpose in typescript",{"value":171,"source":50,"evidence":172},"jsonformer",[173],{"id":53,"by":11,"text":54},{"value":175,"source":82,"evidence":176},"struct-gpt",[177],{"id":178,"by":179,"text":180},"35866752","knowsuchagency","I'm curious what you might think of https:\u002F\u002Fgithub.com\u002Fknowsuchagency\u002Fstruct-gpt",{"comments":182,"answered":43,"key":183},6,[184,187,188],{"id":185,"text":186},"35825127","Thanks for the thoughts! I've deployed a few meta models that act like you're describing for second stage predictions, but for fuzzy task definitions have actually seen similar…",{"id":59,"text":60},{"id":189,"text":190},"35831795","Good suggestion mmaia - I'm opening a new issue to keep track of the different output schemas that are being suggested. One thing that originally worried me a bit with yaml was…",{"commenters":192,"max_depth":32,"maker_replies":182,"first_comment_mins":193,"lifespan_hours":194},48,21,96,[196,200,202,206,210,212,215,218,220,224,227,230,231,235,236,238,240,242,246,249,251,253,256,257,258,259,262,264,265,267,270,271,273,276,280,283,285,288,290,291,293,296,297,299,303,306,308,310,313,315,318,322,325,327,331,333,336,340,344,349,352,355,357,361,363,366,369,371,374,376,380,383,387],[197,42,39,198,199,42],"35825064","project\u002Fmixed\u002Fidea","crazyedgar",[185,42,42,201,11,34],"maker\u002Fneutral\u002Fnone",[203,42,42,204,205,42],"35825364","other\u002Fneutral\u002Fnone","iamflimflam1",[207,42,42,208,209,42],"35825587","commenter\u002Fneutral\u002Fnone","syntaxing",[211,42,42,208,199,42],"35825790",[213,42,42,208,214,42],"35826593","IanCal",[216,42,42,208,217,42],"35828407","RobertDeNiro",[219,42,42,208,214,42],"35828719",[221,42,39,222,223,42],"35827750","project\u002Fneutral\u002Fexecution","ZephyrBlu",[225,42,42,208,226,42],"35829222","generalizations",[228,42,42,208,229,42],"35831779","zh217",[146,34,42,204,147,42],[232,34,42,233,234,42],"35826254","other\u002Fpositive\u002Fnone","johntash",[132,34,39,222,133,42],[237,34,42,208,147,42],"35837802",[108,34,34,239,109,42],"project\u002Fcritical\u002Fexecution",[241,34,42,208,223,42],"35827764",[243,34,32,244,245,42],"35828214","project\u002Fpositive\u002Fnone","slig",[247,34,32,248,229,42],"35831626","project\u002Fpositive\u002Fidea",[250,34,42,208,147,42],"35837786",[90,43,34,252,91,42],"project\u002Fcritical\u002Fidea",[254,43,34,239,255,42],"35830954","olabyne",[94,43,42,208,95,42],[59,43,42,201,11,34],[102,43,34,252,95,42],[260,43,42,208,261,42],"35831209","xg15",[263,43,42,208,91,42],"35832412",[178,43,42,204,179,42],[120,39,39,266,121,42],"project\u002Fneutral\u002Fnone",[268,39,42,208,269,42],"35828941","vlaaad",[189,39,42,201,11,34],[167,272,42,204,168,42],4,[274,272,39,266,275,42],"35830894","kleneway1",[277,32,39,278,279,42],"35826192","project\u002Fneutral\u002Fidea","teleforce",[281,32,42,204,282,42],"35826981","TeMPOraL",[284,32,42,204,95,42],"35829963",[286,32,42,204,287,42],"35834214","mhsred5",[289,32,34,252,95,42],"35830258",[139,32,42,201,11,34],[292,32,42,204,287,42],"35834156",[294,182,32,248,295,42],"35826928","reissbaker",[153,40,39,266,154,42],[116,298,34,252,117,42],8,[300,301,42,204,302,42],"35832127",9,"pigcat",[304,35,34,252,305,42],"35827039","robflaherty",[307,35,42,208,95,42],"35830347",[309,35,42,201,11,34],"35831449",[311,33,42,204,312,42],"35827996","Loeffelmann",[314,33,42,204,95,42],"35830291",[316,18,42,204,317,42],"35827068","fswd",[319,320,42,204,321,42],"35825530",13,"CupofChineseTea",[323,324,32,244,179,42],"35855388",14,[160,326,42,204,161,42],15,[328,329,42,204,330,42],"35825077",16,"m3kw9",[332,329,42,204,330,42],"35825122",[334,329,42,204,335,42],"35825413","yawnxyz",[337,338,42,204,339,42],"35826162",17,"jumploops",[341,342,39,278,343,42],"35826756",18,"senko",[345,346,39,347,348,42],"35826241",19,"project\u002Fneutral\u002Fdesign","BiteCode_dev",[350,346,39,347,351,42],"35826889","rain1",[353,346,34,354,348,42],"35827002","project\u002Fcritical\u002Fdesign",[356,346,32,248,95,42],"35830395",[358,359,39,278,360,42],"35825685",20,"andrewstuart",[362,359,42,208,91,42],"35830295",[364,193,42,204,365,42],"35825690","KingOfCoders",[367,193,42,204,368,42],"35825724","vmarkham",[370,193,42,208,365,42],"35825734",[372,193,42,204,373,42],"35825726","toteno",[375,193,42,208,365,42],"35825732",[377,378,39,278,379,42],"35826524",22,"AmazingTurtle",[381,378,34,252,382,42],"35831963","alalalal",[384,385,34,252,386,42],"35827154",23,"valyagolev",[53,388,42,201,11,34],24,[],[391,396,401,406,411,416],{"id":392,"name":393,"points":394,"category":395},"35826540","Grasp",266,"web_saas",{"id":397,"name":398,"points":399,"category":400},"35861209","SineRider",181,"games",{"id":402,"name":403,"points":404,"category":405},"35831177","The HN Recap",177,"productivity",{"id":407,"name":408,"points":409,"category":410},"35864661","Cptn.io",139,"infrastructure",{"id":412,"name":413,"points":414,"category":415},"35881963","Fir",127,"dev_tools",{"id":417,"name":418,"points":419,"category":405},"35846667","Git",124,false,"v2",{"id":423,"name":5,"line":6,"ai":420,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":424,"top":18,"kw":425,"maker":11,"domain":10,"tier":19,"attempts":42,"strip":426,"url":9,"mix":427,"praise":81,"objection":87,"sub":21},35821748,-0.14,[24,25,26,27,28],"3000300315511103003010511000500333300011",[32,33,34,35],1794036635027]