Giter Club home page Giter Club logo

apocas / restai Goto Github PK

View Code? Open in Web Editor NEW
334.0 8.0 68.0 33.45 MB

RestAI is an AIaaS (AI as a Service) open-source platform. Built on top of LlamaIndex, Ollama and HF Pipelines. Supports any public LLM supported by LlamaIndex and any local LLM suported by Ollama. Precise embeddings usage and tuning.

Home Page: https://apocas.github.io/restai/

License: Apache License 2.0

Makefile 0.57% Python 98.45% Dockerfile 0.98%
embeddings langchain llm openai python fastapi rag llama openaiapi llamaindex

restai's Introduction

RestAI Logo
RestAI

AIaaS (AI as a Service) for everyone. Create AI projects and consume them using a simple REST API.

Demo: https://ai.ince.pt Username: demo Password: demo

RestAI Video

Features

  • Projects: There are multiple types of agents (projects), each with its own features. (rag, ragsql, inference, vision, router, agent)
  • Users: A user represents a user of the system. It's used for authentication and authorization (basic auth). Each user may have access to multiple projects.
  • LLMs: Supports any public LLM supported by LlamaIndex. Which includes any local LLM supported by Ollama, LiteLLM, etc.
  • VRAM: Automatic VRAM management. RestAI will manage the VRAM usage, automatically loading and unloading models as needed and requested.
  • API: The API is a first-class citizen of RestAI. All endpoints are documented using Swagger.
  • Frontend: There is a frontend available at restai-frontend

Project Types

RAG

RestAI RAG
  • Embeddings: You may use any embeddings model supported by llamaindex. Check embeddings definition.
  • Vectorstore: There are two vectorstores supported: Chroma and Redis
  • Retrieval: It features an embeddings search and score evaluator, which allows you to evaluate the quality of your embeddings and simulate the RAG process before the LLM. Reranking is also supported, ColBERT and LLM based.
  • Loaders: You may use any loader supported by llamaindex.
  • Sandboxed mode: RAG agents (projects) have "sandboxed" mode, which means that a locked default answer will be given when there aren't embeddings for the provided question. This is useful for chatbots, where you want to provide a default answer when the LLM doesn't know how to answer the question, reduncing hallucination.
  • Evaluation: You may evaluate your RAG agent using deepeval. Using the eval property in the RAG endpoint.

RAGSQL

  • Connection: Supply a MySQL or PostgreSQL connection string and it will automatically crawl the DB schema, using table and column names it’s able to figure out how to translate the question to sql and then write a response.

Agent

  • ReAct Agents, specify which tools to use in the project and the agent will figure out how to use them to achieve the objective.

  • New tools are easily added. Just create a new tool in the app/llms/tools folder and it will be automatically picked up by Restai.

  • Tools: Supply all the tools names you want the Agent to use in this project. (separated by commas)

Inference

Vision

  • text2img: RestAI supports local Stable Diffusion and Dall-E. It features prompt boosting, a LLM is internally used to boost the user prompt with more detail.
  • img2text: RestAI supports LLaVA, BakLLaVA by default.
  • img2img: RestAI supports InstantID.

Stable Diffusion & InstantID

LLaVA

Router

  • Routes a message to the most suitable project. It's useful when you have multiple projects and you want to route the question to the most suitable one.
  • Routes: Very similar to Zero Shot React strategy, but each route is a project. The router will route the question to the project that has the highest score. It's useful when you have multiple projects and you want to route the question to the most suitable one.

LLMs

  • You may use any LLM supported by Ollama and/or LlamaIndex.

Installation

  • RestAI uses Poetry to manage dependencies. Install it with pip install poetry.

Development

  • make install
  • make dev (starts restai in development mode)

Production

  • make install
  • make start

Docker

  • Edit the .env file accordingly
  • docker compose --env-file .env up --build

You can specify profiles docker compose --profile redis --profile mysql .... to include additional components like the redis cache backend or a DB server, here are the supported profiles:

  • --profile redis Starts and sets redis as the cache backend
  • --profile mysql Starts and enables Mysql as the database server
  • --profile postgres Starts and enables Postgres as the database server

The variables MYSQL_HOST and POSTGRES_HOST should match the names of the respective services "mysql" and "postgres" and not localhost or 127.0.0.1 when using the containers

To delete everything or a specific container don't forget to pass the necessary profiles to the compose command, EX:

  • Removing everything docker compose --profile mysql --profile postgres down --rmi all
  • Removing singular database volume docker compose --profile mysql down --volumes

Note: the local_cache volume will also get removed since it's in the main service and not in any profile

API

  • Endpoints: All the API endpoints are documented and available at: Endpoints
  • Swagger: Swagger/OpenAPI documentation: Swagger

Frontend

Tests

  • Tests are implemented using pytest. Run them with make test.

License

Pedro Dias - @pedromdias

Licensed under the Apache license, version 2.0 (the "license"); You may not use this file except in compliance with the license. You may obtain a copy of the license at:

http://www.apache.org/licenses/LICENSE-2.0.html

Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. See the license for the specific language governing permissions and limitations under the license.

restai's People

Contributors

apocas avatar dennisdegreef avatar eltociear avatar gbrian avatar hallowslab avatar nayan32biswas avatar nunokisc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

restai's Issues

Agentic RAG and Advanced Retrieval Strategies

One of the growing and important discussions in the RAG Community now is Agent. It would be great to see Agent Implementation in this project and also some advanced Retrieval like Automerging Retrieval in llama index.

Discussion regarding contributing in the project

Hi @apocas,
I found the project very helpful and want to add some improvement to the project if you agree with the change.

Issues

  1. Loading environment variable is not organized.
  2. docker-compose file is not configured properly to run the project.

I want to add those changes if you think those change will improve the project.

a question and suggestion

A very good project.
I have a question, i see a docker-compose.yml located in the root directory. Is it means can directly launched it to run project without the need for other dependency operations.
Also, i think the document is worth improving, like ollama docs/ πŸ˜€

Please provide requirements. txt

The requirements.txt file is a text file used for Python projects, which lists all the required dependencies and their version numbers for the project.
image
llama_index-0.10.14 is wrong
from llama_index.embeddings.langchain import LangchainEmbedding
from llama_index.postprocessor.colbert_rerank import ColbertRerank

Please add support for LiteLLM to this project

This project is pretty great BUT we need more options to use different LLM's.You don't have to worry about creating a solution which supports 100+ LLM easily as LiteLLM is another foss project which is capable of doing this task for you.
Project LiteLLM link - https://github.com/BerriAI/litellm
You can study there project and see how it can be implemented in this project like you implemented support for ollama I believe similarly you can do it for LiteLLM which will be big win for the project as many will be easily able to use many more LLM easily which everyone wants and project will require 3 major parameters from user like base url,model name,api key that's all and with open ai api general structure it can query and give back result for the query.Many big projects have started adding support for this project in there project to make things advanced in easier way so study it and after that if you have any query you can ask them they are pretty responsive plus if u want to know more about my personal experience of using it with other great projects like flowise then I can tell you that too in detail.

Alternative way to import OPENAI?

I have a deployed openai service in azure and I want to utilize it, is there anyway to import besides using OPENAI_API_KEY ?

AZURE_OPENAI_API_ENDPOINT=
AZURE_OPENAI_API_KEY=
AZURE_OPENAI_API_VERSION=
AZURE_OPENAI_API_INSTANCE_NAME=
AZURE_OPENAI_API_DEPLOYMENT_NAME=
AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME=

their format looks like this. Thanks!

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.