Skip to content

Commit c789f09

Browse files
committed
Merge branch 'development'
2 parents f7c283a + 132828f commit c789f09

File tree

14 files changed

+170
-196
lines changed

14 files changed

+170
-196
lines changed

.DS_Store

0 Bytes
Binary file not shown.

create_fastapi_project/templates/__init__.py

+42-44
Original file line numberDiff line numberDiff line change
@@ -47,66 +47,64 @@ def install_template(root: str, template: ITemplate, app_name: str):
4747
if has_pyproject:
4848
dependencies = [
4949
"fastapi[all]",
50-
"fastapi-pagination[sqlalchemy]@^0.12.7",
51-
"asyncer@^0.0.2",
52-
"httpx@^0.24.1",
50+
"fastapi-pagination[sqlalchemy]",
51+
"asyncer",
52+
"httpx",
5353
]
5454
dev_dependencies = [
55-
"pytest@^7.4.0",
56-
"mypy@^1.5.0",
57-
"ruff@^0.0.284",
58-
"black@^23.7.0",
55+
"pytest",
56+
"mypy",
57+
"ruff",
58+
"black",
5959
]
6060
if template == ITemplate.langchain_basic:
6161
langchain_dependencies = [
62-
"langchain@^0.0.265",
63-
"openai@^0.27.8",
64-
"adaptive-cards-py@^0.0.7",
65-
"google-search-results@^2.4.2",
62+
"langchain",
63+
"openai",
64+
"adaptive-cards-py",
65+
"google-search-results",
6666
]
6767
frontend_dependencies = [
6868
"streamlit",
6969
"websockets",
7070
]
71-
dependencies[0] = "fastapi[all]@^0.99.1"
7271
dependencies.extend(langchain_dependencies)
7372
if template == ITemplate.full:
7473
full_dependencies = [
75-
"alembic@^1.10.2",
76-
"asyncpg@^0.27.0",
77-
"sqlmodel@^0.0.8",
78-
"python-jose@^3.3.0",
79-
"cryptography@^38.0.3",
80-
"passlib@^1.7.4",
81-
"SQLAlchemy-Utils@^0.38.3",
82-
"SQLAlchemy@^1.4.40",
83-
"minio@^7.1.13",
84-
"Pillow@^9.4.0",
85-
"watchfiles@^0.18.1",
86-
"asyncer@^0.0.2",
87-
"httpx@^0.23.1",
88-
"pandas@^1.5.3",
89-
"openpyxl@^3.0.10",
90-
"redis@^4.5.1",
91-
"fastapi-async-sqlalchemy@^0.3.12",
92-
"oso@^0.26.4",
93-
"celery@^5.2.7",
94-
"transformers@^4.28.1",
95-
"requests@^2.29.0",
96-
"wheel@^0.40.0",
97-
"setuptools@^67.7.2",
98-
"langchain@^0.0.262",
99-
"openai@^0.27.5",
100-
"celery-sqlalchemy-scheduler@^0.3.0",
101-
"psycopg2-binary@^2.9.5",
102-
"fastapi-limiter@^0.1.5 ",
103-
"fastapi-pagination[sqlalchemy]@^0.11.4 ",
104-
"fastapi-cache2[redis]@^0.2.1 ",
74+
"alembic",
75+
"asyncpg",
76+
"sqlmodel",
77+
"python-jose",
78+
"cryptography",
79+
"passlib",
80+
"SQLAlchemy-Utils",
81+
"SQLAlchemy",
82+
"minio",
83+
"Pillow",
84+
"watchfiles",
85+
"asyncer",
86+
"httpx",
87+
"pandas",
88+
"openpyxl",
89+
"redis",
90+
"fastapi-async-sqlalchemy",
91+
"oso",
92+
"celery",
93+
"transformers",
94+
"requests",
95+
"wheel",
96+
"setuptools",
97+
"langchain",
98+
"openai",
99+
"celery-sqlalchemy-scheduler",
100+
"psycopg2-binary",
101+
"fastapi-limiter",
102+
"fastapi-pagination[sqlalchemy]",
103+
"fastapi-cache2[redis]",
105104
]
106105
full_dev_dependencies = [
107-
"pytest-asyncio@^0.21.1",
106+
"pytest-asyncio",
108107
]
109-
dependencies[0] = "fastapi[all]@^0.95.2"
110108
dependencies.extend(full_dependencies)
111109
dev_dependencies.extend(full_dev_dependencies)
112110

create_fastapi_project/templates/basic/backend/Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11
1+
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11-slim
22
ENV PYTHONUNBUFFERED=1
3+
ENV PIP_DEFAULT_TIMEOUT=100
34
WORKDIR /code
45
# Install Poetry
56
RUN apt clean && apt update && apt install curl -y
@@ -13,7 +14,7 @@ COPY app/pyproject.toml app/poetry.lock* /code/
1314

1415
# Allow installing dev dependencies to run tests
1516
ARG INSTALL_DEV=false
16-
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
17+
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
1718

1819
ENV PYTHONPATH=/code
1920
EXPOSE 8000

create_fastapi_project/templates/basic/backend/app/app/core/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ModeEnum(str, Enum):
1010
testing = "testing"
1111

1212

13-
class Settings(BaseSettings):
13+
class Settings(BaseSettings, extra='ignore'):
1414
PROJECT_NAME: str = "app"
1515
BACKEND_CORS_ORIGINS: list[str] | list[AnyHttpUrl]
1616
MODE: ModeEnum = ModeEnum.development
@@ -21,7 +21,7 @@ class Settings(BaseSettings):
2121

