compair-core 0.3.11__tar.gz → 0.3.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of compair-core might be problematic. Click here for more details.

Files changed (43) hide show
  1. {compair_core-0.3.11 → compair_core-0.3.13}/PKG-INFO +2 -1
  2. {compair_core-0.3.11 → compair_core-0.3.13}/README.md +1 -0
  3. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/api.py +48 -15
  4. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/app.py +8 -2
  5. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/routers/capabilities.py +1 -0
  6. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/settings.py +1 -0
  7. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core.egg-info/PKG-INFO +2 -1
  8. {compair_core-0.3.11 → compair_core-0.3.13}/pyproject.toml +1 -1
  9. {compair_core-0.3.11 → compair_core-0.3.13}/LICENSE +0 -0
  10. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/__init__.py +0 -0
  11. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/__init__.py +0 -0
  12. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/celery_app.py +0 -0
  13. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/default_groups.py +0 -0
  14. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/embeddings.py +0 -0
  15. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/feedback.py +0 -0
  16. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/logger.py +0 -0
  17. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/main.py +0 -0
  18. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/models.py +0 -0
  19. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/schema.py +0 -0
  20. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/tasks.py +0 -0
  21. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair/utils.py +0 -0
  22. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair_email/__init__.py +0 -0
  23. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair_email/email.py +0 -0
  24. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair_email/email_core.py +0 -0
  25. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair_email/templates.py +0 -0
  26. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/compair_email/templates_core.py +0 -0
  27. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/__init__.py +0 -0
  28. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/deps.py +0 -0
  29. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/local_model/__init__.py +0 -0
  30. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/local_model/app.py +0 -0
  31. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/providers/__init__.py +0 -0
  32. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/providers/console_mailer.py +0 -0
  33. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/providers/contracts.py +0 -0
  34. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/providers/local_storage.py +0 -0
  35. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/providers/noop_analytics.py +0 -0
  36. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/providers/noop_billing.py +0 -0
  37. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/providers/noop_ocr.py +0 -0
  38. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core/server/routers/__init__.py +0 -0
  39. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core.egg-info/SOURCES.txt +0 -0
  40. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core.egg-info/dependency_links.txt +0 -0
  41. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core.egg-info/requires.txt +0 -0
  42. {compair_core-0.3.11 → compair_core-0.3.13}/compair_core.egg-info/top_level.txt +0 -0
  43. {compair_core-0.3.11 → compair_core-0.3.13}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compair-core
3
- Version: 0.3.11
3
+ Version: 0.3.13
4
4
  Summary: Open-source foundation of the Compair collaboration platform.
5
5
  Author: RocketResearch, Inc.
6
6
  License: MIT
@@ -91,6 +91,7 @@ Key environment variables for the core edition:
91
91
  - `COMPAIR_EMAIL_BACKEND` – the core mailer logs emails to stdout; cloud overrides this with transactional delivery.
92
92
  - `COMPAIR_REQUIRE_AUTHENTICATION` (`true`) – set to `false` to run the API in single-user mode without login or account management. When disabled, Compair auto-provisions a local user, group, and long-lived session token so you can upload documents immediately.
93
93
  - `COMPAIR_SINGLE_USER_USERNAME` / `COMPAIR_SINGLE_USER_NAME` – override the email-style username and display name that are used for the auto-provisioned local user in single-user mode.
94
+ - `COMPAIR_INCLUDE_LEGACY_ROUTES` (`false`) – opt-in to the full legacy API surface (used by the hosted product) when running the core edition. Leave unset to expose only the streamlined single-user endpoints in Swagger.
94
95
 
95
96
  See `compair_core/server/settings.py` for the full settings surface.
96
97
 
@@ -56,6 +56,7 @@ Key environment variables for the core edition:
56
56
  - `COMPAIR_EMAIL_BACKEND` – the core mailer logs emails to stdout; cloud overrides this with transactional delivery.
57
57
  - `COMPAIR_REQUIRE_AUTHENTICATION` (`true`) – set to `false` to run the API in single-user mode without login or account management. When disabled, Compair auto-provisions a local user, group, and long-lived session token so you can upload documents immediately.
