Skip to content

Commit 1b971ca

Browse files
authored
Merge pull request #5 from Ontos-AI/staging
Staging
2 parents 53167fb + 7d6a94c commit 1b971ca

81 files changed

Lines changed: 2090 additions & 12733 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/codeql/codeql-config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: "Knowhere CodeQL config"
2+
3+
paths-ignore:
4+
- apps/api/scripts/**
5+
- packages/shared-python/shared/utils/api_keys.py

.github/workflows/codeql.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CodeQL
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- staging
8+
9+
permissions:
10+
contents: read
11+
security-events: write
12+
actions: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
analyze:
20+
name: Analyze
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 30
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v6
27+
with:
28+
persist-credentials: false
29+
30+
- name: Initialize CodeQL
31+
uses: github/codeql-action/init@v4
32+
with:
33+
languages: python
34+
queries: security-extended,security-and-quality
35+
config-file: ./.github/codeql/codeql-config.yml
36+
37+
- name: Set up Python
38+
uses: actions/setup-python@v6
39+
with:
40+
python-version: "3.11"
41+
42+
- name: Autobuild
43+
uses: github/codeql-action/autobuild@v4
44+
45+
- name: Perform CodeQL analysis
46+
uses: github/codeql-action/analyze@v4

.github/workflows/pr-ci.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ on:
55
branches:
66
- main
77
- staging
8-
push:
9-
branches:
10-
- main
11-
- staging
12-
workflow_dispatch:
138

149
permissions:
1510
contents: read
@@ -20,7 +15,7 @@ concurrency:
2015

2116
env:
2217
PYTHON_VERSION: "3.11"
23-
UV_VERSION: "0.10.0"
18+
UV_VERSION: "0.11.7"
2419
UV_LINK_MODE: copy
2520

2621
jobs:
@@ -47,8 +42,6 @@ jobs:
4742
enable-cache: true
4843
cache-dependency-glob: |
4944
uv.lock
50-
apps/*/uv.lock
51-
packages/*/uv.lock
5245
5346
- name: Install dependencies
5447
run: uv sync --locked --all-packages --all-groups
@@ -79,8 +72,6 @@ jobs:
7972
enable-cache: true
8073
cache-dependency-glob: |
8174
uv.lock
82-
apps/*/uv.lock
83-
packages/*/uv.lock
8475
8576
- name: Install dependencies
8677
run: uv sync --locked --all-packages --all-groups
@@ -111,8 +102,6 @@ jobs:
111102
enable-cache: true
112103
cache-dependency-glob: |
113104
uv.lock
114-
apps/*/uv.lock
115-
packages/*/uv.lock
116105
117106
- name: Install dependencies
118107
run: uv sync --locked --all-packages --all-groups

.github/workflows/secret-scan.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ on:
55
branches:
66
- main
77
- staging
8-
push:
9-
branches:
10-
- main
11-
- staging
12-
workflow_dispatch:
13-
schedule:
14-
- cron: "17 3 * * *"
158

169
permissions:
1710
contents: read

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ build/
1212
__pycache__/
1313
*.pyc
1414
*.pyo
15+
.coverage
1516
.venv/
1617
venv/
1718
venv_pptx2md/
@@ -46,6 +47,7 @@ logs/
4647
*.log
4748

4849
# Generated files
50+
.build/
4951
apps/api/openapi.json
5052
packages/shared-types/generated/
5153

README.md

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ knowhere-api/
3737
- Python 3.11+
3838
- `uv`
3939
- Docker with `docker compose`
40-
- a local Chrome or Chromium driver if you plan to run document layout parsing
41-
flows
4240

4341
## Configuration
4442

@@ -61,51 +59,35 @@ cp apps/worker/.env.example apps/worker/.env
6159

6260
- database and Redis connection settings
6361
- S3-compatible storage credentials
64-
- `SECRET_KEY`
65-
- `USERS_DATA_PATH`
6662
- `DS_KEY`
6763
- any optional LLM, billing, or webhook providers you want to enable
6864

69-
The example files default to the open-source/self-hosted behavior:
70-
71-
- `API_STANDALONE_MODE_ENABLED=false` for the combined dashboard + API flow, where
72-
the dashboard initializes Better Auth tables before API migrations.
73-
- `BILLING_ENABLED=false`, so Stripe and credit deduction are not required.
74-
- `RATE_LIMIT_ENABLED=false` for local/self-hosted convenience; set it to
75-
`true` when you want API rate limits enforced.
76-
77-
For API-only development without the dashboard, set `API_STANDALONE_MODE_ENABLED=true`,
78-
run API migrations, then create an API-only user/key:
79-
80-
```bash
81-
cd apps/api
82-
uv run --python 3.11 python -m alembic upgrade heads
83-
uv run --python 3.11 python scripts/init_user.py --email you@example.com
84-
```
85-
86-
If you plan to use the dashboard, start the combined self-hosted stack and
87-
register through the dashboard instead of using `scripts/init_user.py`.
88-
8965
4. Start the local infrastructure stack:
9066

9167
```bash
9268
./deploy/local-dev/start-dev.sh
9369
```
9470

95-
If you also want the helper to initialize the local API user state, rerun it
96-
with `--init-user`:
71+
5. Start the API and worker in separate terminals:
9772

9873
```bash
99-
./deploy/local-dev/start-dev.sh --init-user
74+
cd apps/api && uv run main.py
75+
cd apps/worker && uv run worker.py
10076
```
10177

102-
5. Start the API and worker in separate terminals:
78+
The API runs migrations during startup.
79+
80+
For API-only development without the dashboard, create an API-only user/key
81+
after the API service starts:
10382

10483
```bash
105-
cd apps/api && uv run main.py
106-
cd apps/worker && uv run worker.py
84+
cd apps/api
85+
uv run scripts/init_user.py --email you@example.com
10786
```
10887

88+
If you plan to use the dashboard, register through the dashboard instead of
89+
using `scripts/init_user.py`.
90+
10991
## Quality Checks
11092

11193
Run lint checks from the repository root:

apps/api/.env.example

Lines changed: 7 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Required for specific features:
1111
# - alternate object storage callbacks
1212
# - webhooks and async callback delivery
13-
# - billing, email, analytics, and dashboard auth providers
13+
# - billing and analytics
1414
# - alternate parsing providers
1515
#
1616
# Optional or development-only values can stay empty unless you need the
@@ -19,20 +19,13 @@
1919
# Required for local startup: application runtime
2020
ENVIRONMENT=development
2121
APP_ENV=
22-
DEBUG=true
2322
LOG_LEVEL=INFO
2423
APP_TITLE=Knowhere API
2524
APP_VERSION=1.0.0
2625
APP_DESCRIPTION=Document ingestion, retrieval, and MCP backend
27-
SECRET_KEY=replace-with-a-long-random-secret
28-
ALGORITHM=HS256
29-
ACCESS_TOKEN_EXPIRE_MINUTES=10080
3026
INTERNAL_DASHBOARD_ENDPOINT=http://localhost:3000
31-
API_STANDALONE_MODE_ENABLED=false
27+
API_STANDALONE_MODE_ENABLED=true
3228
TMP_PATH=/tmp/knowhere
33-
FONT_PATH=/usr/share/fonts
34-
CHROMEDRIVER_PATH=/usr/bin/chromedriver
35-
USERS_DATA_PATH=/tmp/knowhere-users
3629

3730
# Optional or development-only: observability and local dashboard wiring
3831
LOGFIRE_TOKEN=
@@ -46,7 +39,7 @@ DB_SSL_MODE=disable
4639
# DB_SSL_ROOT_CERT=/path/to/ca-cert.pem
4740

4841
# Required for local startup: Redis / Celery
49-
RATE_LIMIT_ENABLED=false
42+
RATE_LIMIT_ENABLED=true
5043
REDIS_HOST=localhost
5144
REDIS_PORT=6379
5245
REDIS_PASSWORD=
@@ -57,7 +50,6 @@ BROKER_POOL_LIMIT=10
5750
# Required for local startup: S3-compatible storage
5851
S3_TYPE=s3
5952
S3_BUCKET_NAME=knowhere-uploads
60-
S3_UPLOADS_BUCKET=knowhere-uploads
6153
S3_RESULTS_BUCKET=knowhere-results
6254
S3_ACCESS_KEY_ID=test
6355
S3_SECRET_ACCESS_KEY=test
@@ -68,7 +60,6 @@ S3_REGION=us-west-1
6860
S3_USE_SSL=false
6961
S3_ADDRESSING_STYLE=path
7062
S3_WEBHOOK_AUTH_TOKEN=replace-with-a-shared-secret
71-
SNS_SIGNATURE_VERIFICATION=true
7263

7364
# Required for specific features: OSS settings
7465
OSS_ENDPOINT=
@@ -90,7 +81,6 @@ ALI_SDK_MAX_RETRIES=3
9081
ALI_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
9182
ARK_API_KEY=
9283
ARK_URL=https://ark.cn-beijing.volces.com/api/v3/chat/completions
93-
EMBEDDING_MODEL=text-embedding-v4
9484
NORMOL_MODEL=deepseek-chat
9585
HIERARCHY_LLM_MODEL=qwen3.6-flash
9686
IMAGE_MODEL=qwen3.5-flash
@@ -99,58 +89,23 @@ IMAGE_MODEL_MAX=qwen3.5-flash
9989
# File handling defaults
10090
SUPPORTED_EXTENSIONS=.doc,.docx,.pdf,.txt,.xls,.xlsx,.csv,.pptx,.jpg,.jpeg,.png,.md
10191
MAX_FILE_SIZE=104857600
102-
MAX_IMAGE_SIZE=10485760
103-
MIN_CONFIDENCE_THRESHOLD=0.05
104-
HIGH_IOU_THRESHOLD=0.9
105-
DEFAULT_EMBEDDING_DIM=1024
106-
DEFAULT_TOP_K=5
107-
DEFAULT_BATCH_SIZE=32
108-
DEFAULT_EPOCHS=3
109-
DEFAULT_THRESHOLD=0.5
11092

11193
# Required for specific features: webhooks and callbacks
112-
WEBHOOK_SIGNING_SECRET=
11394
WEBHOOK_MASTER_KEY=
11495
QSTASH_TOKEN=
11596
QSTASH_CALLBACK_BASE_URL=https://api.example.com/api/v1
11697
QSTASH_MAX_RETRIES=5
11798
# QSTASH_CURRENT_SIGNING_KEY=
11899
# QSTASH_NEXT_SIGNING_KEY=
119100

120-
# Required for specific features: billing and notifications
121-
BILLING_ENABLED=false
101+
# Required for specific features: billing and analytics
102+
BILLING_ENABLED=true
122103
STRIPE_SECRET_KEY=
123-
STRIPE_PUBLISHABLE_KEY=
124104
STRIPE_WEBHOOK_SECRET=
125-
RESEND_API_KEY=
126-
RESEND_FROM_EMAIL=noreply@example.com
127-
RESEND_FROM_NAME=Knowhere
128-
RESEND_MAX_RETRIES=3
129-
RESEND_RETRY_DELAY=1.0
130-
RESEND_TEMPLATE_WELCOME=
131-
RESEND_TEMPLATE_PURCHASE_CONFIRMATION=
132-
RESEND_TEMPLATE_JOB_COMPLETION=
133-
RESEND_TEMPLATE_JOB_FAILURE=
134-
RESEND_TEMPLATE_WELCOME_ENABLED=false
135-
RESEND_TEMPLATE_PURCHASE_CONFIRMATION_ENABLED=false
136-
RESEND_TEMPLATE_JOB_COMPLETION_ENABLED=false
137-
RESEND_TEMPLATE_JOB_FAILURE_ENABLED=false
138105
MOESIF_APPLICATION_ID=
139-
NEXT_PUBLIC_POSTHOG_KEY=
140-
NEXT_PUBLIC_POSTHOG_HOST=https://app.posthog.com
141106
FREE_PLAN_INITIAL_CREDITS=5
142107
FRONTEND_URL=http://localhost:3000
143108

144-
# Required for specific features: dashboard and auth providers
145-
USERS_VERIFY_TOKEN_SECRET=
146-
USERS_RESET_PASSWORD_TOKEN_SECRET=
147-
GOOGLE_CLIENT_ID=
148-
GOOGLE_CLIENT_SECRET=
149-
GITHUB_CLIENT_ID=
150-
GITHUB_CLIENT_SECRET=
151-
APPLE_CLIENT_ID=
152-
APPLE_CLIENT_SECRET=
153-
154109
# Required for specific features: parsing providers
155110
MINERU_API_KEYS=
156111
MINERU_URL=https://mineru.net/api/v4
@@ -163,13 +118,6 @@ ILOVEAPI_SECRET_KEY=
163118
ILOVEAPI_BASE_URL=https://api.ilovepdf.com/v1
164119
ILOVEAPI_TIMEOUT=120
165120

166-
# Optional or development-only: compatibility fields kept for retained legacy code paths
121+
# Legacy parser compatibility fields.
167122
ALL_DF_COLS=content,path,type,length,keywords,summary,know_id,tokens,connectto,addtime,page_nums
168-
DEFAULT_FOLDERS=Supplementary_Files,Temporary_Files,templates,images,fragments
169-
KB_TERM=KB_DATA
170-
KB_VEC_TERM=KB_VECS
171-
META_PATH=app/core/config/Meta_setting.csv
172-
CONFIG_PATH=app/core/config/config.txt
173-
PATH_IMAGE_PATTERN=.*\.(png|jpe?g|gif)$
174-
IMG_TBL_PATTERN=\[(?:images|tables)/[^\]]+\]
175-
SPLIT_CHAR=/
123+
SPLIT_CHAR=-->

apps/api/alembic/env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def run_with_connection(connection: Connection) -> None:
136136
return
137137

138138
if isinstance(configured_connection, Engine):
139-
with configured_connection.connect() as connection:
139+
with configured_connection.begin() as connection:
140140
run_with_connection(connection)
141141
return
142142

@@ -149,7 +149,7 @@ def run_with_connection(connection: Connection) -> None:
149149
connect_args=ssl_connect_args,
150150
)
151151

152-
with connectable.connect() as connection:
152+
with connectable.begin() as connection:
153153
run_with_connection(connection)
154154

155155

apps/api/app/api/v1/api_v1.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
API v1 route registry.
33
"""
44

5-
from app.api.v1 import health
65
from app.api.v1.routes import (
76
api_key,
87
documents,
@@ -59,9 +58,6 @@
5958
qstash_callbacks.router, prefix="/webhooks", tags=["QStash Callbacks"]
6059
)
6160

62-
# Health check
63-
api_router.include_router(health.router, prefix="/health", tags=["Health"])
64-
6561
# Version info
6662
api_router.include_router(version.router, tags=["Version"])
6763

0 commit comments

Comments
 (0)