Skip to content

Commit

Permalink
Merge pull request #3 from tomkat-cr/FA-246_fastapi_app_starter
Browse files Browse the repository at this point in the history
FA-246 - FastAPI app starter
  • Loading branch information
tomkat-cr authored Jun 7, 2024
2 parents 9b0e4d7 + 3793ee2 commit 4eee91f
Show file tree
Hide file tree
Showing 32 changed files with 2,721 additions and 2,292 deletions.
46 changes: 43 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ DEFAULT_LANG=en
APP_DEBUG=1
# Application environment: dev, qa, staging, prod
APP_STAGE=dev
# Application secret ket (to set password encryption)
APP_SECRET_KEY=xxxx
# Application super admin email
APP_SUPERADMIN_EMAIL=xxxx
# Application secret ket (to set password encryption)
APP_SECRET_KEY=xxxx
# Storage seed (to set storage URL encryption -e.g. AWS S3-)
STORAGE_URL_SEED=yyy
#
# Database configuration
#
Expand Down Expand Up @@ -95,13 +97,17 @@ FRONTEND_PATH=../exampleapp_frontend
PYTHON_VERSION=3.11.5
#
# AWS Configuration
# https://console.aws.amazon.com
AWS_S3_BUCKET_NAME_FE=aws-s3-bucket-name
AWS_REGION=aws-region
AWS_API_GATEWAY_STAGE=aws-api-gateway-stage
AWS_LAMBDA_FUNCTION_NAME=aws-lambda-function-name
AWS_LAMBDA_FUNCTION_ROLE=aws-lambda-function-role
AWS_SSL_CERTIFICATE_ARN=arn:aws:acm:AWS-REGION:AWS-ACCOUNT:certificate/AWS-CERTIFICATE-UUD
#
# Development URL masking external hostname (storage URL encryption)
URL_MASK_EXTERNAL_HOSTNAME=app-dev.exampleapp.com
#
# SMTP Mail configuration
SMTP_SERVER=smtp_server
SMTP_PORT=smtp_port
Expand Down Expand Up @@ -136,18 +142,52 @@ AI_TECHNOLOGY="langchain"
####################
#
# Google configuration
# https://console.cloud.google.com/apis/credentials
GOOGLE_API_KEY=google_console_api_key
# https://programmablesearchengine.google.com/
GOOGLE_CSE_ID=google_console_cse_key
#
# OpenAI configuration
# https://platform.openai.com/api-keys
OPENAI_API_KEY=openai_api_key
OPENAI_MODEL=gpt-3.5-turbo
OPENAI_TEMPERATURE=0.7
#
# Langchain/LangSmith configuration
# https://smith.langchain.com/settings
LANGCHAIN_API_KEY=langchain_api_key
LANGCHAIN_PROJECT=langchain_project
#
# Hugging Face credentials and model URL
# Hugging Face configuration
# https://huggingface.co/settings/tokens
HUGGINGFACE_API_KEY=huggingface_api_key
HUGGINGFACE_ENDPOINT_URL=huggingface_endpoint_url
#
# Anthropic configuration
# https://console.anthropic.com/settings/keys
ANTHROPIC_MODEL=claude-3-sonnet
ANTHROPIC_API_KEY=anthropic_api_key
#
# Eleven Labs configuration
# https://elevenlabs.io/app/subscription
ELEVENLABS_API_KEY=elevenlabs_api_key
#
# Cohere configuration
# https://dashboard.cohere.com/api-keys
COHERE_API_KEY=cohere_api_key
#
# Pinecone configuration
# https://app.pinecone.io/keys
PINECONE_API_KEY=pinecone_api_key
PINECONE_ENV=pinecone_env
#
# Vectara configuration
# https://console.vectara.com/console/apiAccess/personalApiKey
VECTARA_CUSTOMER_ID=vectara_customer_id
VECTARA_CORPUS_ID=vectara_corpus_id
VECTARA_API_KEY=vectara_api_key
#
# Weaviate configuration
# https://console.weaviate.cloud/dashboard
WEAVIATE_URL=weaviate_url
WEAVIATE_API_KEY=weaviate_api_key
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,67 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch
### Breaks


## 0.1.7 (2024-06-06)

### New
Add AI Endpoints and create_app for FastAPI [FA-246].
Add 'setup.cfg' and 'setup.py' to enable 'sam build' and 'sam local start-api' [GS-90].

