Skip to content

Commit 1645b78

Browse files
committed
Merge branch 'full-template'
2 parents c5b32c4 + cbc1e48 commit 1645b78

File tree

20 files changed

+610
-347
lines changed

20 files changed

+610
-347
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ app
6464
└───test
6565
```
6666

67+
## Containers Architecture
68+
69+
![langchain-architecture](https://res.cloudinary.com/dnv0qwkrk/image/upload/v1693340056/Allient/create-fastapi-project/image_2_mraj02.png)
70+
As this project uses [Caddy](https://caddyserver.com/) as a reverse proxy, which uses namespaces routing, you can access the documentation with the following path [http://fastapi.localhost/docs](http://fastapi.localhost/docs)
71+
6772
## ENV Variables
6873

6974
```bash

create_fastapi_project/main.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ def create_project():
4040
langchain_basic = ITemplate.langchain_basic.value
4141
full = ITemplate.full.value
4242
template_type: str = questionary.select(
43-
"Choose a template", choices=[
44-
basic,
45-
langchain_basic,
46-
questionary.Choice(full, disabled=disabled_message)
47-
]
43+
"Choose a template",
44+
choices=[basic, langchain_basic, full],
4845
).ask()
4946
if template_type == ITemplate.full:
5047
questionary.select(
@@ -79,9 +76,7 @@ def create_project():
7976
panel = Panel(styled_message, title="Project Initialization")
8077
console.print(panel)
8178

82-
confirmation: bool = questionary.confirm(
83-
"Are you sure you want to continue?"
84-
).ask()
79+
confirmation: bool = questionary.confirm("Are you sure you want to continue?").ask()
8580
if not confirmation:
8681
print("Not created")
8782
raise typer.Abort()

create_fastapi_project/templates/__init__.py

+78-11
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
import shutil
33
from enum import Enum
44
from dotenv import dotenv_values
5-
from create_fastapi_project.helpers.install import add_configuration_to_pyproject, install_dependencies
5+
from create_fastapi_project.helpers.install import (
6+
add_configuration_to_pyproject,
7+
install_dependencies,
8+
)
9+
610

711
class ITemplate(str, Enum):
812
basic = "basic"
913
langchain_basic = "langchain_basic"
10-
full = "full"
14+
full = "full"
15+
1116

1217
def install_template(root: str, template: ITemplate, app_name: str):
1318
print(f"Initializing project with template: {template}")
@@ -32,45 +37,107 @@ def install_template(root: str, template: ITemplate, app_name: str):
3237
dirs_exist_ok=True,
3338
)
3439

35-
3640
poetry_path = ""
3741
if template == ITemplate.full or template == ITemplate.langchain_basic:
3842
# TODO: CHECK PATHS IN MACOS AND WINDOWS | (os.path.join)
3943
poetry_path = os.path.join(root, "backend", "app")
44+
poetry_frontend_path = os.path.join(root, "frontend", "app")
4045

4146
else:
4247
poetry_path = os.path.join(root, "app")
43-
48+
4449
has_pyproject = add_configuration_to_pyproject(poetry_path)
4550

4651
if has_pyproject:
47-
dependencies = ["fastapi[all]", "fastapi-pagination[sqlalchemy]@^0.12.7", "asyncer@^0.0.2", "httpx@^0.24.1"]
52+
dependencies = [
53+
"fastapi[all]",
54+
"fastapi-pagination[sqlalchemy]@^0.12.7",
55+
"asyncer@^0.0.2",
56+
"httpx@^0.24.1",
57+
]
58+
dev_dependencies = [
59+
"pytest@^7.4.0",
60+
"mypy@^1.5.0",
61+
"ruff@^0.0.284",
62+
"black@^23.7.0",
63+
]
4864
if template == ITemplate.langchain_basic:
4965
langchain_dependencies = [
5066
"langchain@^0.0.265",
5167
"openai@^0.27.8",
5268
"adaptive-cards-py@^0.0.7",
53-
"google-search-results@^2.4.2"
69+
"google-search-results@^2.4.2",
70+
]
71+
frontend_dependencies = [
72+
"streamlit",
73+
"websockets",
5474
]
5575
dependencies[0] = "fastapi[all]@^0.99.1"
5676
dependencies.extend(langchain_dependencies)
57-
dev_dependencies = ["pytest@^5.2", "mypy@^1.5.0", "ruff@^0.0.284", "black@^23.7.0"]
77+
if template == ITemplate.full:
78+
full_dependencies = [
79+
"alembic@^1.10.2",
80+
"asyncpg@^0.27.0",
81+
"sqlmodel@^0.0.8",
82+
"python-jose@^3.3.0",
83+
"cryptography@^38.0.3",
84+
"passlib@^1.7.4",
85+
"SQLAlchemy-Utils@^0.38.3",
86+
"SQLAlchemy@^1.4.40",
87+
"minio@^7.1.13",
88+
"Pillow@^9.4.0",
89+
"watchfiles@^0.18.1",
90+
"asyncer@^0.0.2",
91+
"httpx@^0.23.1",
92+
"pandas@^1.5.3",
93+
"openpyxl@^3.0.10",
94+
"redis@^4.5.1",
95+
"fastapi-async-sqlalchemy@^0.3.12",
96+
"oso@^0.26.4",
97+
"celery@^5.2.7",
98+
"transformers@^4.28.1",
99+
"requests@^2.29.0",
100+
"wheel@^0.40.0",
101+
"setuptools@^67.7.2",
102+
"langchain@^0.0.262",
103+
"openai@^0.27.5",
104+
"celery-sqlalchemy-scheduler@^0.3.0",
105+
"psycopg2-binary@^2.9.5",
106+
"fastapi-limiter@^0.1.5 ",
107+
"fastapi-pagination[sqlalchemy]@^0.11.4 ",
108+
"fastapi-cache2[redis]@^0.2.1 ",
109+
]
110+
full_dev_dependencies = [
111+
"pytest-asyncio@^0.21.1",
112+
]
113+
dependencies[0] = "fastapi[all]@^0.95.2"
114+
dependencies.extend(full_dependencies)
115+
dev_dependencies.extend(full_dev_dependencies)
116+
58117
print("- Installing main packages. This might take a couple of minutes.")
59118
install_dependencies(poetry_path, dependencies)
60119
print("- Installing development packages. This might take a couple of minutes.")
61120
install_dependencies(poetry_path, dev_dependencies, dev=True)
121+
122+
if template == ITemplate.langchain_basic:
123+
add_configuration_to_pyproject(poetry_frontend_path)
124+
print(
125+
"- Installing frontend packages. This might take a couple of minutes."
126+
)
127+
install_dependencies(poetry_frontend_path, frontend_dependencies)
128+
62129
# Set your dynamic environment variables
63-
130+
64131
# Load variables from .env.example
65132
example_env = dotenv_values(".env.example")
66133
example_env["PROJECT_NAME"] = app_name
67134

68135
# Write modified environment variables to .env and .env.example file
69-
with open(".env", "w") as env_file, open(".env.example", "w") as example_env_file:
136+
with open(".env", "w") as env_file, open(
137+
".env.example", "w"
138+
) as example_env_file:
70139
for key, value in example_env.items():
71140
env_file.write(f"{key}={value}\n")
72141
example_env_file.write(f"{key}={value}\n")
73142

74143
return has_pyproject
75-
76-

0 commit comments

Comments
 (0)