2222
class Config:
2323
case_sensitive = True
24-
env_file = os.path.expanduser("~/.env")
24+
env_file = os.path.expanduser("../../.env")
2525

2626

2727
settings = Settings()

create_fastapi_project/templates/full/backend/Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10-slim-2022-11-25
1+
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11-slim
22
ENV PYTHONUNBUFFERED=1
3+
ENV PIP_DEFAULT_TIMEOUT=100
34
WORKDIR /code
45
# Install Poetry
56
RUN apt clean && apt update && apt install curl -y
@@ -13,7 +14,7 @@ COPY app/pyproject.toml app/poetry.lock* /code/
1314

1415
# Allow installing dev dependencies to run tests
1516
ARG INSTALL_DEV=false
16-
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
17+
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
1718

1819
ENV PYTHONPATH=/code
1920
EXPOSE 8000

create_fastapi_project/templates/langchain_basic/backend/Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11
1+
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11-slim
22
ENV PYTHONUNBUFFERED=1
3+
ENV PIP_DEFAULT_TIMEOUT=100
34
WORKDIR /code
45
# Install Poetry
56
RUN apt clean && apt update && apt install curl -y
@@ -13,7 +14,7 @@ COPY app/pyproject.toml app/poetry.lock* /code/
1314

1415
# Allow installing dev dependencies to run tests
1516
ARG INSTALL_DEV=false
16-
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi"
17+
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
1718

1819
ENV PYTHONPATH=/code
1920
EXPOSE 8000
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
2-
from pydantic import AnyHttpUrl, BaseSettings
2+
from pydantic import AnyHttpUrl, field_validator
3+
from pydantic_settings import BaseSettings, SettingsConfigDict
34
from enum import Enum
45

56

@@ -10,18 +11,26 @@ class ModeEnum(str, Enum):
1011

1112

1213
class Settings(BaseSettings):
13-
PROJECT_NAME: str = "app"
14-
BACKEND_CORS_ORIGINS: list[str] | list[AnyHttpUrl]
1514
MODE: ModeEnum = ModeEnum.development
15+
PROJECT_NAME: str = "app"
1616
API_VERSION: str = "v1"
1717
API_V1_STR: str = f"/api/{API_VERSION}"
1818
OPENAI_API_KEY: str
1919
UNSPLASH_API_KEY: str
2020
SERP_API_KEY: str
2121

22-
class Config:
23-
case_sensitive = True
24-
env_file = os.path.expanduser("~/.env")
22+
BACKEND_CORS_ORIGINS: list[str] | list[AnyHttpUrl]
23+
@field_validator("BACKEND_CORS_ORIGINS")
24+
def assemble_cors_origins(cls, v: str | list[str]) -> list[str] | str:
25+
if isinstance(v, str) and not v.startswith("["):
26+
return [i.strip() for i in v.split(",")]
27+
elif isinstance(v, (list, str)):
28+
return v
29+
raise ValueError(v)
30+
31+
model_config = SettingsConfigDict(
32+
case_sensitive=True, env_file=os.path.expanduser("~/.env")
33+
)
2534

2635

2736
settings = Settings()

create_fastapi_project/templates/langchain_basic/backend/app/app/schemas/message_schema.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pydantic import BaseModel, validator
1+
from pydantic import BaseModel, field_validator
22
from app.utils.uuid6 import uuid7
33
from typing import Any
44

@@ -19,20 +19,20 @@ class IChatResponse(BaseModel):
1919
type: str
2020
suggested_responses: list[str] = []
2121

22-
@validator("id", "message_id", pre=True, allow_reuse=True)
22+
@field_validator("id", "message_id")
2323
def check_ids(cls, v):
2424
if v == "" or v is None:
2525
return str(uuid7())
2626
return v
2727

28-
@validator("sender")
28+
@field_validator("sender")
2929
def sender_must_be_bot_or_you(cls, v):
3030
if v not in ["bot", "you"]:
3131
raise ValueError("sender must be bot or you")
3232
return v
3333

34-
@validator("type")
34+
@field_validator("type")
3535
def validate_message_type(cls, v):
3636
if v not in ["start", "stream", "end", "error", "info"]:
3737
raise ValueError("type must be start, stream or end")
38-
return v
38+
return v

create_fastapi_project/templates/langchain_basic/backend/app/app/schemas/response_schema.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,25 @@
44
from fastapi_pagination import Params, Page
55
from fastapi_pagination.bases import AbstractPage, AbstractParams
66
from pydantic import Field
7-
from pydantic.generics import GenericModel
7+
from pydantic import BaseModel
88

99
DataType = TypeVar("DataType")
1010
T = TypeVar("T")
1111

1212

1313
class PageBase(Page[T], Generic[T]):
1414
previous_page: int | None = Field(
15-
None, description="Page number of the previous page"
15+
default=None, description="Page number of the previous page"
16+
)
17+
next_page: int | None = Field(
18+
default=None, description="Page number of the next page"
1619
)
17-
next_page: int | None = Field(None, description="Page number of the next page")
1820

1921

20-
class IResponseBase(GenericModel, Generic[T]):
22+
class IResponseBase(BaseModel, Generic[T]):
2123
message: str = ""
22-
meta: dict = {}
23-
data: T | None
24+
meta: dict | Any | None = {}
25+
data: T | None = None
2426

2527

2628
class IGetResponsePaginated(AbstractPage[T], Generic[T]):

create_fastapi_project/templates/langchain_basic/backend/app/app/utils/exceptions/__init__.py

-12
This file was deleted.

create_fastapi_project/templates/langchain_basic/backend/app/app/utils/exceptions/common_exception.py

-82
This file was deleted.

0 commit comments

Comments
 (0)