Coder Social home page Coder Social logo

adepojujeremy / fastapi-langchain-db-api-agent Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 10.61 MB

A FastAPI-based agent that queries the Northwind database and integrates multiple public APIs, including authentication-required endpoints. The agent automatically determines the appropriate tool to engage based on the natural language query provided. Deployed on Render and accessible via a single FastAPI endpoint.The application is live and hosted

Home Page: https://fastapi-langchain-db-api-agent.onrender.com

License: MIT License

fastapi-langchain-db-api-agent's Introduction

LangChain-FastAPI-Agent

This repository contains a Python-based LangChain agent that interacts with a SQLite database and various public APIs. The agent is exposed over a single FastAPI endpoint and can process natural language queries to decide whether to query the database or fetch data from a public API.

Features

  • Database Querying: Interacts with the Northwind SQLite database to retrieve information based on SQL queries.
  • Public API Integration: Fetches data from a public API without authentication.
  • Authenticated API Integration: Fetches data from a public API that requires authentication.
  • Natural Language Processing: Determines the appropriate action (database query or API request) based on the input query.
  • FastAPI Endpoint: Exposes the agent functionality over a FastAPI endpoint for easy interaction.

Setup Instructions

  1. Clone the Repository: bash git clone https://github.com/your-username/langchain-fastapi-agent.git cd langchain-fastapi-agent

  2. Download the Northwind Database: sh curl -L -o northwind.db https://github.com/jpwhite3/northwind-SQLite3/blob/main/dist/northwind.db?raw=true

  3. Install Dependencies: bash pip install fastapi uvicorn requests pydantic

  4. Run the FastAPI Server: bash uvicorn agent_api:app --reload

  5. Test the API with Postman:

    • Open Postman and create a new POST request to http://127.0.0.1:8000/query.

    • Set the request body to raw and JSON, for example: json { "query": "SELECT * FROM Customers" }

    • Send the request and view the response.

Endpoints

  • POST /query: Accepts a JSON payload with a query string. Determines whether to query the database or fetch data from a public API based on the input query.

Example Queries

  • Database Query: json { "query": "SELECT * FROM Customers" }

  • Public API Query: json { "query": "Fetch data from public API" }

  • Authenticated API Query: json { "query": "Fetch data from auth API" }

Deployment

The application can be deployed to cloud platforms like Render or Vercel for wider accessibility.

Demo

A demo video of the project interaction using Postman is available here.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

fastapi-langchain-db-api-agent's People

Contributors

adepojujeremy avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.