Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,38 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '20'


- name: Install UV
uses: astral-sh/setup-uv@v1
with:
version: "0.6.16"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
uv sync
uv pip install -e .[dev]
npm ci

- name: Lint with flake8
run: |
poetry run flake8 chatiq
uv run flake8 chatiq

- name: Check code formatting
run: |
poetry run black --check chatiq
uv run black --check chatiq

- name: Check imports with isort
run: |
poetry run isort chatiq --check --diff
uv run isort chatiq --check --diff

- name: Run Pytype
run: |
poetry run pytype chatiq
uv run pytype chatiq

- name: Run unit tests and measure code coverage
run: |
poetry run coverage run -m pytest
poetry run coverage xml
uv run coverage run -m pytest
uv run coverage xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
Expand All @@ -68,7 +72,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish package
run: poetry publish --build -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}
run: |
uv pip build .
uv pip publish --api-token ${{ secrets.PYPI_API_TOKEN }}
if: ${{ steps.semantic-release.outputs.nextVer != null }}

- name: Set up QEMU
Expand Down
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "always"
},
"editor.tabSize": 4
},
Expand All @@ -22,5 +22,6 @@
"editor.tabSize": 4
},
"isort.args":["--profile", "black"],
"terminal.integrated.copyOnSelection": true
"terminal.integrated.copyOnSelection": true,
"python.packageManager": "uv"
}
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ WORKDIR /app
# for print statements and avoid output buffering.
ENV PYTHONUNBUFFERED 1

# Install UV
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

# Copy dependency files
COPY pyproject.toml package.json package-lock.json ./

RUN pip install --no-cache-dir poetry \
&& poetry config virtualenvs.create false \
&& poetry install --without dev --no-interaction --no-ansi
# Install dependencies
RUN uv sync --frozen

#######################
## Development stage ##
Expand All @@ -36,8 +39,8 @@ RUN npm install
# Initialize an empty Git repository
# for allowing pre-commit install to run without errors.
RUN git init \
&& poetry install --no-interaction --no-ansi \
&& poetry run pre-commit install
&& uv sync --dev \
&& uv run pre-commit install

# indicate what port the server is running on
EXPOSE 3000
Expand All @@ -49,8 +52,12 @@ CMD ["flask", "--app", "chatiq.main:app", "--debug", "run", "--host", "0.0.0.0",
#######################
FROM base AS production

# Copy application code
COPY . .

# Set PATH to include UV tool bin directory
ENV PATH="/usr/local/bin:${PATH}"

# indicate what port the server is running on
EXPOSE 3000

Expand Down
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ git clone https://github.com/yujiosaka/ChatIQ.git
cd chatiq
```

3. Install `poetry`:
3. Install `uv`:

```sh
pip install poetry
pip install uv
```

4. Run the `setup_dev_env.sh` script to set up your development environment:
Expand All @@ -225,6 +225,16 @@ pip install poetry
flask --app chatiq.main:app --debug run
```

### Managing Dependencies

When modifying dependencies in `pyproject.toml`, make sure to update the `requirements.txt` file by running:

```sh
uv pip compile pyproject.toml -o requirements.txt
```

This ensures that the `requirements.txt` file stays in sync with the dependencies defined in `pyproject.toml`. The `requirements.txt` file is used by various deployment processes and should be committed to the repository whenever dependencies are updated.

### Docker Dev Container Setup

Using Visual Studio Code and the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension, you can simplify the development environment setup process. The extension allows you to develop inside a Docker container and automatically sets up the development environment for you.
Expand Down Expand Up @@ -402,16 +412,16 @@ That's it! The ChatIQ Slack app is now installed in your workspace.

## Building and Publishing

1. To build the project, use the `poetry build` command:
1. To build the project, use the `uv pip build` command:

```sh
poetry build
uv pip build .
```

2. To upload the built package to PyPI, use `poetry publish` command:
2. To upload the built package to PyPI, use `uv pip publish` command:

```sh
poetry publish
uv pip publish
```

## Linting and Formatting
Expand All @@ -421,25 +431,25 @@ This project uses `flake8` for linting, `black` for code formatting, `isort` for
To lint the code, run:

```sh
flake8
uv run flake8
```

To format the code, run:

```sh
black .
uv run black .
```

To organize imports, run:

```sh
isort .
uv run isort .
```

To perform type checking with pytype, run:

```sh
pytype chatiq
uv run pytype chatiq
```

## Limitations and Considerations
Expand Down
8 changes: 4 additions & 4 deletions chatiq/document_loaders/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from typing import Iterator, List

import requests
from langchain.docstore.document import Document
from langchain.document_loaders.base import BaseLoader
from langchain.document_loaders.blob_loaders import Blob
from langchain.document_loaders.parsers.pdf import PyMuPDFParser
from langchain.text_splitter import TokenTextSplitter
from langchain_community.docstore.document import Document
from langchain_community.document_loaders.base import BaseLoader
from langchain_community.document_loaders.blob_loaders import Blob
from langchain_community.document_loaders.parsers.pdf import PyMuPDFParser
from slack_bolt import BoltContext

from chatiq.constants import FILE_DOCUMENT_THREAD_TS
Expand Down
4 changes: 2 additions & 2 deletions chatiq/handlers/app_mention.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from logging import Logger
from typing import Callable, List, Tuple

from langchain.chat_models import ChatOpenAI
from langchain.memory import ConversationTokenBufferMemory
from langchain_community.chat_models import ChatOpenAI
from langchain_community.memory import ConversationTokenBufferMemory
from openai import BadRequestError, OpenAIError
from slack_sdk.errors import SlackApiError
from slack_sdk.web.client import WebClient
Expand Down
4 changes: 2 additions & 2 deletions chatiq/retriever.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from langchain.vectorstores import Weaviate
from langchain.vectorstores.base import VectorStoreRetriever
from langchain_community.vectorstores import Weaviate
from langchain_core.vectorstores import VectorStoreRetriever


class Retriever(VectorStoreRetriever):
Expand Down
2 changes: 1 addition & 1 deletion chatiq/vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, List

from langchain.docstore.document import Document
from langchain.vectorstores import Weaviate
from langchain_community.vectorstores import Weaviate
from weaviate import Client
from weaviate.exceptions import WeaviateBaseError

Expand Down
Loading
Loading