### Changes
Change 'OPENAI_VISION_MODEL' default value to 'gpt-4o'. Previously was 'gpt-4-vision-preview' [GS-78].
Remove the "dist" from the git repo.
Separate "messages_to_langchain_fmt_text" and "messages_to_langchain_fmt" so the latter always returns list [GS-78].
get_functions_dict() returns the exact function name when LanchChain Tools are required [GS-78].
Image generator save_image() returns "public_url" instead of "attachment_url", to be aligned to AWS save_file_from_url().
Add "sendfile_callable" and "background_tasks" parameters to ai_chatbot_endpoint() to allow FastAPI send file back [GS-66].

### Fixes
Downgrade duckduckgo-search==5.3.1b1 to remove "pyreqwest_impersonate" and fix the error building the docker image.
Fix "Cannot instantiate typing.Union, <class 'TypeError'>" error in messages_to_langchain_fmt() avoiding AnyMessage use.
Fix LCEL non-agent compatibility by removing "args_schema" from text_to_audio_response() Tool decorator [GS-66].


## 0.1.6 (2024-05-28)
---

### New
Implement new OpenAI model gpt-4o [GS-78].
Add file upload on FastAPI [GS-68].
Add STORAGE_URL_SEED and APP_HOST_NAME env. vars. to mask the S3 URL and avoid AWS over-billing attacks [GS-72].
Conversations conversion [GS-72].
Add requirements.txt generation to Makefile on publish.
Add ".PHONY" entries for all labels in Makefile.

### Changes
Tiktoken and langchain-openai upgraded to use 'text-embedding-3-small' as default OPENAI_EMBEDDINGS_MODEL [GS-65].
ANTHROPIC_MODEL defaults to 'claude-3-sonnet'.
OpenAI vision model defaults to 'gpt-4o' [GS-78].
Remove the GenericSuite AI library dependency from GenericSuite Core [GS-74].
Redirect README instructions to the GenericSuite Documentation [GS-73].
"blueprint" as mandatory parameter to GenericDbHelper, AppContext and app_context_and_set_env(), to make posible the specific functions to GenericDbHelper [GS-79].

### Fixes
Fix DuckDuckGo & Google Search issues [GS-87].
Implement non-agent LCEL chains to solve issue getting AI assistant responses in deployed environments [GS-66].


## 0.1.5 (2024-04-20)
---

### Changes
Updated genericsuite = "0.1.5" with "mangum" to make FastAPI work on AWS Lambda [FA-246].


## 0.1.4 (2024-04-20)
---

### Changes
Updated genericsuite = "0.1.4" with FastAPI enhanced support [FA-246].
Change: README with clearer AWS_S3_CHATBOT_ATTACHMENTS_BUCKET_* example values and main image taken from the official documentation site [FA-246].
Change: Homepage pointed to "https://genericsuite.carlosjramirez.com/Backend-Development/GenericSuite-AI/" [FA-257].
License changed to ISC in "pyproject.toml" [FA-244].


## 0.1.3 (2024-04-09)
---

Expand Down
25 changes: 22 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# .DEFAULT_GOAL := local
# .PHONY: tests
.PHONY: lock update requirements lock-rebuild build publish-test publish dev-prepare-local dev-prepare-git dev-prepare-pypi dev-prepare-publish
SHELL := /bin/bash

lock:
Expand All @@ -8,16 +8,35 @@ lock:
update:
poetry update

requirements:
poetry export -f requirements.txt --output requirements.txt --without-hashes

lock-rebuild:
poetry lock --no-update
poetry install --sync

build:
# Build 'dist' directory needed for the Pypi publish
poetry lock --no-update
rm -rf dist
python3 -m build

publish-test: build
publish-test: dev-prepare-publish requirements build
# Pypi Test publish
python3 -m twine upload --repository testpypi dist/*

publish: build
publish: dev-prepare-publish requirements build
# Production Pypi publish
python3 -m twine upload dist/*

dev-prepare-local:
poetry add --group dev ../genericsuite-be

dev-prepare-git:
poetry add --group dev git+https://github.com/tomkat-cr/genericsuite-be

dev-prepare-pypi:
poetry add --group dev genericsuite

dev-prepare-publish:
if ! poetry remove genericsuite; then echo "'genericsuite' was not removed..."; else "'genericsuite' removed successfully..."; fi;
Loading

0 comments on commit 4eee91f

Please sign in to comment.