diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index a2c219d..1a6a742 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -5,51 +5,54 @@ concurrency:
cancel-in-progress: true
on:
- push:
- branches: ["main"]
- pull_request:
- branches:
- - '*'
- workflow_dispatch:
+ push:
+ branches: [ "main" ]
+ pull_request:
+ branches:
+ - '*'
+ workflow_dispatch:
jobs:
- build:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v3
- - name: Set up Python 3.10
- uses: actions/setup-python@v3
- with:
- python-version: "3.10"
-
- - name: Cache dependencies
- id: cache
- uses: actions/cache@v3
- with:
- path: ${{ env.pythonLocation }}
- key: ${{ env.pythonLocation }}-pip-${{ hashFiles('requirements.txt') }}
-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install pytest pytest-cov pytest-mock pytest-coverage
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
-
- - name: Test with pytest
- run: |
- pytest --cov
-
- - name: Creating coverage folder
- run: |
- mkdir -p coverage
-
- - name: Coverage Bagdge
- uses: tj-actions/coverage-badge-py@v1.8
- with:
- output: coverage/coverage.svg
-
- - name: Publish coverage report to coverage-badge branch
- uses: JamesIves/github-pages-deploy-action@v4
- with:
- branch: coverage-badge
- folder: coverage
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up Python 3.10
+ uses: actions/setup-python@v3
+ with:
+ python-version: "3.10"
+
+ - name: Cache dependencies
+ id: cache
+ uses: actions/cache@v3
+ with:
+ path: ${{ env.pythonLocation }}
+ key: ${{ env.pythonLocation }}-pip-${{ hashFiles('pyproject.toml') }}
+
+ - name: Install poetry
+ run: |
+ curl -sSL https://install.python-poetry.org | python3 -
+ echo "$HOME/.local/bin" >> $GITHUB_PATH
+
+ - name: Install dependencies
+ run: |
+ poetry install
+
+ - name: Test with pytest
+ run: |
+ pytest --cov
+
+ - name: Creating coverage folder
+ run: |
+ mkdir -p coverage
+
+ - name: Coverage Bagdge
+ uses: tj-actions/coverage-badge-py@v1.8
+ with:
+ output: coverage/coverage.svg
+
+ - name: Publish coverage report to coverage-badge branch
+ uses: JamesIves/github-pages-deploy-action@v4
+ with:
+ branch: coverage-badge
+ folder: coverage
diff --git a/.idea/copilot/chatSessions/00000000000.xd b/.idea/copilot/chatSessions/00000000000.xd
new file mode 100644
index 0000000..50e9ae8
Binary files /dev/null and b/.idea/copilot/chatSessions/00000000000.xd differ
diff --git a/.idea/copilot/chatSessions/blobs/version b/.idea/copilot/chatSessions/blobs/version
new file mode 100644
index 0000000..720d64f
Binary files /dev/null and b/.idea/copilot/chatSessions/blobs/version differ
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..90e3fbf
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28__01_08__Changes_.xml b/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28__01_08__Changes_.xml
new file mode 100644
index 0000000..ed9e2e7
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28__01_08__Changes_.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28__01_08__Changes_1.xml b/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28__01_08__Changes_1.xml
new file mode 100644
index 0000000..be459d2
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28__01_08__Changes_1.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git "a/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28_\344\270\213\345\215\210_01_08_[Changes]/shelved.patch" "b/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28_\344\270\213\345\215\210_01_08_[Changes]/shelved.patch"
new file mode 100644
index 0000000..171a29d
--- /dev/null
+++ "b/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28_\344\270\213\345\215\210_01_08_[Changes]/shelved.patch"
@@ -0,0 +1,29 @@
+Index: src/interactor/use_cases/message/cor/__init__.py
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>from typing import List\r\n\r\nfrom linebot.v3.messaging.models.message import Message\r\n\r\nfrom src.interactor.dtos.event_dto import EventInputDto\r\nfrom src.interactor.interfaces.repositories.agent_executor_repository import (\r\n AgentExecutorRepositoryInterface,\r\n)\r\nfrom src.interactor.use_cases.message.cor.addition_handler import AdditionHandler\r\nfrom src.interactor.use_cases.message.cor.default_handler import DefaultHandler\r\nfrom src.interactor.use_cases.message.cor.muting_handler import MutingHandler\r\n\r\n\r\nclass ReplyMessagesCOR:\r\n def __init__(self):\r\n self._chain = MutingHandler(AdditionHandler(DefaultHandler()))\r\n\r\n def handle(self, input_dto: EventInputDto, repository: AgentExecutorRepositoryInterface):\r\n response: List[Message] = []\r\n self._chain.handle(input_dto, repository, response)\r\n return response\r\n
+===================================================================
+diff --git a/src/interactor/use_cases/message/cor/__init__.py b/src/interactor/use_cases/message/cor/__init__.py
+--- a/src/interactor/use_cases/message/cor/__init__.py
++++ b/src/interactor/use_cases/message/cor/__init__.py
+@@ -6,14 +6,18 @@
+ from src.interactor.interfaces.repositories.agent_executor_repository import (
+ AgentExecutorRepositoryInterface,
+ )
++from src.interactor.interfaces.repositories.window_repository import WindowRepositoryInterface
+ from src.interactor.use_cases.message.cor.addition_handler import AdditionHandler
+ from src.interactor.use_cases.message.cor.default_handler import DefaultHandler
+ from src.interactor.use_cases.message.cor.muting_handler import MutingHandler
++from src.interactor.use_cases.message.cor.window_mutable_handler import WindowMutableHandler
+
+
+ class ReplyMessagesCOR:
+- def __init__(self):
+- self._chain = MutingHandler(AdditionHandler(DefaultHandler()))
++ def __init__(self, window_repository: WindowRepositoryInterface):
++ self._chain = MutingHandler(
++ AdditionHandler(WindowMutableHandler(DefaultHandler(), window_repository))
++ )
+
+ def handle(self, input_dto: EventInputDto, repository: AgentExecutorRepositoryInterface):
+ response: List[Message] = []
diff --git "a/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28_\344\270\213\345\215\210_01_08_[Changes]1/shelved.patch" "b/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28_\344\270\213\345\215\210_01_08_[Changes]1/shelved.patch"
new file mode 100644
index 0000000..3a2732f
--- /dev/null
+++ "b/.idea/shelf/Uncommitted_changes_before_Checkout_at_2024_3_28_\344\270\213\345\215\210_01_08_[Changes]1/shelved.patch"
@@ -0,0 +1,123 @@
+Index: .vscode/settings.json
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>{\r\n \"python.analysis.extraPaths\": [\r\n \"./src\"\r\n ],\r\n \"[python]\": {\r\n \"editor.defaultFormatter\": \"ms-python.black-formatter\",\r\n \"editor.rulers\": [100],\r\n \"editor.formatOnSave\": true,\r\n \"editor.codeActionsOnSave\": {\r\n \"source.fixAll.ruff\": true,\r\n \"source.organizeImports.ruff\": true,\r\n },\r\n \"editor.formatOnType\": true\r\n }\r\n}\r\n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/.vscode/settings.json b/.vscode/settings.json
+--- a/.vscode/settings.json
++++ b/.vscode/settings.json
+@@ -7,8 +7,8 @@
+ "editor.rulers": [100],
+ "editor.formatOnSave": true,
+ "editor.codeActionsOnSave": {
+- "source.fixAll.ruff": true,
+- "source.organizeImports.ruff": true,
++ "source.fixAll.ruff": "explicit",
++ "source.organizeImports.ruff": "explicit"
+ },
+ "editor.formatOnType": true
+ }
+Index: .idea/inspectionProfiles/profiles_settings.xml
+===================================================================
+diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
+new file mode 100644
+--- /dev/null
++++ b/.idea/inspectionProfiles/profiles_settings.xml
+@@ -0,0 +1,6 @@
++
++
++
++
++
++
+Index: .idea/vcs.xml
+===================================================================
+diff --git a/.idea/vcs.xml b/.idea/vcs.xml
+new file mode 100644
+--- /dev/null
++++ b/.idea/vcs.xml
+@@ -0,0 +1,6 @@
++
++
++
++
++
++
+Index: pyproject.toml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>[tool.poetry]\r\nname = \"langchain-linebot\"\r\nversion = \"0.1.0\"\r\ndescription = \"A LineBot implemented using LangChain, featuring conversation isolation and memory, and implemented using clean architecture for practice.\"\r\nauthors = [\"Justin Xiao \"]\r\nlicense = \"MIT license\"\r\nreadme = \"README.md\"\r\n\r\n[tool.poetry.dependencies]\r\npython = \"^3.10\"\r\ncerberus = \"^1.3.5\"\r\nflask = \"^2.3.3\"\r\nflask-sqlalchemy = \"^3.1.1\"\r\nlangchain = \"^0.0.301\"\r\nline-bot-sdk = \"^3.5.0\"\r\nmarshmallow = \"^3.20.1\"\r\npydantic = \"^2.4.0\"\r\npython-dotenv = \"^1.0.0\"\r\nsqlalchemy = \"^2.0.21\"\r\nwerkzeug = \"^2.3.7\"\r\nyfinance = \"^0.2.30\"\r\npsycopg2 = \"^2.9.7\"\r\nopenai = \"^0.28.0\"\r\ntiktoken = \"^0.5.1\"\r\ngoogle-search-results = \"^2.4.2\"\r\n\r\n[tool.poetry.group.dev.dependencies]\r\npytest = \"^7.4.2\"\r\npytest-cov = \"^4.1.0\"\r\npytest-cover = \"^3.0.0\"\r\npytest-coverage = \"^0.0\"\r\npytest-flask = \"^1.2.0\"\r\npytest-mock = \"^3.11.1\"\r\n\r\n[build-system]\r\nrequires = [\"poetry-core\"]\r\nbuild-backend = \"poetry.core.masonry.api\"\r\n\r\n# https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html\r\n[tool.black]\r\nline-length = 100\r\n\r\n# https://beta.ruff.rs/docs/settings/\r\n[tool.ruff]\r\nline-length = 100\r\n# https://beta.ruff.rs/docs/rules/\r\nselect = [\"E\", \"W\", \"F\"]\r\nignore = [\"F401\", \"E501\"]\r\n# Exclude a variety of commonly ignored directories.\r\nrespect-gitignore = true\r\nignore-init-module-imports = true\r\n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/pyproject.toml b/pyproject.toml
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -7,7 +7,7 @@
+ readme = "README.md"
+
+ [tool.poetry.dependencies]
+-python = "^3.10"
++python = "3.8.17"
+ cerberus = "^1.3.5"
+ flask = "^2.3.3"
+ flask-sqlalchemy = "^3.1.1"
+Index: .idea/.gitignore
+===================================================================
+diff --git a/.idea/.gitignore b/.idea/.gitignore
+new file mode 100644
+--- /dev/null
++++ b/.idea/.gitignore
+@@ -0,0 +1,10 @@
++# Default ignored files
++/shelf/
++/workspace.xml
++# Editor-based HTTP Client requests
++/httpRequests/
++# Datasource local storage ignored files
++/dataSources/
++/dataSources.local.xml
++# GitHub Copilot persisted chat sessions
++/copilot/chatSessions
+Index: .idea/yuwen-yorozuya-linebot.iml
+===================================================================
+diff --git a/.idea/yuwen-yorozuya-linebot.iml b/.idea/yuwen-yorozuya-linebot.iml
+new file mode 100644
+--- /dev/null
++++ b/.idea/yuwen-yorozuya-linebot.iml
+@@ -0,0 +1,17 @@
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+\ No newline at end of file
+Index: .idea/modules.xml
+===================================================================
+diff --git a/.idea/modules.xml b/.idea/modules.xml
+new file mode 100644
+--- /dev/null
++++ b/.idea/modules.xml
+@@ -0,0 +1,8 @@
++
++
++
++
++
++
++
++
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..fd02170
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "associatedIndex": 2
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1711655687988
+
+
+ 1711655687988
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/yuwen-yorozuya-linebot.iml b/.idea/yuwen-yorozuya-linebot.iml
new file mode 100644
index 0000000..e0536ca
--- /dev/null
+++ b/.idea/yuwen-yorozuya-linebot.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
deleted file mode 100644
index 1b8c0a9..0000000
--- a/.pre-commit-config.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-repos:
- - repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.4.0
- hooks:
- - id: check-yaml
- - id: end-of-file-fixer
- - id: trailing-whitespace
- - repo: https://github.com/psf/black
- rev: 23.9.1
- hooks:
- - id: black
- - repo: local
- hooks:
- - id: pytest
- name: pytest
- language: system
- entry: pytest -v
- always_run: true
- pass_filenames: false
- stages: [commit]
diff --git a/README.md b/README.md
index f8ba9e4..7adf4c8 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,7 @@
---
## 📒 Table of Contents
+
- [📒 Table of Contents](#-table-of-contents)
- [📍 Overview](#-overview)
- [🚀 Getting Started](#-getting-started)
@@ -35,18 +36,23 @@
---
-
## 📍 Overview
-The LangChain-LineBot project is a feature-rich chat interface built on the LINE platform that enables seamless and interactive communication. This project has undergone a significant transformation, adopting the principles of Clean Architecture, which has not only enhanced its maintainability but also unlocked several key benefits.
+The LangChain-LineBot project is a feature-rich chat interface built on the LINE platform that enables seamless and
+interactive communication. This project has undergone a significant transformation, adopting the principles of Clean
+Architecture, which has not only enhanced its maintainability but also unlocked several key benefits.
-- Cleaner Code: The separation of concerns and modularization result in cleaner, more organized code, making it easier to read and maintain.
+- Cleaner Code: The separation of concerns and modularization result in cleaner, more organized code, making it
+ easier to read and maintain.
-- Testability: With well-defined interfaces and dependency injection, unit testing becomes straightforward, ensuring the reliability of the codebase.
+- Testability: With well-defined interfaces and dependency injection, unit testing becomes straightforward,
+ ensuring the reliability of the codebase.
-- Scalability: The architecture's modular nature allows for easy expansion and addition of new features, making the project adaptable to future requirements.
+- Scalability: The architecture's modular nature allows for easy expansion and addition of new features, making
+ the project adaptable to future requirements.
-- Maintainability: Clean Architecture promotes code maintainability, reducing the risk of technical debt and simplifying future updates and enhancements.
+- Maintainability: Clean Architecture promotes code maintainability, reducing the risk of technical debt and
+ simplifying future updates and enhancements.
## ✨ Feature
@@ -54,21 +60,26 @@ LangChain-LineBot serves as a dynamic chat agent chain with an array of essentia
### OpenAI Function Calling
-In addition to its core features, this project implements OpenAI Function Calling. This means that developers can encapsulate desired services as functions and incorporate them into the chatbot through the LangChain agent. We can implement this in `src\infrastructure\tools\`.
+In addition to its core features, this project implements OpenAI Function Calling. This means that developers can
+encapsulate desired services as functions and incorporate them into the chatbot through the LangChain agent. We can
+implement this in `src\infrastructure\tools\`.
### Language Model
-The project leverages the LangChain framework, a powerful tool designed to simplify the integration of language models into applications. Specifically, LangChain is used in this project to seamlessly connect with the OpenAI Language Model (LLM), allowing developers to focus on application development without getting bogged down in the complexities of language processing.
+The project leverages the LangChain framework, a powerful tool designed to simplify the integration of language models
+into applications. Specifically, LangChain is used in this project to seamlessly connect with the OpenAI Language
+Model (LLM), allowing developers to focus on application development without getting bogged down in the complexities of
+language processing.
### Chat Memory
-The ability to remember and recall previous conversations, providing a personalized user experience. Default is PostgreSQL. You can use your memory repositorios by implementing the BaseChatMemory interface.
+The ability to remember and recall previous conversations, providing a personalized user experience. Default is
+PostgreSQL. You can use your memory repositorios by implementing the BaseChatMemory interface.
### System Messages
You can custom your LineBot's personality by setting the CHATBOT_DESCRIPTION in .env file.
-
## 🚀 Getting Started
### ✔️ Prerequisites
@@ -76,14 +87,15 @@ You can custom your LineBot's personality by setting the CHATBOT_DESCRIPTION<
Before you begin, ensure that you have the following prerequisites installed:
1. Setup LINE Channel to get CHANNEL_SECRET and CHANNEL_ACCESS_TOKEN
- > ref: [Day 12:帶著聊天機器人來到 LINE](https://ithelp.ithome.com.tw/articles/10221681)
+ > ref: [Day 12:帶著聊天機器人來到 LINE](https://ithelp.ithome.com.tw/articles/10221681)
2. Get SerpAPI Token
- > ref: [SerpAPI](https://serpapi.com/dashboard)
+ > ref: [SerpAPI](https://serpapi.com/dashboard)
3. Get OpenAI Token
- > ref: [OpenAI-API-keys](https://platform.openai.com/account/api-keys)
+ > ref: [OpenAI-API-keys](https://platform.openai.com/account/api-keys)
4. Setup PostgreSQL and get connect string
- > You can use some PostgreSQL provider like: ElephantSQL, Vercel Postgre...etc.
- I recommand [Zeabur](https://zeabur.com/zh-TW) for a web-hosting PostgreSQL because you can create a project and run the LineBot and PostgreSQL in the same platform. So fast! So easy! So convenient!
+ > You can use some PostgreSQL provider like: ElephantSQL, Vercel Postgre...etc.
+ I recommand [Zeabur](https://zeabur.com/zh-TW) for a web-hosting PostgreSQL because you can create a project and run
+ the LineBot and PostgreSQL in the same platform. So fast! So easy! So convenient!
5. Setup environment variables by creating a .env file
```
CHANNEL_SECRET=
@@ -99,28 +111,30 @@ Before you begin, ensure that you have the following prerequisites installed:
### 📦 Installation
1. Clone the LangChain-LineBot repository:
+
```sh
-git clone https://github.com/ttpss930141011/LangChain-LineBot
+git clone https://github.com/ttpss930141011/yuwen-yorozuya-linebot.git
```
2. Change to the project directory:
+
```sh
-cd LangChain-LineBot
+cd yuwen-yorozuya-linebot
```
3. Install the dependencies:
+
```sh
-pip install -r requirements.txt
+Poetry install
```
-
### 🧪 Running Tests
+
```sh
pytest
```
-
-### 🎮 Using LangChain-LineBot
+### 🎮 Using yuwen-yorozuya-linebot
```sh
python app.py
@@ -138,63 +152,79 @@ python app.py
2. Then put the forwarding url to LineBot Messaging API Webhook url settings.
-
-
-
+
+
#### For Zeabur
1. New project
-
+
2. New services
-
-
+
+
3. Setup environment vairables
-
+
+
---
-## 👨🏫 Demo
-|Keep remember|Search information on the internet|Group assistant|
-|--|--|--|
-|![demo1](./static/images/demo1.jpg)|![demo2](./static/images/demo2.jpg)|![group](./static/images/group.jpg)|
+## 👨🏫 Demo
+| Keep remember | Search information on the internet | Group assistant |
+|-------------------------------------|-------------------------------------|-------------------------------------|
+| ![demo1](./static/images/demo1.jpg) | ![demo2](./static/images/demo2.jpg) | ![group](./static/images/group.jpg) |
---
-
## 📝 Note
### Clean Architecture Transformation
-In the quest for code quality, maintainability, and scalability, the LangChain-LineBot project has embraced Clean Architecture principles. Here's how Clean Architecture has influenced this project's development:
-- Flask + LINE SDK: The project continues to utilize Flask and the LINE SDK as its core technologies, but the key transformation lies in the architecture.
+In the quest for code quality, maintainability, and scalability, the LangChain-LineBot project has embraced Clean
+Architecture principles. Here's how Clean Architecture has influenced this project's development:
-- Blueprints as Handlers: In the Clean Architecture paradigm, message handlers are treated as blueprints. This approach decouples the handling of messages from the application's core logic, making the codebase more modular and maintainable.
+- Flask + LINE SDK: The project continues to utilize Flask and the LINE SDK as its core technologies, but the key
+ transformation lies in the architecture.
-- Controller and Usecase Separation: The traditional controller and use case layers have been restructured, promoting a separation of concerns. Controllers are responsible for handling incoming requests and orchestrating the flow, while use cases encapsulate the application's business logic.
+- Blueprints as Handlers: In the Clean Architecture paradigm, message handlers are treated as blueprints. This
+ approach decouples the handling of messages from the application's core logic, making the codebase more modular and
+ maintainable.
-- Dependency Injection: Extensive use of dependency injection enhances code cleanliness, testability, and extensibility. Dependencies are injected into components, reducing tight coupling and simplifying unit testing.
+- Controller and Usecase Separation: The traditional controller and use case layers have been restructured,
+ promoting a separation of concerns. Controllers are responsible for handling incoming requests and orchestrating the
+ flow, while use cases encapsulate the application's business logic.
+
+- Dependency Injection: Extensive use of dependency injection enhances code cleanliness, testability, and
+ extensibility. Dependencies are injected into components, reducing tight coupling and simplifying unit testing.
### Final
-I am used to implement 3-tier architecture in my project. Accidentally, I heard a sharing by a senior software engineer in development community. He was talking about what is the adventages he felt when he migrated the application to the another application from other company.
+I am used to implement 3-tier architecture in my project. Accidentally, I heard a sharing by a senior software engineer
+in development community. He was talking about what is the adventages he felt when he migrated the application to the
+another application from other company.
-| 3-tier architecture | Clean architecture |
-|--|--|
-|![3-tier architecture](./static/images/Overview_of_a_three-tier_application_vectorVersion.svg)|![Clean architecture](./static/images/CA.png)|
+| 3-tier architecture | Clean architecture |
+|------------------------------------------------------------------------------------------------|-----------------------------------------------|
+| ![3-tier architecture](./static/images/Overview_of_a_three-tier_application_vectorVersion.svg) | ![Clean architecture](./static/images/CA.png) |
-I started to study what is the Clean Architectre by reading two books "[Clean Architecture: A Craftsman's Guide to Software Structure and Design](https://a.co/d/b6AwM2R)" and "[Architecture Patterns with Python: Enabling Test-Driven Development, Domain-Driven Design, and Event-Driven Microservices](https://a.co/d/dhmMraK)".
+I started to study what is the Clean Architectre by reading two
+books "[Clean Architecture: A Craftsman's Guide to Software Structure and Design](https://a.co/d/b6AwM2R)"
+and "[Architecture Patterns with Python: Enabling Test-Driven Development, Domain-Driven Design, and Event-Driven Microservices](https://a.co/d/dhmMraK)".
-Although the project I made in formar job didn't have too complicated dependency like "Big Ball of yarn", I can imagine it will be annoying if I gonna change infrustructure or framework one day. In the project, I wrote many interfaces to make dependency to easily inject. I think a large number of dependency inversions is one of the important aspects why Clean Architecture is attractive.
+Although the project I made in formar job didn't have too complicated dependency like "Big Ball of yarn", I can imagine
+it will be annoying if I gonna change infrustructure or framework one day. In the project, I wrote many interfaces to
+make dependency to easily inject. I think a large number of dependency inversions is one of the important aspects why
+Clean Architecture is attractive.
-Finally, I will continue to delve deeper into Clean Architecture, especially with regards to the implementation of entities and the definition of value objects. I'm not yet entirely familiar with these concepts in the context of this project, so my plan is to further study and explore them in greater detail.
+Finally, I will continue to delve deeper into Clean Architecture, especially with regards to the implementation of
+entities and the definition of value objects. I'm not yet entirely familiar with these concepts in the context of this
+project, so my plan is to further study and explore them in greater detail.
---
@@ -207,11 +237,10 @@ The following is todo-list on LineBot:
- [ ] Give YouTube link and return video summary
- [ ] Give the file and start the document conversation
-
-
-
---
## 📄 License
-This project is licensed under the MIT License. See the [LICENSE](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-license-to-a-repository) file for additional info.
+This project is licensed under the MIT License. See
+the [LICENSE](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-license-to-a-repository)
+file for additional info.
diff --git a/pyproject.toml b/pyproject.toml
index 299653e..35885de 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -7,30 +7,31 @@ license = "MIT license"
readme = "README.md"
[tool.poetry.dependencies]
-python = "^3.10"
-cerberus = "^1.3.5"
-flask = "^2.3.3"
-flask-sqlalchemy = "^3.1.1"
-langchain = "^0.0.301"
-line-bot-sdk = "^3.5.0"
-marshmallow = "^3.20.1"
-pydantic = "^2.4.0"
+python = "3.10.12"
+cerberus = "1.3.5"
+charset-normalizer = "3.3.2"
+flask = "2.3.3"
+flask-sqlalchemy = "3.1.1"
+langchain = "0.0.295"
+line-bot-sdk = "3.1.0"
+marshmallow = "3.20.1"
+pydantic = "1.10.12"
python-dotenv = "^1.0.0"
-sqlalchemy = "^2.0.21"
-werkzeug = "^2.3.7"
-yfinance = "^0.2.30"
-psycopg2 = "^2.9.7"
-openai = "^0.28.0"
-tiktoken = "^0.5.1"
-google-search-results = "^2.4.2"
+sqlalchemy = "2.0.19"
+werkzeug = "2.3.6"
+yfinance = "0.2.28"
+psycopg2 = "2.9.7"
+openai = "0.27.8"
+tiktoken = "0.4.0"
+google-search-results = "2.4.2"
[tool.poetry.group.dev.dependencies]
-pytest = "^7.4.2"
-pytest-cov = "^4.1.0"
-pytest-cover = "^3.0.0"
-pytest-coverage = "^0.0"
-pytest-flask = "^1.2.0"
-pytest-mock = "^3.11.1"
+pytest = "7.3.1"
+pytest-cov = "4.0.0"
+pytest-cover = "3.0.0"
+pytest-coverage = "0.0"
+pytest-flask = "1.2.0"
+pytest-mock = "3.10.0"
[build-system]
requires = ["poetry-core"]
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index ab0638f..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-Cerberus==1.3.5
-Flask==2.3.2
-flask_sqlalchemy==3.1.1
-langchain==0.0.295
-line_bot_sdk==3.1.0
-marshmallow==3.20.1
-pydantic==1.10.12
-pylint==2.17.2
-pylint-pytest==1.1.2
-pytest==7.3.1
-pytest-cov==4.0.0
-pytest-cover==3.0.0
-pytest-coverage==0.0
-pytest-flask==1.2.0
-pytest-mock==3.10.0
-python-dotenv==1.0.0
-SQLAlchemy==2.0.19
-Werkzeug==2.3.6
-yfinance==0.2.28
-psycopg2==2.9.7
-openai==0.27.8
-tiktoken==0.4.0
-google-search-results==2.4.2
-flake8==6.1.0