Skip to content
Merged
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
35 changes: 35 additions & 0 deletions .github/workflows/pr-lint-typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PR Lint and Type Check

on:
pull_request:
paths:
- ".github/workflows/pr-lint-typecheck.yml"
- "pyproject.toml"
- "uv.lock"
- "stackchan_server/**"
- "example_apps/**"

jobs:
lint-and-typecheck:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup uv
uses: astral-sh/setup-uv@v6

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install dependencies
run: uv sync --group dev --group example-gemini --frozen

- name: Ruff
run: uv run ruff check stackchan_server example_apps

- name: ty
run: uv run ty check stackchan_server example_apps
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ async def talk_session(proxy: WsProxy):
```



## Lint / Type Check

`stackchan_server/` と `example_apps/` を対象に、`uv` で Ruff と ty を実行できます。

```bash
uv sync --group dev --group example-gemini
uv run ruff check stackchan_server example_apps
uv run ty check stackchan_server example_apps
```

## 現在開発中の環境

- 本体: M5Stack CoreS3 SE
Expand Down
6 changes: 3 additions & 3 deletions example_apps/gemini.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import annotations

import asyncio
from logging import StreamHandler, getLogger

from stackchan_server.app import StackChanApp
from stackchan_server.ws_proxy import WsProxy
from google import genai
from google.genai import types

from stackchan_server.app import StackChanApp
from stackchan_server.ws_proxy import WsProxy

logger = getLogger(__name__)
logger.addHandler(StreamHandler())
logger.setLevel("DEBUG")
Expand Down
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@ description = "A WebSocket control interface for StackChan AI agent"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"fastapi[websockets]>=0.128.0",
"fastapi>=0.128.0",
"google-cloud-speech>=2.35.0",
"uvicorn[standard]>=0.40.0",
"voicevox-client>=1.1.0",
]

[dependency-groups]
dev = [
"ruff>=0.15.2",
"ty>=0.0.17",
]
example-gemini = [
"google-genai>=1.59.0",
]

[tool.ruff]
target-version = "py313"


[tool.hatch.build.targets.wheel]
packages = ["stackchan_server"]

Expand Down
4 changes: 2 additions & 2 deletions stackchan_server/ws_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import struct
import wave
from contextlib import suppress
from datetime import datetime
from datetime import UTC, datetime
from enum import IntEnum
from logging import getLogger
from pathlib import Path
Expand Down Expand Up @@ -380,7 +380,7 @@ async def _send_state_command(self, state_id: int | FirmwareState) -> None:
self._down_seq += 1

def _save_wav(self, pcm_bytes: bytes) -> tuple[Path, str]:
timestamp = datetime.utcnow().strftime("%Y%m%d_%H%M%S_%f")
timestamp = datetime.now(UTC).strftime("%Y%m%d_%H%M%S_%f")
filename = f"rec_ws_{timestamp}.wav"
filepath = self.recordings_dir / filename

Expand Down
Loading