Agent automatically figures out how to make API requests given API docs and user query in plain text
Project description
Ad-Hoc API
An Archytas tool that eses LLMs to interact with APIs given documentation. User explains what they want in plain english, and then the agent (using the APIs docs for context) writes python code to complete the task.
Installation
pip install adhoc-api
Usage
This is designed to be paired with an Archytas agent. You may omit the python tool, and the agent should instead return the source code to you rather than running it.
from adhoc_api import AdHocAPI
from archytas.react import ReActAgent, FailedTaskError
from archytas.tools import PythonTool
from easyrepl import REPL
def main():
python = PythonTool()
adhoc_api = AdhocApi(run_code=python.run)
tools = [adhoc_api, python]
agent = ReActAgent(model='gpt-4o', tools=tools, verbose=True)
# REPL to interact with agent
for query in REPL(history_file='.chat'):
try:
answer = agent.react(query)
print(answer)
except FailedTaskError as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
adhoc_api-0.2.1.tar.gz
(11.1 kB
view hashes)
Built Distribution
adhoc_api-0.2.1-py3-none-any.whl
(13.6 kB
view hashes)
Close
Hashes for adhoc_api-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cbcd23085a868115ff7dccb25ee1ae1e906925b04c95a9805d2c73245e4b227 |
|
MD5 | abc5905f4ecd203cc1ab8f97dd3b046c |
|
BLAKE2b-256 | 73537dfb4f55601f7e7b895768302880a08cbf2e43def848d80741fc4daf789a |