-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,541 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,4 +136,6 @@ sonarqube/logs | |
|
||
backend | ||
|
||
.terraform | ||
.terraform | ||
|
||
my_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
create_fastapi_project/templates/langchain_basic/.env.example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PROJECT_NAME= | ||
OPENAI_API_KEY= | ||
UNSPLASH_API_KEY= | ||
SERP_API_KEY= |
19 changes: 19 additions & 0 deletions
19
create_fastapi_project/templates/langchain_basic/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11 | ||
ENV PYTHONUNBUFFERED=1 | ||
WORKDIR /code | ||
# Install Poetry | ||
RUN apt clean && apt update && apt install curl -y | ||
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \ | ||
cd /usr/local/bin && \ | ||
ln -s /opt/poetry/bin/poetry && \ | ||
poetry config virtualenvs.create false | ||
|
||
# Copy poetry.lock* in case it doesn't exist in the repo | ||
COPY app/pyproject.toml app/poetry.lock* /code/ | ||
|
||
# Allow installing dev dependencies to run tests | ||
ARG INSTALL_DEV=false | ||
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi" | ||
|
||
ENV PYTHONPATH=/code | ||
EXPOSE 8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/make | ||
|
||
include .env | ||
|
||
help: | ||
@echo "make" | ||
@echo " install" | ||
@echo " Install all packages of poetry project locally." | ||
@echo " run-app" | ||
@echo " Run app locally without docker." | ||
@echo " run-dev-build" | ||
@echo " Run development docker compose and force build containers." | ||
@echo " run-dev" | ||
@echo " Run development docker compose." | ||
@echo " stop-dev" | ||
@echo " Stop development docker compose." | ||
@echo " run-prod" | ||
@echo " Run production docker compose." | ||
@echo " stop-prod" | ||
@echo " Run production docker compose." | ||
@echo " formatter" | ||
@echo " Apply black formatting to code." | ||
@echo " mypy" | ||
@echo " Check typing." | ||
@echo " lint" | ||
@echo " Lint code with ruff, and check if black formatter should be applied." | ||
@echo " lint-watch" | ||
@echo " Lint code with ruff in watch mode." | ||
@echo " lint-fix" | ||
@echo " Lint code with ruff and try to fix." | ||
|
||
install: | ||
cd app && poetry install && cd .. | ||
|
||
run-app: | ||
cd app && poetry run uvicorn app.main:app --host 0.0.0.0 --port 8000 && cd .. | ||
|
||
|
||
run-dev-build: | ||
docker compose -f docker-compose-dev.yml up --build | ||
|
||
run-dev: | ||
docker compose -f docker-compose-dev.yml up | ||
|
||
stop-dev: | ||
docker compose -f docker-compose-dev.yml down | ||
|
||
run-prod: | ||
docker compose up --build | ||
|
||
stop-prod: | ||
docker compose down | ||
|
||
formatter: | ||
cd app && \ | ||
poetry run black app | ||
|
||
mypy: | ||
cd app && \ | ||
poetry run mypy . | ||
|
||
lint: | ||
cd app && \ | ||
poetry run ruff app && poetry run black --check app | ||
|
||
lint-watch: | ||
cd app && \ | ||
poetry run ruff app --watch | ||
|
||
lint-fix: | ||
cd app && \ | ||
poetry run ruff app --fix |
104 changes: 104 additions & 0 deletions
104
create_fastapi_project/templates/langchain_basic/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# FastAPI Project with `create-fastapi-project` | ||
|
||
This is a FastAPI project initialized using [`create-fastapi-project`](/~https://github.com/allient/create-fastapi-project), designed to provide a quick start for building APIs with [FastAPI](https://fastapi.tiangolo.com/). | ||
|
||
## Required API Keys | ||
|
||
### OpenAI | ||
|
||
1. Create an account on [OpenAI](https://platform.openai.com/). | ||
2. Get your API key from [API Keys - OpenAI](https://platform.openai.com/account/api-keys). | ||
3. Set your API key as an environment variable named `OPENAI_API_KEY`. | ||
|
||
## Other API Keys (Optional if you want to use the template's custom tools) | ||
|
||
### Unsplash (Image Search) | ||
|
||
1. Create an account on [Unsplash](https://unsplash.com/developers). | ||
2. Create an app on [Unsplash Developers](https://unsplash.com/oauth/applications). | ||
3. Get your Access Key from [Your Applications - Unsplash Developers](https://unsplash.com/oauth/applications). | ||
4. Set your Access Key as an environment variable named `UNSPLASH_API_KEY`. | ||
|
||
### SerpApi (Search Engine Results Page API) | ||
|
||
1. Create an account on [SerpApi](https://serpapi.com/). | ||
2. Get your API key from [API Key - SerpApi](https://serpapi.com/manage-api-key). | ||
3. Set your API key as an environment variable named `SERP_API_KEY`. | ||
|
||
## Getting Started | ||
|
||
The commands in this documentation can be customized on the **Makefile**. It can be started with and without docker. | ||
|
||
- Run the server (Recommended using docker): | ||
|
||
```bash | ||
# Run locally with docker in dev mode and force build | ||
make run-dev-build | ||
# or | ||
# Run locally with docker in dev mode | ||
make run-dev | ||
# or | ||
# Run locally with docker in prod mode (Autoreload disabled) | ||
make run-prod | ||
``` | ||
|
||
- Run the server without docker: | ||
|
||
First, make sure you have all packages installed: | ||
|
||
```bash | ||
make install | ||
``` | ||
|
||
```bash | ||
make run-app | ||
``` | ||
|
||
Open [http://localhost:8000/docs](http://localhost:8000/docs) with your browser to see the result. | ||
|
||
You can start editing the server by modifying `app/main.py`. | ||
|
||
## Demo Langchain Tools | ||
|
||
This template includes some tools to help you get started with your project: | ||
|
||
- Search pokemon by name or id | ||
- Search weather by city name | ||
- Search images by keyword | ||
- Search videos by keyword | ||
|
||
And also includes a agent that uses the tools to answer your questions. | ||
You can access the agent by opening [http://localhost:8000/chat](http://localhost:8000/chat) with your browser. | ||
|
||
## Learn More | ||
|
||
To learn more about Fastapi, take a look at the following resources: | ||
|
||
- [Fastapi Documentation](https://fastapi.tiangolo.com/). | ||
- [fastapi-alembic-sqlmodel-async](/~https://github.com/jonra1993/fastapi-alembic-sqlmodel-async). | ||
- [full-stack-fastapi-postgresql](/~https://github.com/tiangolo/full-stack-fastapi-postgresql). | ||
- [sqlmodel-tutorial](https://sqlmodel.tiangolo.com/tutorial/fastapi/). | ||
- [asyncer-tutorial](https://asyncer.tiangolo.com/tutorial/). | ||
- [fastapi-pagination](/~https://github.com/uriyyo/fastapi-pagination). | ||
- [fastapi-best-practices](/~https://github.com/zhanymkanov/fastapi-best-practices). | ||
- [awesome-fastapi](/~https://github.com/mjhea0/awesome-fastapi). | ||
|
||
## Why use Create FastAPI Project? | ||
|
||
`create-fastapi-project` provides a streamlined way to kickstart your FastAPI projects. Here are some compelling reasons to choose it for your project setup: | ||
|
||
### Interactive Experience | ||
|
||
Running `pip install create-fastapi-project@latest` (with no arguments) launches an interactive experience that guides you through the process of setting up your project. This interactive approach simplifies the initial configuration and gets you started quickly. | ||
|
||
### Zero Dependencies | ||
|
||
`create-fastapi-project` has been designed to be lightweight and efficient. It requires zero external dependencies, ensuring that your project remains unburdened by unnecessary packages. | ||
|
||
### Reliability and Maintenance | ||
|
||
`create-fastapi-project` is officially maintained by the [Allient development team](https://www.allient.io/). It is well-tested and aligns with best practices, ensuring that it functions as expected and remains up to date with FastAPI's releases. | ||
|
||
By choosing `create-fastapi-project`, you streamline your initial project setup, leverage reliable patterns, and enjoy the convenience of a tool tailored for FastAPI development. | ||
|
||
We love ❤️ [FastAPI](https://fastapi.tiangolo.com/) and its ecosystem. You can check out the [create-fastapi-project GitHub repository](/~https://github.com/allient/create-fastapi-project) - your feedback and contributions are welcome! |
Empty file.
Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions
7
create_fastapi_project/templates/langchain_basic/app/app/api/v1/api.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from fastapi import APIRouter | ||
from app.api.v1.endpoints import ( | ||
chat, | ||
) | ||
|
||
api_router = APIRouter() | ||
api_router.include_router(chat.router, prefix="/chat", tags=["chat"]) |
Empty file.
Oops, something went wrong.