needle简单试用

needle 核心是比较轻量,以下是一个简单尝试(注意目前needle 是不支持中文的)

参考代码

  • 示例
import needle
import datetime
@needle.tool
def get_weather(city: str):
    "Get the current weather for a city."
    return {"city": city, "temp_c": 27, "sky": "clear"}

@needle.tool
def current_dates():
    "Get the current date."
    return {"date": datetime.datetime.now().strftime("%Y-%m-%d")}


if __name__ == "__main__":
    agent = needle.Needle(tools=[get_weather, current_dates])
    print(agent.run("get current date and beijing weather")["results"])
  • 效果 速度还是比较快的

image

说明

needle 设计上是比较有意思的,但是就是不支持中文,但是架构设计上值得学习下

参考资料

https://github.com/cactus-compute/needle

https://cactuscompute.com/

https://docs.cactuscompute.com/latest/

posted on 2026-09-03 08:00  荣锋亮  阅读(14)  评论(0)    收藏  举报

导航