patterns-ai-core / langchainrb

Build LLM-powered applications in Ruby
https://rubydoc.info/gems/langchainrb
MIT License
1.3k stars 181 forks source link

An abstraction that interfaces with any API and uses an LLM to come up with API calls to be executed. #81

Open andreibondarev opened 1 year ago

andreibondarev commented 1 year ago

Background

A popular use-case is constructing a prompt for the LLM that includes the API specs, and user's question at hand to construct an API call that gets executed on LLM's behalf. The API call's result then gets fed back to the LLM to synthesize an answer to the user's question.

Objectives

Create an entity (should it be a Tool? an Agent? or another abstraction?) that:

bborn commented 1 year ago

I've spent quite a bit of time on this (in Python). Here's what I came up with for AgentHQ:

https://gist.github.com/bborn/59ec195828825445e97f8eb37e8fbc2b

Basically:

andreibondarev commented 1 year ago

@bborn Thank you, I'll take a closer look and get back to you!

mattlindsey commented 1 year ago

So I think this is exactly the kind of thing the new 'function calling' in GPT enables, but it is only tuned and available for gpt-3.5-turbo-0613 and gpt-4-0613. You describe every api call to it in their format, and it reliably returns structured JSON to enable you to easily make the api call.