58
58
  - `COMPAIR_SINGLE_USER_USERNAME` / `COMPAIR_SINGLE_USER_NAME` – override the email-style username and display name that are used for the auto-provisioned local user in single-user mode.
59
+ - `COMPAIR_INCLUDE_LEGACY_ROUTES` (`false`) – opt-in to the full legacy API surface (used by the hosted product) when running the core edition. Leave unset to expose only the streamlined single-user endpoints in Swagger.
59
60
 
60
61
  See `compair_core/server/settings.py` for the full settings surface.
61
62
 
@@ -13,6 +13,7 @@ import psutil
13
13
  from celery.result import AsyncResult
14
14
  from fastapi import APIRouter, Body, Depends, File, Form, Header, HTTPException, Query, Request, UploadFile
15
15
  from fastapi.responses import HTMLResponse, RedirectResponse, StreamingResponse
16
+ from fastapi.routing import APIRoute
16
17
  from sqlalchemy import distinct, func, select, or_
17
18
  from sqlalchemy.orm import joinedload, Session
18
19
 
@@ -46,6 +47,7 @@ redis_client = redis.Redis.from_url(redis_url) if (redis and redis_url) else Non
46
47
  #from compair.main import process_document
47
48
 
48
49
  router = APIRouter()
50
+ core_router = APIRouter()
49
51
  WEB_URL = os.environ.get("WEB_URL")
50
52
  ADMIN_API_KEY = os.environ.get("ADMIN_API_KEY")
51
53
 
@@ -1401,21 +1403,24 @@ def create_doc(
1401
1403
  datetime_modified=datetime.now(timezone.utc)
1402
1404
  )
1403
1405
  print('About to assign groups!')
1404
- print(groups.split(','))
1405
- if groups is not None:
1406
- group_ids = groups.split(',')
1407
- q = select(models.Group).filter(
1408
- models.Group.group_id.in_(group_ids)
1409
- )
1410
- groups = session.execute(q).fetchall()[0]
1411
- for group in groups:
1412
- document.groups.append(group)
1406
+ target_group_ids = []
1407
+ if groups:
1408
+ target_group_ids = [gid.strip() for gid in groups.split(',') if gid.strip()]
1409
+
1410
+ if target_group_ids:
1411
+ q = select(models.Group).filter(models.Group.group_id.in_(target_group_ids))
1412
+ resolved_groups = session.execute(q).scalars().all()
1413
+ if not resolved_groups:
1414
+ raise HTTPException(status_code=404, detail="No matching groups found for provided IDs.")
1415
+ document.groups = resolved_groups
1413
1416
  else:
1414
- q = select(models.Group).filter(
1415
- models.Group.name == current_user.username
1416
- )
1417
- group = session.execute(q).fetchone()[0]
1418
- document.groups = [group]
1417
+ q = select(models.Group).filter(models.Group.name == current_user.username)
1418
+ default_group = session.execute(q).scalars().first()
1419
+ if default_group is None:
1420
+ raise HTTPException(status_code=404, detail="Default group not found for user.")
1421
+ document.groups = [default_group]
1422
+
1423
+ primary_group = document.groups[0]
1419
1424
 
1420
1425
  print(f'doc check!!! {document.content}')
1421
1426
  session.add(document)
