Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.13 support #1430

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/actions/poetry-python-install/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
python-version:
description: Python version
required: true
default: '3.9'
default: '3.10'
poetry-version:
description: Poetry version
required: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
fastapi-version: ['0.110', '0.111', '0.112']
python-version: ['3.10', '3.11', '3.12', '3.13']
fastapi-version: ['0.115']
env:
BACKEND_DIR: ./backend
steps:
Expand Down
4 changes: 2 additions & 2 deletions backend/chainlit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
)
from chainlit.step import Step, step
from chainlit.sync import make_async, run_sync
from chainlit.types import InputAudioChunk, OutputAudioChunk, ChatProfile, Starter
from chainlit.types import ChatProfile, InputAudioChunk, OutputAudioChunk, Starter
from chainlit.user import PersistedUser, User
from chainlit.user_session import user_session
from chainlit.utils import make_module_getattr
Expand All @@ -57,9 +57,9 @@
author_rename,
header_auth_callback,
oauth_callback,
on_audio_start,
on_audio_chunk,
on_audio_end,
on_audio_start,
on_chat_end,
on_chat_resume,
on_chat_start,
Expand Down
5 changes: 2 additions & 3 deletions backend/chainlit/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ def create_jwt(data: User) -> str:
to_encode: Dict[str, Any] = data.to_dict()
to_encode.update(
{
"exp": datetime.utcnow() + timedelta(
seconds=config.project.user_session_timeout
),
"exp": datetime.utcnow()
+ timedelta(seconds=config.project.user_session_timeout),
}
)
encoded_jwt = jwt.encode(to_encode, get_jwt_secret(), algorithm="HS256")
Expand Down
14 changes: 7 additions & 7 deletions backend/chainlit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if TYPE_CHECKING:
from chainlit.action import Action
from chainlit.message import Message
from chainlit.types import InputAudioChunk, ChatProfile, Starter, ThreadDict
from chainlit.types import ChatProfile, InputAudioChunk, Starter, ThreadDict
from chainlit.user import User
from fastapi import Request, Response

Expand Down Expand Up @@ -272,9 +272,9 @@ class CodeSettings:
password_auth_callback: Optional[
Callable[[str, str], Awaitable[Optional["User"]]]
] = None
header_auth_callback: Optional[
Callable[[Headers], Awaitable[Optional["User"]]]
] = None
header_auth_callback: Optional[Callable[[Headers], Awaitable[Optional["User"]]]] = (
None
)
oauth_callback: Optional[
Callable[[str, str, Dict[str, str], "User"], Awaitable[Optional["User"]]]
] = None
Expand All @@ -293,9 +293,9 @@ class CodeSettings:
set_chat_profiles: Optional[
Callable[[Optional["User"]], Awaitable[List["ChatProfile"]]]
] = None
set_starters: Optional[
Callable[[Optional["User"]], Awaitable[List["Starter"]]]
] = None
set_starters: Optional[Callable[[Optional["User"]], Awaitable[List["Starter"]]]] = (
None
)


@dataclass()
Expand Down
2 changes: 1 addition & 1 deletion backend/chainlit/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ async def get_file(
detail="Unauthorized",
)

#TODO: Causes 401 error. See https://github.com/Chainlit/chainlit/issues/1472
# TODO: Causes 401 error. See https://github.com/Chainlit/chainlit/issues/1472
# if current_user:
# if not session.user or session.user.identifier != current_user.identifier:
# raise HTTPException(
Expand Down
356 changes: 149 additions & 207 deletions backend/poetry.lock

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ chainlit = 'chainlit.cli:cli'
script = "build.py"

[tool.poetry.dependencies]
python = ">=3.9,<4.0.0"
python = ">=3.10,<4.0.0"
httpx = ">=0.23.0"
literalai = "0.0.623"
dataclasses_json = "^0.6.7"
fastapi = ">=0.110.1,<0.113"
starlette = "^0.37.2"
uvicorn = "^0.25.0"
fastapi = ">=0.115.3,<0.116"
starlette = "^0.41.2"
uvicorn = "^0.32.0"
python-socketio = "^5.11.0"
aiofiles = "^23.1.0"
syncer = "^2.0.3"
Expand All @@ -62,7 +62,6 @@ lazify = "^0.4.0"
packaging = "^23.1"
python-multipart = "^0.0.9"
pyjwt = "^2.8.0"
numpy = "^1.26"

[tool.poetry.group.tests]
optional = true
Expand Down Expand Up @@ -101,7 +100,7 @@ mypy-boto3-dynamodb = "^1.34.113"
pandas-stubs = { version = "^2.2.2", python = ">=3.9" }

[tool.mypy]
python_version = "3.9"
python_version = "3.10"


[[tool.mypy.overrides]]
Expand All @@ -122,9 +121,6 @@ module = [
ignore_missing_imports = true





[tool.poetry.group.custom-data]
optional = true

Expand Down
10 changes: 5 additions & 5 deletions backend/tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import datetime # Added import for datetime
import os
from pathlib import Path
import pathlib
import tempfile
from pathlib import Path
from typing import Callable
from unittest.mock import AsyncMock, Mock, create_autospec, mock_open
import datetime # Added import for datetime

import pytest
import tempfile
from chainlit.session import WebsocketSession
from chainlit.auth import get_current_user
from chainlit.config import APP_ROOT, ChainlitConfig, load_config
from chainlit.server import app
from fastapi.testclient import TestClient
from chainlit.session import WebsocketSession
from chainlit.types import FileReference
from chainlit.user import PersistedUser # Added import for PersistedUser
from fastapi.testclient import TestClient


@pytest.fixture
Expand Down
Loading