[{"data":1,"prerenderedAt":437},["ShallowReactive",2],{"project-37661767":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":44,"post_text":47,"what":48,"said":90,"maker_in_thread":225,"shape":237,"grid":241,"attempts":400,"same_week":401,"maker_shows":34,"maker_hidden":430,"reader_version":431,"card":432},"37661767","Magentic","Use LLMs as simple Python functions","title","Show HN: Magentic – Use LLMs as simple Python functions","https:\u002F\u002Fgithub.com\u002Fjackmpcollins\u002Fmagentic","github.com","jackmpcollins",1695745876,2023,283,63,165,3109,6,"legend","dev_tools","python llm library","library",[24,25,26,27,28],"llm","python","openai","structured output","function calling","mixed",0.4,{"positive":32,"neutral":33,"mixed":34,"critical":35},14,8,1,4,27,{"design":38,"idea":41,"execution":42},{"positive":39,"critical":40},9,2,{"positive":35,"critical":40},{"positive":43,"critical":43},0,[45,43,43,45,43,34,43,46,45,34,34,45,45,45,46,46,45,43,46,45,46,43,45,43,43,45,34,43,43,43,43,45,46,46,46,43,46,43,43,43],5,3,"This is a Python package that allows you to write function signatures to define LLM queries. This makes it easy to mix regular code with calls to LLMs, which enables you to use the LLM for its creativity and reasoning while also enforcing structure\u002Flogic as necessary. LLM output is parsed for you according to the return type annotation of the function, including complex return types such as streaming an array of structured objects.\n\nI built this to show that we can think about using LLMs more fluidly than just chains and chats, i.e. more interchangeably with regular code, and to make it easy t",{"problem":49,"audience":55,"pricing":64,"motivation":65,"time_to_build":64,"stack":69,"openness":88,"stage":89,"team_size":89},{"value":50,"source":51,"evidence":52},"Mixing regular code with LLM calls and parsing structured LLM output","maker",[53],{"id":54},"post",{"value":56,"source":57,"evidence":58},"Python developers building with LLMs","inferred",[59,60],{"id":54},{"id":61,"by":62,"text":63},"37663324","jstarfish","This looks really useful. Langchain is not my idea of a fun time. Love the examples too. Low-effort humor is the best: > create_superhero(\"Garden Man\") > # Superhero(name='Garden…",null,{"value":66,"source":51,"evidence":67},"Show that LLMs can be used more interchangeably with regular code than chains and chats",[68],{"id":54},[70,74,80],{"value":71,"source":51,"evidence":72},"Python",[73],{"id":54},{"value":75,"source":51,"evidence":76},"OpenAI chat API with function calling",[77],{"id":78,"by":11,"text":79},"37665005","Thanks! Currently magentic just uses OpenAI function-calling; it provides it a function schema that matches the structure of the output object. So it fails in the same ways as…",{"value":81,"source":82,"evidence":83},"Pydantic","commenter",[84],{"id":85,"by":86,"text":87},"37670262","ramraj07","Awesome job with the simplicity, gonna play with it. Have you tried using yaml as the format with the models instead of JSOn? Feel like you'll use far fewer tokens to describe…","open_source","unknown",{"praise":91,"objections":126,"requests":152,"questions":169,"alternatives":188},[92,111,115],{"value":93,"source":82,"evidence":94},"Clean, intuitive decorator-based API design",[95,99,103,107],{"id":96,"by":97,"text":98},"37664889","smilingemoji","The API looks very clean. Today I learned about \"...\" in Python",{"id":100,"by":101,"text":102},"37662822","bogtog","Really like how this is implemented with decorators. Everything just feels really smooth",{"id":104,"by":105,"text":106},"37667755","pedrovhb","Just wanna say, that's pretty great API design :)",{"id":108,"by":109,"text":110},"37663858","retrovrv","Super cool! Looks quite intuitive, especially for function calls.",{"value":112,"source":82,"evidence":113},"Fun examples and humor",[114],{"id":61,"by":62,"text":63},{"value":116,"source":82,"evidence":117},"Useful for prototyping LLM logic in code",[118,122],{"id":119,"by":120,"text":121},"37663888","pphysch","This is neat. It makes it easy to prototype, and then you can just remove the decorator and write a specific implementation if you need to.",{"id":123,"by":124,"text":125},"37671700","hitori","I am amazed that `...` is a valid syntax in Python, not a pseudo grammar. This library is impressive, I appreciate it and I will apply it to my project.",[127,138,145],{"value":128,"source":82,"evidence":129},"Only supports OpenAI-compatible chat models",[130,134],{"id":131,"by":132,"text":133},"37662691","ElectricalUnion","Is it really LLMs (plural) when you only have OpenAPI integration?",{"id":135,"by":136,"text":137},"37669792","czyhandsome","Do you support custom LLMs?",{"value":139,"source":82,"evidence":140},"Misuse of Ellipsis instead of pass in function bodies",[141],{"id":142,"by":143,"text":144},"37671477","politelemon","It's a misuse of the Python Ellipsis, though PEP has no opinion on it. The Ellipsis is \"Special value used mostly in conjunction with extended slicing syntax for user-defined…",{"value":146,"source":82,"evidence":147},"Framework may hinder chain-of-thought prompting",[148],{"id":149,"by":150,"text":151},"37664577","BoorishBears","I've personally found frameworks like this to get in the way of quality COT: It's rare for a prompt that takes great advantage of the LLM's reasoning to fit in the format these…",[153,158,165],{"value":154,"source":82,"evidence":155},"Support for other LLM backends",[156,157],{"id":131,"by":132,"text":133},{"id":135,"by":136,"text":137},{"value":159,"source":82,"evidence":160},"System prompt and chat message support",[161],{"id":162,"by":163,"text":164},"37669191","quickthrower2","Does this do System vs. Assistant vs. User prompting?",{"value":166,"source":82,"evidence":167},"Few-shot examples in prompts",[168],{"id":85,"by":86,"text":87},[170,177,181],{"value":171,"source":82,"evidence":172},"Does it return actual code output or call OpenAI each time",[173],{"id":174,"by":175,"text":176},"37662746","conor_f","Looks super cool! A few questions: 1) Can you get the actual code output or will this end up calling OpenAI each function call? 2) What latency does it add? What about token…",{"value":178,"source":82,"evidence":179},"Latency and token usage",[180],{"id":174,"by":175,"text":176},{"value":182,"source":82,"evidence":183},"Why a decorator instead of a function call",[184],{"id":185,"by":186,"text":187},"37663400","jedberg","Curious as to why you chose to do it as a decorator instead of just a function call?",[189,200,211,218],{"value":190,"source":82,"evidence":191},"Marvin",[192,196],{"id":193,"by":194,"text":195},"37662860","cosmonoot","Seems a lot like https:\u002F\u002Fgithub.com\u002FPrefectHQ\u002Fmarvin? The prompting you do seems awfully similar to: https:\u002F\u002Fwww.askmarvin.ai\u002Fprompting\u002Fprompt_function\u002F",{"id":197,"by":198,"text":199},"37662712","bl00p","Are you familiar with https:\u002F\u002Fgithub.com\u002FPrefectHQ\u002Fmarvin? This looks very similar",{"value":201,"source":82,"evidence":202},"Guidance",[203,207],{"id":204,"by":205,"text":206},"37664322","Difwif","Looks great! I don't normally like these LLM libraries but this one sparks joy. I'll try it out on my next experiment. Could you highlight how you're parsing to structured…",{"id":208,"by":209,"text":210},"37663870","AmazingTurtle","I tried out guidance. Encountered endless bugs",{"value":212,"source":82,"evidence":213},"LMQL",[214],{"id":215,"by":216,"text":217},"37663411","lachlan_gray","This is also similar in spirit to LMQL https:\u002F\u002Fgithub.com\u002Feth-sri\u002Flmql",{"value":219,"source":82,"evidence":220},"LocalAI",[221],{"id":222,"by":223,"text":224},"37667045","michaelmior","There's also LocalAI[0] which allows the use of local LLMs with an OpenAI compatible API. [0] https:\u002F\u002Fgithub.com\u002Fgo-skynet\u002FLocalAI",{"comments":226,"answered":33,"key":227},13,[228,231,234],{"id":229,"text":230},"37676837","Ellipses is actually used in quite a few places. See the answers and comments on this stackoverflow post[0]. The usage most similar to what I have in the magentic examples is…",{"id":232,"text":233},"37670759","Yes, I'm working on allowing few-shot examples to be provided as part of defining the prompt-function, which should help in cases like this. Unfortunately from my testing just…",{"id":235,"text":236},"37665335","With magentic you could do chain-of-thought in two or more steps: one function that generates a string output containing the chain-of-thought reasoning and answer, and a second…",{"commenters":238,"max_depth":45,"maker_replies":226,"first_comment_mins":239,"lifespan_hours":240},43,52,135,[242,244,247,251,254,258,259,262,265,267,269,273,275,277,280,282,284,286,291,292,293,295,299,302,305,307,310,313,317,319,322,325,327,329,332,334,337,339,342,345,347,349,352,354,356,358,359,361,362,364,366,368,370,373,377,379,381,384,388,390,394,397,399],[61,43,45,243,62,43],"project\u002Fpositive\u002Fdesign",[245,43,43,246,194,43],"37663882","commenter\u002Fneutral\u002Fnone",[248,43,43,249,250,43],"37665761","other\u002Fneutral\u002Fnone","brandall10",[252,43,43,249,253,43],"37681063","phatskat",[255,34,45,256,257,43],"37671455","project\u002Fpositive\u002Fidea","denysvitali",[96,40,45,243,97,43],[260,40,43,261,163,43],"37669176","commenter\u002Fneutral\u002Fdesign",[263,40,43,246,264,43],"37671156","nodesocket",[142,40,34,266,143,43],"project\u002Fcritical\u002Fdesign",[229,40,43,268,11,34],"maker\u002Fneutral\u002Fdesign",[270,46,43,271,272,43],"37664146","other\u002Fneutral\u002Fidea","jumploops",[85,35,46,274,86,43],"project\u002Fmixed\u002Fexecution",[232,35,43,276,11,34],"maker\u002Fneutral\u002Fexecution",[278,45,45,256,279,43],"37664958","js98",[149,18,34,281,150,43],"project\u002Fcritical\u002Fidea",[235,18,43,283,11,34],"maker\u002Fneutral\u002Fidea",[285,18,34,266,150,43],"37669471",[287,288,45,289,290,43],"37664728",7,"project\u002Fpositive\u002Fnone","te_chris",[100,33,45,243,101,43],[204,39,45,243,205,43],[78,39,43,294,11,34],"project\u002Fneutral\u002Fexecution",[296,297,45,256,298,43],"37669631",10,"fbnbr",[185,300,46,301,186,43],11,"project\u002Fneutral\u002Fdesign",[303,300,46,301,304,43],"37663502","dragonwriter",[306,300,43,268,11,34],"37664192",[308,300,45,243,309,43],"37671468","3abiton",[311,300,43,249,312,43],"37672642","jwestbury",[314,315,43,249,316,43],"37673810",12,"ccmillion",[174,226,46,318,175,43],"project\u002Fneutral\u002Fnone",[320,226,43,321,11,34],"37664545","maker\u002Fneutral\u002Fperformance",[323,32,45,256,324,43],"37665096","zainhoda",[162,326,46,318,163,43],15,[328,326,43,301,11,34],"37671152",[330,326,43,331,11,34],"37734955","maker\u002Fneutral\u002Fnone",[123,333,45,243,124,43],16,[335,333,43,261,336,43],"37671829","joelthelion",[338,333,43,261,312,43],"37672628",[340,333,43,261,341,43],"37672842","inpaner",[343,333,43,261,344,43],"37673184","hoosieree",[119,346,45,243,120,43],17,[131,348,34,281,132,43],18,[350,348,43,246,351,43],"37662846","msikora",[353,348,43,249,304,43],"37663548",[355,348,43,283,11,34],"37663678",[357,348,43,331,11,34],"37663749",[222,348,43,249,223,43],[360,348,43,331,11,34],"37670337",[208,348,43,249,209,43],[108,363,45,243,109,43],19,[104,365,45,243,105,43],20,[135,367,46,318,136,43],21,[369,367,43,318,11,34],"37670300",[193,371,46,372,194,43],22,"project\u002Fneutral\u002Fidea",[374,375,43,271,376,43],"37666682",23,"bluecoconut",[197,378,46,372,198,43],24,[380,378,43,268,11,34],"37662772",[382,378,43,249,383,43],"37664674","fredoliveira",[385,386,46,294,387,43],"37663905",25,"visarga",[389,386,43,249,344,43],"37673252",[391,392,43,249,393,43],"37663966",26,"avindroth",[395,392,43,396,175,43],"37665790","commenter\u002Fneutral\u002Fidea",[398,392,43,271,393,43],"37689962",[215,36,43,271,216,43],[],[402,407,412,417,421,425],{"id":403,"name":404,"points":405,"category":406},"37613054","Paisa",662,"productivity",{"id":408,"name":409,"points":410,"category":411},"37663270","Raverie",644,"games",{"id":413,"name":414,"points":415,"category":416},"37600019","automatic_log_collector_and_analyzer",313,"infrastructure",{"id":418,"name":419,"points":420,"category":406},"37636701","chatgpt-history-export-to-md",295,{"id":422,"name":423,"points":424,"category":406},"37642671","E-Ink Day Schedule",294,{"id":426,"name":427,"points":428,"category":429},"37611457","Piano Tabs",222,"learning_science",false,"v2",{"id":433,"name":5,"line":6,"ai":430,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":30,"top":18,"kw":434,"maker":11,"domain":10,"tier":19,"attempts":43,"strip":435,"url":9,"mix":436,"praise":93,"objection":128,"sub":21},37661767,[24,25,26,27,28],"5005010351155533503530500510000533303000",[32,33,34,35],1794036642417]