The GenericSuite AI for Python (backend version)
Project description
The GenericSuite AI for Python (backend version)
GenericSuite AI is a versatile backend solution, designed to provide a comprehensive suite of features, tools and functionalities for AI oriented Python APIs.
It's bassed on The Generic Suite (backend version), so its features are inherited.
The perfect companion for this backend solution is The GenericSuite AI (frontend version)
Pre-requisites
- Python >= 3.9 and < 4.0
- Git
- Make: Mac | Windows
- Node version 18+, installed via NVM (Node Package Manager) or NPM and Node install.
AWS account and credentials
- AWS account, see free tier.
- AWS Token, see Access Keys.
- AWS Command-line interface, see awscli.
- API Framework and Serverless Deployment, see Chalice.
Installation
First check the Getting Started section in the GenericSuite backend version documentation.
To use GenericSuite AI in your project, install it with the following command(s):
From Pypi
Pip
pip install genericsuite-ai
Pipenv
pipenv install genericsuite-ai
Poetry
poetry add genericsuite-ai
From a specific branch in the repository, e.g. "branch_x"
Pip
pip install git+https://github.com/tomkat-cr/genericsuite-be-ai@branch_x
Pipenv
pipenv install git+https://github.com/tomkat-cr/genericsuite-be-ai@branch_x
Poetry
poetry add git+https://github.com/tomkat-cr/genericsuite-be-ai@branch_x
Test dependencies
To execute the unit and integration test, install pytest
and coverage
:
Pip
pip install pytest coverage
Pipenv
pipenv install --dev pytest coverage
Poetry
poetry add --dev pytest coverage
Development scripts installation
The GenericSuite backend development scripts contains utilities to build and deploy APIs made by The GenericSuite.
npm install -D genericsuite-be-scripts
Features
ai_chatbot
endpoint to implement NLP conversations based on OpenAI or Langchain APIs.- OpenAPI, Google Gemini, Anthropic, Ollama, and Hugging Face models handling.
- Clarifai models and embeddings handling.
- Computer vision (OpenAPI GPT4 Vision, Google Gemini Vision, Clarifai Vision).
- Speech-to-text processing (OpenAPI Whisper, Clarifai Audio Models).
- Text-to-speech (OpenAI TTS-1, Clarifai Audio Models).
- Image generator (OpenAI DALL-E 3, Google Gemini Image, Clarifai Image Models).
- Vector indexers (FAISS, Chroma, Clarifai, Vectara, Weaviate, MongoDBAtlasVectorSearch)
- Embedders (OpenAI, Hugging Face, Clarifai, Bedrock, Cohere, Ollama)
- Web search tool.
- Webpage scrapping and analyzing tool.
- JSON, PDF, Git and Youtube readers.
- Language translation tools.
- Chats stored in the Database.
- Plan attribute, OpenAi API key and model name in the user profile, to allow free plan users to use Models at their own expenses.
Configuration
Configure your application by setting up the necessary environment variables. Refer to the .env.example and config.py files for the available options.
Please check the GenericSuite backend version configuration section for more details about general environment variables.
For GenericSuite AI, there are these additional environment variables:
- Chabot configuration
# Aplicacion AI assistant name
AI_ASSISTANT_NAME=ExampleBot
- Google configuration
GOOGLE_API_KEY=google_console_api_key
GOOGLE_CSE_ID=google_console_cse_key
- OpenAI configuration
OPENAI_API_KEY=openai_api_key
OPENAI_MODEL=gpt-3.5-turbo
OPENAI_TEMPERATURE=0.7
- Langchain/LangSmith configuration
LANGCHAIN_API_KEY=langchain_api_key
LANGCHAIN_PROJECT=langchain_project
- Hugging Face credentials and model URL
HUGGINGFACE_API_KEY=huggingface_api_key
HUGGINGFACE_ENDPOINT_URL=huggingface_endpoint_url
- AWS Configuration
AWS_S3_CHATBOT_ATTACHMENTS_BUCKET_DEV=exampleapp-chatbot-attachments-dev
AWS_S3_CHATBOT_ATTACHMENTS_BUCKET_QA=exampleapp-chatbot-attachments-qa
AWS_S3_CHATBOT_ATTACHMENTS_BUCKET_STAGING=exampleapp-chatbot-attachments-staging
AWS_S3_CHATBOT_ATTACHMENTS_BUCKET_PROD=exampleapp-chatbot-attachments-prod
- Other AI configurations
(not included in the original AWS Lambda deployment. Configurable via Configuration Parameters)
EMBEDDINGS_ENGINE=openai
# EMBEDDINGS_ENGINE=clarifai
VECTOR_STORE_ENGINE=FAISS
# VECTOR_STORE_ENGINE=clarifai
# VECTOR_STORE_ENGINE=mongo
# VECTOR_STORE_ENGINE=vectara
`LANGCHAIN_DEFAULT_MODEL=chat_openai
# LANGCHAIN_DEFAULT_MODEL=gemini
# LANGCHAIN_DEFAULT_MODEL=huggingface
# LANGCHAIN_DEFAULT_MODEL=clarifai
AI_VISION_TECHNOLOGY=openai
# AI_VISION_TECHNOLOGY=gemini
# AI_VISION_TECHNOLOGY=clarifai
AI_IMG_GEN_TECHNOLOGY=openai
# AI_IMG_GEN_TECHNOLOGY=gemini
# AI_IMG_GEN_TECHNOLOGY=clarifai
AI_AUDIO_TO_TEXT_TECHNOLOGY=openai
# AI_AUDIO_TO_TEXT_TECHNOLOGY=google
# AI_AUDIO_TO_TEXT_TECHNOLOGY=clarifai
AI_TEXT_TO_AUDIO_TECHNOLOGY=openai
# AI_TEXT_TO_AUDIO_TECHNOLOGY=clarifai
# Add aditional models to the LLM
AI_ADDITIONAL_MODELS=0
# AI_ADDITIONAL_MODELS=1
# Langchain credentials and other parameters
# Langsmith
LANGCHAIN_ENDPOINT=https://api.smith.langchain.com
LANGCHAIN_TRACING_V2=true
# Agent configuration
LANGCHAIN_AGENT_TYPE=react_chat_agent
# LANGCHAIN_AGENT_TYPE=react_agent
# LANGCHAIN_AGENT_TYPE=structured_chat_agent
# LANGCHAIN_AGENT_TYPE=LLMSingleActionAgent
LANGCHAIN_MAX_ITERATIONS=8
LANGCHAIN_EARLY_STOPPING_METHOD=force
# LANGCHAIN_EARLY_STOPPING_METHOD=generate
LANGCHAIN_HANDLE_PARSING_ERR=1
# Translate final Chatbot response to the user in case user's language is not english
LANGCHAIN_TRANSLATE_USING=google_translate
# LANGCHAIN_TRANSLATE_USING=initial_prompt
# LANGCHAIN_TRANSLATE_USING=same_model
# LANGCHAIN_TRANSLATE_USING=
LANGCHAIN_USE_LANGSMITH_HUB=0
# LANGCHAIN_USE_LANGSMITH_HUB=1
# Google other parameters
GOOGLE_MODEL=gemini-pro
GOOGLE_VISION_MODEL=gemini-pro-vision
# GOOGLE_IMG_GEN_MODEL=gemini-pro-vision
GOOGLE_IMG_GEN_MODEL=imagegeneration@005
# OpenAI other parameters
OPENAI_MAX_TOKENS=500
# Addicional NLP model
OPENAI_MODEL_PREMIUM=gpt-4-turbo-preview
OPENAI_MODEL_INSTRUCT=gpt-3.5-turbo-instruct
# Computer Vision model
OPENAI_VISION_MODEL=gpt-4-vision-preview
# Image neration model
OPENAI_IMAGE_GEN_MODEL=dall-e-3
# Speech-to-text model
OPENAI_VOICE_MODEL=whisper-1
# Text-to-speech model
OPENAI_TEXT_TO_AUDIO_MODEL=tts-1
OPENAI_TEXT_TO_AUDIO_VOICE=onyx
# OPENAI_TEXT_TO_AUDIO_VOICE=alloy
# OPENAI_TEXT_TO_AUDIO_VOICE=echo
# OPENAI_TEXT_TO_AUDIO_VOICE=fable
# OPENAI_TEXT_TO_AUDIO_VOICE=nova
# OPENAI_TEXT_TO_AUDIO_VOICE=shimmer
# Embeddings model
OPENAI_EMBEDDINGS_MODEL=text-embedding-ada-002
# OPENAI_EMBEDDINGS_MODEL=text-embedding-3-small
# Embeddings premium model
OPENAI_EMBEDDINGS_MODEL_PREMIUM=text-embedding-3-large'
# Anthropic credentials and other parameters
ANTHROPIC_MODEL=claude-2
ANTHROPIC_API_KEY=
# AWS Bedrock credentials and other parameters
AWS_BEDROCK_EMBEDDINGS_MODEL_ID=amazon.titan-embed-text-v1
AWS_BEDROCK_EMBEDDINGS_PROFILE=bedrock-admin
# HuggingFace other parameters
HUGGINGFACE_MAX_NEW_TOKENS=512
HUGGINGFACE_TOP_K=50
HUGGINGFACE_TEMPERATURE=1
HUGGINGFACE_REPETITION_PENALTY=03
# IMPORTANT: about "sentence-transformers" lib. Be careful, because
# when it's included, the package size increase by 5 Gb. and if the
# app runs in a AWS Lambda Function, it overpass the package size
# deployment limit.
HUGGINGFACE_EMBEDDINGS_MODEL="BAAI/bge-base-en-v1.5"
# HUGGINGFACE_EMBEDDINGS_MODEL="sentence-transformers/all-mpnet-base-v2"
HUGGINGFACE_EMBEDDINGS_MODEL_KWARGS='{"device":"cpu"}'
HUGGINGFACE_EMBEDDINGS_ENCODE_KWARGS='{"normalize_embeddings": true}'
# Clarifai credentials and other parameters
# PAT (Personal API Token): https://clarifai.com/settings/security
CLARIFAI_PAT=
CLARIFAI_USER_ID=
CLARIFAI_APP_ID=
AI_CLARIFAI_DEFAULT_CHAT_MODEL=GPT-4
# AI_CLARIFAI_DEFAULT_CHAT_MODEL=claude-v2
# AI_CLARIFAI_DEFAULT_CHAT_MODEL=mixtral-8x7B-Instruct-v0_1
# AI_CLARIFAI_DEFAULT_CHAT_MODEL=llama2-70b-chat
AI_CLARIFAI_DEFAULT_TEXT_EMBEDDING_MODEL==text-embedding-ada
# AI_CLARIFAI_DEFAULT_TEXT_EMBEDDING_MODEL==BAAI-bge-base-en-v15
AI_CLARIFAI_DEFAULT_AUDIO_TO_TEXT_MODEL=whisper
# AI_CLARIFAI_DEFAULT_AUDIO_TO_TEXT_MODEL=whisper-large-v2
AI_CLARIFAI_DEFAULT_TEXT_TO_AUDIO_MODEL=speech-synthesis
AI_CLARIFAI_AUDIO_TO_TEXT_SDK_TYPE=python_sdk
# AI_CLARIFAI_AUDIO_TO_TEXT_SDK_TYPE=clarifai_grpc
AI_CLARIFAI_DEFAULT_IMG_GEN_MODEL=stable-diffusion-xl
# AI_CLARIFAI_DEFAULT_IMG_GEN_MODEL=dall-e-3
AI_CLARIFAI_DEFAULT_VISION_MODEL=openai-gpt-4-vision
# AI_CLARIFAI_DEFAULT_VISION_MODEL=food-item-recognition
# ElevenLabs
ELEVENLABS_API_KEY=
# Sarah
ELEVENLABS_VOICE_ID_FEMALE=EXAVITQu4vr4xnSDxMaL
# Drew
ELEVENLABS_VOICE_ID_MALE=29vD33N1CtxCmqQRPOHJ
ELEVENLABS_MODEL_ID=eleven_multilingual_v2
ELEVENLABS_STABILITY=0.5
ELEVENLABS_SIMILARITY_BOOST=0.5
ELEVENLABS_STYLE=0
ELEVENLABS_USE_SPEAKER_BOOST=1
# Cohere credentials and other parameters
COHERE_API_KEY=
COHERE_EMBEDDINGS_MODEL=embed-english-light-v3.0
# Ollama credentials and other parameters
OLLAMA_MODEL=llama:7b
OLLAMA_EMBEDDINGS_MODEL=llama:7b
# MongooDB embeddings
MONGODB_VS_COLLECTION=
MONGODB_VS_INDEX_NAME=
# Pinecone credentials and other parameters
# PINECONE_API_KEY=
# PINECONE_ENV=
# Vectara credentials and other parameters
VECTARA_CUSTOMER_ID=
VECTARA_CORPUS_ID=
VECTARA_API_KEY=
# Weaviate credentials and other parameters
WEAVIATE_URL=
WEAVIATE_API_KEY=
Code examples and JSON configuration files
The main menu, API endpoints and CRUD editor configurations are defined in the JSON configuration files.
You can find examples about configurations and how to code an App in the GenericSuite App Creation and Configuration guide.
Usage
Check the The GenericSuite backend development scripts for more details.
License
This project is licensed under the ISC License - see the LICENSE file for details.
Credits
This project is developed and maintained by Carlos J. Ramirez. For more information or to contribute to the project, visit GenericSuite AI on GitHub.
Happy Coding!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for genericsuite_ai-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19b8fe5eb5f9276ce12e87ec82c15ddf2653950bda122d5e3abe01542a405cc8 |
|
MD5 | 25152f8b0df593ecae280b2d68d39a5e |
|
BLAKE2b-256 | d17ddfc4a77d380d48dd0d23991bfc9c928c0c50d5b82ac511955508acb9fcf7 |