TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Agents Made Simple

5 点作者 galgia4 个月前
I have built many AI agents, and all frameworks felt so bloated, slow, and unpredictable. Therefore, I hacked together a minimal library that works with JSON&#x2F;dict&#x2F;kwargs definitions for each step, allowing you a simpler way to define reproducible agents. It supports concurrency for up to 1000 calls&#x2F;min, giving you speed and predictability in your workflows.<p><i>Install</i><p><pre><code> pip install flashlearn </code></pre> <i>Input is a list of dictionaries</i><p>Simply take user inputs, API responses, and calculations from other tools and feed them to <i>FlashLearn</i>.<p><pre><code> user_inputs = [{&quot;query&quot;: &quot;When was python launched?&quot;}] </code></pre> <i>Skill is just a simple dictionary</i><p>A skill is an LLM’s ability to perform a task, containing all the necessary information. You can create your own, use predefined samples, or generate them automatically from example data.<p><pre><code> ConvertToGoogleQueries = { &quot;skill_class&quot;: &quot;GeneralSkill&quot;, &quot;system_prompt&quot;: &quot;Exactly populate the provided function definition&quot;, &quot;function_definition&quot;: { &quot;type&quot;: &quot;function&quot;, &quot;function&quot;: { &quot;name&quot;: &quot;ConvertToGoogleQueries&quot;, &quot;description&quot;: &quot;Convert the given question into between 1 and n google queries to answer the given question.&quot;, &quot;strict&quot;: True, &quot;parameters&quot;: { &quot;type&quot;: &quot;object&quot;, &quot;properties&quot;: { &quot;google_queries&quot;: { &quot;type&quot;: &quot;array&quot;, &quot;items&quot;: {&quot;type&quot;: &quot;string&quot;} } }, &quot;required&quot;: [&quot;google_queries&quot;], &quot;additionalProperties&quot;: False } } } } </code></pre> <i>Run in 3 lines of code</i><p>Load the skill, create tasks (a list of dictionaries), and run them in parallel. Results are easy to parse in downstream steps.<p><pre><code> skill = GeneralSkill.load_skill(ConvertToGoogleQueries) tasks = skill.create_tasks([{&quot;query&quot;: &quot;User&#x27;s query&quot;}]) results = skill.run_tasks_in_parallel(tasks) </code></pre> <i>Get structured results</i><p>The output is a dictionary, where each key corresponds to an index in the original list. This lets you keep track of results easily.<p><pre><code> flash_results = {&#x27;0&#x27;: {&#x27;google_queries&#x27;: [&quot;QUERY_1&quot;, &quot;QUERY_2&quot;]}} </code></pre> <i>Pass on to downstream tasks</i><p>Use the structured JSON output in your next steps.<p><pre><code> queries = flash_results[&quot;0&quot;][&quot;google_queries&quot;] results = SimpleGoogleSearch(GOOGLE_API_KEY, GOOGLE_CSE_ID).search(queries) msgs = [ {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: &quot;insert links from search results in response to quote it&quot;}, {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: str(results)}, {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;When was python launched?&quot;} ] print(client.chat.completions.create(model=MODEL_NAME, messages=msgs).choices[0].message.content) </code></pre> Feel free to ask anything!

3 条评论

adamgiacomelli4 个月前
Wow this looks very clean. Can you pipe the results into another agent? What&#x27;s the limit of the input, can I push files into it?
评论 #42876209 未加载
Giacomelli4 个月前
Right, i am new to AI.. i dont get it, how and why is this useful?
评论 #42876354 未加载
ninaslivnik4 个月前
Sounds cool! Do you have some usage examples?
评论 #42876173 未加载