Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 28aede4

Browse files
committed
Merge branch 'main' of github.com:stacklok/codegate into feat/555/version-endpoint
2 parents 8f683f7 + dceeef8 commit 28aede4

File tree

17 files changed

+687
-119
lines changed

17 files changed

+687
-119
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ body:
4545
attributes:
4646
label: "IDE and Version"
4747
description: "Enter the IDE name and version."
48-
placeholder: "e.g., VS Code 1.78.0"
48+
placeholder: "e.g. VS Code 1.78.0"
4949
validations:
5050
required: true
5151

@@ -54,7 +54,7 @@ body:
5454
attributes:
5555
label: "Extension and Version"
5656
description: "Enter the extension name and version."
57-
placeholder: "e.g., Proxy Extension 0.5.1"
57+
placeholder: "e.g. Proxy Extension 0.5.1"
5858
validations:
5959
required: true
6060

@@ -77,8 +77,17 @@ body:
7777
id: model
7878
attributes:
7979
label: "Model"
80-
description: "Enter the model name used (e.g., GPT-4, Claude 3)."
81-
placeholder: "e.g., GPT-4"
80+
description: "Enter the model name used (e.g. GPT-4, Claude 3)."
81+
placeholder: "e.g. GPT-4"
82+
validations:
83+
required: true
84+
85+
- type: input
86+
id: codegate-version
87+
attributes:
88+
label: "Codegate version"
89+
description: "Enter the version of CodeGate (e.g. `v0.1.8`, `4845e00c039e`)."
90+
placeholder: "e.g. v0.1.8"
8291
validations:
8392
required: true
8493

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""introduce workspaces
2+
3+
Revision ID: 5c2f3eee5f90
4+
Revises: 30d0144e1a50
5+
Create Date: 2025-01-15 19:27:08.230296
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
from alembic import op
12+
13+
# revision identifiers, used by Alembic.
14+
revision: str = "5c2f3eee5f90"
15+
down_revision: Union[str, None] = "30d0144e1a50"
16+
branch_labels: Union[str, Sequence[str], None] = None
17+
depends_on: Union[str, Sequence[str], None] = None
18+
19+
20+
def upgrade() -> None:
21+
# Workspaces table
22+
op.execute(
23+
"""
24+
CREATE TABLE workspaces (
25+
id TEXT PRIMARY KEY, -- UUID stored as TEXT
26+
name TEXT NOT NULL,
27+
UNIQUE (name)
28+
);
29+
"""
30+
)
31+
op.execute("INSERT INTO workspaces (id, name) VALUES ('1', 'default');")
32+
# Sessions table
33+
op.execute(
34+
"""
35+
CREATE TABLE sessions (
36+
id TEXT PRIMARY KEY, -- UUID stored as TEXT
37+
active_workspace_id TEXT NOT NULL,
38+
last_update DATETIME NOT NULL,
39+
FOREIGN KEY (active_workspace_id) REFERENCES workspaces(id)
40+
);
41+
"""
42+
)
43+
# Alter table prompts
44+
op.execute("ALTER TABLE prompts ADD COLUMN workspace_id TEXT REFERENCES workspaces(id);")
45+
op.execute("UPDATE prompts SET workspace_id = '1';")
46+
# Create index for workspace_id
47+
op.execute("CREATE INDEX idx_prompts_workspace_id ON prompts (workspace_id);")
48+
# Create index for session_id
49+
op.execute("CREATE INDEX idx_sessions_workspace_id ON sessions (active_workspace_id);")
50+
51+
52+
def downgrade() -> None:
53+
# Drop the index for workspace_id
54+
op.execute("DROP INDEX IF EXISTS idx_prompts_workspace_id;")
55+
op.execute("DROP INDEX IF EXISTS idx_sessions_workspace_id;")
56+
# Remove the workspace_id column from prompts table
57+
op.execute("ALTER TABLE prompts DROP COLUMN workspace_id;")
58+
# Drop the sessions table
59+
op.execute("DROP TABLE IF EXISTS sessions;")
60+
# Drop the workspaces table
61+
op.execute("DROP TABLE IF EXISTS workspaces;")

poetry.lock

Lines changed: 57 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ click = "==8.1.8"
1111
PyYAML = "==6.0.2"
1212
fastapi = "==0.115.6"
1313
uvicorn = "==0.34.0"
14-
structlog = "==24.4.0"
14+
structlog = "==25.1.0"
1515
litellm = "==1.58.0"
1616
llama_cpp_python = "==0.3.5"
1717
cryptography = "==44.0.0"
@@ -20,7 +20,7 @@ aiosqlite = "==0.20.0"
2020
ollama = "==0.4.6"
2121
pydantic-settings = "==2.7.1"
2222
numpy = "==2.2.1"
23-
tree-sitter = "==0.23.2"
23+
tree-sitter = "==0.24.0"
2424
tree-sitter-go = "==0.23.4"
2525
tree-sitter-java = "==0.23.5"
2626
tree-sitter-javascript = "==0.23.1"
@@ -34,7 +34,7 @@ pygments = "==2.19.1"
3434
pytest = "==8.3.4"
3535
pytest-cov = "==6.0.0"
3636
black = "==24.10.0"
37-
ruff = "==0.9.1"
37+
ruff = "==0.9.2"
3838
bandit = "==1.8.2"
3939
build = "==1.2.2.post1"
4040
wheel = "==0.45.1"

src/codegate/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
_VERSION = "dev"
1111
_DESC = "CodeGate - A Generative AI security gateway."
1212

13+
1314
def __get_version_and_description() -> tuple[str, str]:
1415
try:
1516
version = metadata.version("codegate")
@@ -19,6 +20,7 @@ def __get_version_and_description() -> tuple[str, str]:
1920
description = _DESC
2021
return version, description
2122

23+
2224
__version__, __description__ = __get_version_and_description()
2325

2426
__all__ = ["Config", "ConfigurationError", "LogFormat", "LogLevel", "setup_logging"]

src/codegate/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from codegate.ca.codegate_ca import CertificateAuthority
1515
from codegate.codegate_logging import LogFormat, LogLevel, setup_logging
1616
from codegate.config import Config, ConfigurationError
17-
from codegate.db.connection import init_db_sync
17+
from codegate.db.connection import init_db_sync, init_session_if_not_exists
1818
from codegate.pipeline.factory import PipelineFactory
1919
from codegate.pipeline.secrets.manager import SecretsManager
2020
from codegate.providers.copilot.provider import CopilotProvider
@@ -307,6 +307,7 @@ def serve(
307307
logger = structlog.get_logger("codegate").bind(origin="cli")
308308

309309
init_db_sync(cfg.db_path)
310+
init_session_if_not_exists(cfg.db_path)
310311

311312
# Check certificates and create CA if necessary
312313
logger.info("Checking certificates and creating CA if needed")

0 commit comments

Comments
 (0)