@@ -1433,7 +1438,7 @@ def create_doc(
1433
1438
  log_activity(
1434
1439
  session=session,
1435
1440
  user_id=document.author_id,
1436
- group_id=group.group_id,
1441
+ group_id=primary_group.group_id,
1437
1442
  action="create",
1438
1443
  object_id=document.document_id,
1439
1444
  object_name=document.title,
@@ -3497,6 +3502,34 @@ def submit_deactivate_request(
3497
3502
  return {"message": f"We’ve received your request and will delete your account and data shortly. If you change your mind, reach out within 24 hours at {EMAIL_USER}."}
3498
3503
 
3499
3504
 
3505
+ CORE_PATHS: set[str] = {
3506
+ "/login",
3507
+ "/load_session",
3508
+ "/load_groups",
3509
+ "/load_group",
3510
+ "/create_group",
3511
+ "/join_group",
3512
+ "/load_group_users",
3513
+ "/delete_group",
3514
+ "/load_documents",
3515
+ "/load_document",
3516
+ "/load_document_by_id",
3517
+ "/create_doc",
3518
+ "/process_doc",
3519
+ "/status/{task_id}",
3520
+ "/upload/ocr-file",
3521
+ "/ocr-file-result/{task_id}",
3522
+ "/load_chunks",
3523
+ "/load_references",
3524
+ "/load_feedback",
3525
+ "/documents/{document_id}/feedback",
3526
+ }
3527
+
3528
+ for route in router.routes:
3529
+ if isinstance(route, APIRoute) and route.path in CORE_PATHS:
3530
+ core_router.routes.append(route)
3531
+
3532
+
3500
3533
  def create_fastapi_app():
3501
3534
  """Backwards-compatible app factory for running this module directly."""
3502
3535
  from fastapi import FastAPI
@@ -28,9 +28,15 @@ def create_app(settings: Settings | None = None) -> FastAPI:
28
28
 
29
29
  app = FastAPI(title="Compair API", version=resolved_settings.version)
30
30
 
31
- from ..api import router as legacy_router
31
+ from ..api import core_router, router as legacy_router
32
32
 
33
- app.include_router(legacy_router)
33
+ if edition == "cloud":
34
+ app.include_router(legacy_router)
35
+ else:
36
+ if resolved_settings.include_legacy_routes:
37
+ app.include_router(legacy_router)
38
+ else:
39
+ app.include_router(core_router)
34
40
  app.include_router(capabilities_router)
35
41
 
36
42
  # Share the resolved settings with request handlers
@@ -38,4 +38,5 @@ def capabilities(settings: Settings = Depends(get_settings)) -> dict[str, object
38
38
  },
39
39
  "server": "Compair Cloud" if edition == "cloud" else "Compair Core",
40
40
  "version": settings.version,
41
+ "legacy_routes": settings.include_legacy_routes,
41
42
  }
@@ -19,6 +19,7 @@ class Settings(BaseSettings):
19
19
  require_authentication: bool = False
20
20
  single_user_username: str = "compair-local@example.com"
21
21
  single_user_name: str = "Compair Local User"
22
+ include_legacy_routes: bool = False
22
23
 
23
24
  # Core/local storage defaults
24
25
  local_upload_dir: str = "~/.compair-core/data/uploads"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compair-core
3
- Version: 0.3.11
3
+ Version: 0.3.13
4
4
  Summary: Open-source foundation of the Compair collaboration platform.
5
5
  Author: RocketResearch, Inc.
6
6
  License: MIT
@@ -91,6 +91,7 @@ Key environment variables for the core edition:
91
91
  - `COMPAIR_EMAIL_BACKEND` – the core mailer logs emails to stdout; cloud overrides this with transactional delivery.
92
92
  - `COMPAIR_REQUIRE_AUTHENTICATION` (`true`) – set to `false` to run the API in single-user mode without login or account management. When disabled, Compair auto-provisions a local user, group, and long-lived session token so you can upload documents immediately.
93
93
  - `COMPAIR_SINGLE_USER_USERNAME` / `COMPAIR_SINGLE_USER_NAME` – override the email-style username and display name that are used for the auto-provisioned local user in single-user mode.
94
+ - `COMPAIR_INCLUDE_LEGACY_ROUTES` (`false`) – opt-in to the full legacy API surface (used by the hosted product) when running the core edition. Leave unset to expose only the streamlined single-user endpoints in Swagger.
94
95
 
95
96
  See `compair_core/server/settings.py` for the full settings surface.
96
97
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "compair-core"
7
- version = "0.3.11"
7
+ version = "0.3.13"
8
8
  description = "Open-source foundation of the Compair collaboration platform."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
File without changes
File without changes