compair-core 0.3.15__py3-none-any.whl → 0.4.1__py3-none-any.whl
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.
- compair_core/api.py +7 -0
- compair_core/compair/__init__.py +35 -10
- compair_core/compair/feedback.py +149 -40
- compair_core/server/local_model/ocr.py +44 -0
- compair_core/server/routers/capabilities.py +4 -0
- {compair_core-0.3.15.dist-info → compair_core-0.4.1.dist-info}/METADATA +6 -3
- {compair_core-0.3.15.dist-info → compair_core-0.4.1.dist-info}/RECORD +10 -9
- {compair_core-0.3.15.dist-info → compair_core-0.4.1.dist-info}/WHEEL +0 -0
- {compair_core-0.3.15.dist-info → compair_core-0.4.1.dist-info}/licenses/LICENSE +0 -0
- {compair_core-0.3.15.dist-info → compair_core-0.4.1.dist-info}/top_level.txt +0 -0
compair_core/api.py
CHANGED
|
@@ -2370,6 +2370,8 @@ def get_activity_feed(
|
|
|
2370
2370
|
):
|
|
2371
2371
|
"""Retrieve recent activities for a user's groups."""
|
|
2372
2372
|
require_feature(HAS_ACTIVITY, "Activity feed")
|
|
2373
|
+
if not IS_CLOUD:
|
|
2374
|
+
raise HTTPException(status_code=501, detail="Activity feed is only available in the Compair Cloud edition.")
|
|
2373
2375
|
with compair.Session() as session:
|
|
2374
2376
|
# Get user's groups
|
|
2375
2377
|
|
|
@@ -3514,7 +3516,11 @@ CORE_PATHS: set[str] = {
|
|
|
3514
3516
|
"/load_documents",
|
|
3515
3517
|
"/load_document",
|
|
3516
3518
|
"/load_document_by_id",
|
|
3519
|
+
"/load_user_files",
|
|
3517
3520
|
"/create_doc",
|
|
3521
|
+
"/update_doc",
|
|
3522
|
+
"/delete_doc",
|
|
3523
|
+
"/delete_docs",
|
|
3518
3524
|
"/process_doc",
|
|
3519
3525
|
"/status/{task_id}",
|
|
3520
3526
|
"/upload/ocr-file",
|
|
@@ -3523,6 +3529,7 @@ CORE_PATHS: set[str] = {
|
|
|
3523
3529
|
"/load_references",
|
|
3524
3530
|
"/load_feedback",
|
|
3525
3531
|
"/documents/{document_id}/feedback",
|
|
3532
|
+
"/get_activity_feed",
|
|
3526
3533
|
}
|
|
3527
3534
|
|
|
3528
3535
|
for route in router.routes:
|
compair_core/compair/__init__.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
+
from pathlib import Path
|
|
4
5
|
from sqlalchemy import Engine, create_engine
|
|
5
6
|
from sqlalchemy.orm import sessionmaker
|
|
6
7
|
|
|
@@ -37,27 +38,51 @@ if edition == "cloud":
|
|
|
37
38
|
|
|
38
39
|
|
|
39
40
|
def _handle_engine() -> Engine:
|
|
41
|
+
# Preferred configuration: explicit database URL
|
|
42
|
+
explicit_url = (
|
|
43
|
+
os.getenv("COMPAIR_DATABASE_URL")
|
|
44
|
+
or os.getenv("COMPAIR_DB_URL")
|
|
45
|
+
or os.getenv("DATABASE_URL")
|
|
46
|
+
)
|
|
47
|
+
if explicit_url:
|
|
48
|
+
if explicit_url.startswith("sqlite:"):
|
|
49
|
+
return create_engine(explicit_url, connect_args={"check_same_thread": False})
|
|
50
|
+
return create_engine(explicit_url)
|
|
51
|
+
|
|
52
|
+
# Backwards compatibility with legacy Postgres env variables
|
|
40
53
|
db = os.getenv("DB")
|
|
41
54
|
db_user = os.getenv("DB_USER")
|
|
42
55
|
db_passw = os.getenv("DB_PASSW")
|
|
43
|
-
|
|
56
|
+
db_host = os.getenv("DB_URL")
|
|
44
57
|
|
|
45
|
-
if all([db, db_user, db_passw,
|
|
58
|
+
if all([db, db_user, db_passw, db_host]):
|
|
46
59
|
return create_engine(
|
|
47
|
-
f"postgresql+psycopg2://{db_user}:{db_passw}@{
|
|
60
|
+
f"postgresql+psycopg2://{db_user}:{db_passw}@{db_host}/{db}",
|
|
48
61
|
pool_size=10,
|
|
49
62
|
max_overflow=0,
|
|
50
63
|
)
|
|
51
64
|
|
|
52
|
-
|
|
65
|
+
# Local default: place an SQLite database inside COMPAIR_DB_DIR
|
|
66
|
+
db_dir = (
|
|
67
|
+
os.getenv("COMPAIR_DB_DIR")
|
|
68
|
+
or os.getenv("COMPAIR_SQLITE_DIR")
|
|
69
|
+
or os.path.join(Path.home(), ".compair-core", "data")
|
|
70
|
+
)
|
|
71
|
+
db_name = os.getenv("COMPAIR_DB_NAME") or os.getenv("COMPAIR_SQLITE_NAME") or "compair.db"
|
|
72
|
+
|
|
73
|
+
db_path = Path(db_dir).expanduser()
|
|
53
74
|
try:
|
|
54
|
-
|
|
75
|
+
db_path.mkdir(parents=True, exist_ok=True)
|
|
55
76
|
except OSError:
|
|
56
|
-
fallback_dir =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
fallback_dir = Path(os.getcwd()) / "compair_data"
|
|
78
|
+
fallback_dir.mkdir(parents=True, exist_ok=True)
|
|
79
|
+
db_path = fallback_dir
|
|
80
|
+
|
|
81
|
+
sqlite_path = db_path / db_name
|
|
82
|
+
return create_engine(
|
|
83
|
+
f"sqlite:///{sqlite_path}",
|
|
84
|
+
connect_args={"check_same_thread": False},
|
|
85
|
+
)
|
|
61
86
|
|
|
62
87
|
|
|
63
88
|
def initialize_database() -> None:
|
compair_core/compair/feedback.py
CHANGED
|
@@ -35,7 +35,8 @@ class Reviewer:
|
|
|
35
35
|
|
|
36
36
|
self._cloud_impl = None
|
|
37
37
|
self._openai_client = None
|
|
38
|
-
self.openai_model = os.getenv("COMPAIR_OPENAI_MODEL", "gpt-
|
|
38
|
+
self.openai_model = os.getenv("COMPAIR_OPENAI_MODEL", "gpt-5-nano")
|
|
39
|
+
self.custom_endpoint = os.getenv("COMPAIR_GENERATION_ENDPOINT")
|
|
39
40
|
|
|
40
41
|
if self.edition == "cloud" and CloudReviewer is not None:
|
|
41
42
|
self._cloud_impl = CloudReviewer()
|
|
@@ -55,6 +56,9 @@ class Reviewer:
|
|
|
55
56
|
if self._openai_client is None and not hasattr(openai, "ChatCompletion"):
|
|
56
57
|
log_event("openai_feedback_unavailable", reason="openai_library_missing")
|
|
57
58
|
self.provider = "fallback"
|
|
59
|
+
if self.provider == "http" and not self.custom_endpoint:
|
|
60
|
+
log_event("custom_feedback_unavailable", reason="missing_endpoint")
|
|
61
|
+
self.provider = "fallback"
|
|
58
62
|
if self.provider == "local":
|
|
59
63
|
self.model = os.getenv("COMPAIR_LOCAL_GENERATION_MODEL", "local-feedback")
|
|
60
64
|
base_url = os.getenv("COMPAIR_LOCAL_MODEL_URL", "http://local-model:9000")
|
|
@@ -63,6 +67,9 @@ class Reviewer:
|
|
|
63
67
|
else:
|
|
64
68
|
self.model = "external"
|
|
65
69
|
self.endpoint = None
|
|
70
|
+
if self.provider not in {"local", "openai", "http", "fallback"}:
|
|
71
|
+
log_event("feedback_provider_unknown", provider=self.provider)
|
|
72
|
+
self.provider = "fallback"
|
|
66
73
|
|
|
67
74
|
@property
|
|
68
75
|
def is_cloud(self) -> bool:
|
|
@@ -89,6 +96,33 @@ def _fallback_feedback(text: str, references: list[Any]) -> str:
|
|
|
89
96
|
return f"Consider aligning with these reference passages: {joined}"
|
|
90
97
|
|
|
91
98
|
|
|
99
|
+
|
|
100
|
+
def _local_reference_feedback(
|
|
101
|
+
reviewer: Reviewer,
|
|
102
|
+
references: list[Any],
|
|
103
|
+
user: User,
|
|
104
|
+
) -> str | None:
|
|
105
|
+
if not references:
|
|
106
|
+
return None
|
|
107
|
+
summaries: list[str] = []
|
|
108
|
+
for ref in references[:3]:
|
|
109
|
+
doc = getattr(ref, "document", None)
|
|
110
|
+
title = getattr(doc, "title", None) or "a related document"
|
|
111
|
+
snippet = getattr(ref, "content", "") or getattr(ref, "text", "")
|
|
112
|
+
snippet = snippet.replace("\n", " ").strip()
|
|
113
|
+
if not snippet:
|
|
114
|
+
continue
|
|
115
|
+
summaries.append(f'"{title}" — {snippet[:200]}')
|
|
116
|
+
if not summaries:
|
|
117
|
+
return None
|
|
118
|
+
instruction = reviewer.length_map.get(user.preferred_feedback_length, "1–2 short sentences")
|
|
119
|
+
if len(summaries) == 1:
|
|
120
|
+
body = summaries[0]
|
|
121
|
+
else:
|
|
122
|
+
body = "; ".join(summaries)
|
|
123
|
+
return f"[local-feedback] {instruction}: Consider the guidance from {body}"
|
|
124
|
+
|
|
125
|
+
|
|
92
126
|
def _openai_feedback(
|
|
93
127
|
reviewer: Reviewer,
|
|
94
128
|
doc: Document,
|
|
@@ -100,56 +134,92 @@ def _openai_feedback(
|
|
|
100
134
|
return None
|
|
101
135
|
instruction = reviewer.length_map.get(user.preferred_feedback_length, "1–2 short sentences")
|
|
102
136
|
ref_text = "\n\n".join(_reference_snippets(references, limit=3))
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
137
|
+
system_prompt = (
|
|
138
|
+
"You are Compair, an assistant that delivers concise, actionable feedback on a user's document. "
|
|
139
|
+
"Focus on clarity, cohesion, and usefulness."
|
|
140
|
+
)
|
|
141
|
+
user_prompt = (
|
|
142
|
+
f"Document:\n{text}\n\nHelpful reference excerpts:\n{ref_text or 'None provided'}\n\n"
|
|
143
|
+
f"Respond with {instruction} that highlights the most valuable revision to make next."
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
def _extract_response_text(response: Any) -> str | None:
|
|
147
|
+
if response is None:
|
|
148
|
+
return None
|
|
149
|
+
text_out = getattr(response, "output_text", None)
|
|
150
|
+
if isinstance(text_out, str) and text_out.strip():
|
|
151
|
+
return text_out.strip()
|
|
152
|
+
outputs = getattr(response, "output", None) or getattr(response, "outputs", None)
|
|
153
|
+
pieces: list[str] = []
|
|
154
|
+
if outputs:
|
|
155
|
+
for item in outputs:
|
|
156
|
+
content_field = None
|
|
157
|
+
if isinstance(item, dict):
|
|
158
|
+
content_field = item.get("content")
|
|
159
|
+
else:
|
|
160
|
+
content_field = getattr(item, "content", None)
|
|
161
|
+
if not content_field:
|
|
162
|
+
continue
|
|
163
|
+
for part in content_field:
|
|
164
|
+
if isinstance(part, dict):
|
|
165
|
+
val = part.get("text") or part.get("output_text")
|
|
166
|
+
if val:
|
|
167
|
+
pieces.append(str(val))
|
|
168
|
+
elif part:
|
|
169
|
+
pieces.append(str(part))
|
|
170
|
+
if pieces:
|
|
171
|
+
merged = "\n".join(pieces).strip()
|
|
172
|
+
return merged or None
|
|
173
|
+
return None
|
|
119
174
|
|
|
120
175
|
try:
|
|
121
|
-
|
|
122
|
-
|
|
176
|
+
client = reviewer._openai_client
|
|
177
|
+
if client is None and hasattr(openai, "OpenAI"):
|
|
178
|
+
api_key = os.getenv("COMPAIR_OPENAI_API_KEY") or None
|
|
179
|
+
try: # pragma: no cover - optional dependency differences
|
|
180
|
+
client = openai.OpenAI(api_key=api_key) if api_key else openai.OpenAI()
|
|
181
|
+
except TypeError:
|
|
182
|
+
client = openai.OpenAI()
|
|
183
|
+
reviewer._openai_client = client
|
|
184
|
+
|
|
185
|
+
content: str | None = None
|
|
186
|
+
if client is not None and hasattr(client, "responses"):
|
|
187
|
+
response = client.responses.create(
|
|
123
188
|
model=reviewer.openai_model,
|
|
124
|
-
|
|
189
|
+
instructions=system_prompt,
|
|
190
|
+
input=user_prompt,
|
|
125
191
|
max_output_tokens=256,
|
|
192
|
+
store=False,
|
|
193
|
+
)
|
|
194
|
+
content = _extract_response_text(response)
|
|
195
|
+
elif client is not None and hasattr(client, "chat") and hasattr(client.chat, "completions"):
|
|
196
|
+
response = client.chat.completions.create(
|
|
197
|
+
model=reviewer.openai_model,
|
|
198
|
+
messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}],
|
|
199
|
+
temperature=0.3,
|
|
200
|
+
max_tokens=256,
|
|
126
201
|
)
|
|
127
|
-
|
|
128
|
-
if
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
202
|
+
choices = getattr(response, "choices", None) or []
|
|
203
|
+
if choices:
|
|
204
|
+
message = getattr(choices[0], "message", None)
|
|
205
|
+
if message is not None:
|
|
206
|
+
content = getattr(message, "content", None)
|
|
207
|
+
if not content:
|
|
208
|
+
content = getattr(choices[0], "text", None)
|
|
209
|
+
if isinstance(content, str):
|
|
210
|
+
content = content.strip()
|
|
134
211
|
elif hasattr(openai, "ChatCompletion"):
|
|
135
212
|
chat_response = openai.ChatCompletion.create( # type: ignore[attr-defined]
|
|
136
213
|
model=reviewer.openai_model,
|
|
137
|
-
messages=
|
|
214
|
+
messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}],
|
|
138
215
|
temperature=0.3,
|
|
139
216
|
max_tokens=256,
|
|
140
217
|
)
|
|
141
|
-
content = (
|
|
142
|
-
|
|
143
|
-
)
|
|
144
|
-
else:
|
|
145
|
-
content = None
|
|
218
|
+
content = chat_response["choices"][0]["message"]["content"].strip() # type: ignore[index, assignment]
|
|
219
|
+
if content:
|
|
220
|
+
return content.strip()
|
|
146
221
|
except Exception as exc: # pragma: no cover - network/API failure
|
|
147
222
|
log_event("openai_feedback_failed", error=str(exc))
|
|
148
|
-
content = None
|
|
149
|
-
if content:
|
|
150
|
-
content = content.strip()
|
|
151
|
-
if content:
|
|
152
|
-
return content
|
|
153
223
|
return None
|
|
154
224
|
|
|
155
225
|
|
|
@@ -181,6 +251,36 @@ def _local_feedback(
|
|
|
181
251
|
return None
|
|
182
252
|
|
|
183
253
|
|
|
254
|
+
def _http_feedback(
|
|
255
|
+
reviewer: Reviewer,
|
|
256
|
+
text: str,
|
|
257
|
+
references: list[Any],
|
|
258
|
+
user: User,
|
|
259
|
+
) -> str | None:
|
|
260
|
+
if not reviewer.custom_endpoint:
|
|
261
|
+
return None
|
|
262
|
+
payload = {
|
|
263
|
+
"document": text,
|
|
264
|
+
"references": [getattr(ref, "content", "") for ref in references],
|
|
265
|
+
"length_instruction": reviewer.length_map.get(
|
|
266
|
+
user.preferred_feedback_length,
|
|
267
|
+
"1–2 short sentences",
|
|
268
|
+
),
|
|
269
|
+
}
|
|
270
|
+
try:
|
|
271
|
+
response = requests.post(reviewer.custom_endpoint, json=payload, timeout=30)
|
|
272
|
+
response.raise_for_status()
|
|
273
|
+
data = response.json()
|
|
274
|
+
feedback = data.get("feedback") or data.get("text")
|
|
275
|
+
if isinstance(feedback, str):
|
|
276
|
+
feedback = feedback.strip()
|
|
277
|
+
if feedback:
|
|
278
|
+
return feedback
|
|
279
|
+
except Exception as exc: # pragma: no cover - network failures stay graceful
|
|
280
|
+
log_event("custom_feedback_failed", error=str(exc))
|
|
281
|
+
return None
|
|
282
|
+
|
|
283
|
+
|
|
184
284
|
def get_feedback(
|
|
185
285
|
reviewer: Reviewer,
|
|
186
286
|
doc: Document,
|
|
@@ -196,9 +296,18 @@ def get_feedback(
|
|
|
196
296
|
if feedback:
|
|
197
297
|
return feedback
|
|
198
298
|
|
|
199
|
-
if reviewer.provider == "
|
|
200
|
-
feedback =
|
|
299
|
+
if reviewer.provider == "http":
|
|
300
|
+
feedback = _http_feedback(reviewer, text, references, user)
|
|
301
|
+
if feedback:
|
|
302
|
+
return feedback
|
|
303
|
+
|
|
304
|
+
if reviewer.provider == "local":
|
|
305
|
+
feedback = _local_reference_feedback(reviewer, references, user)
|
|
201
306
|
if feedback:
|
|
202
307
|
return feedback
|
|
308
|
+
if getattr(reviewer, "endpoint", None):
|
|
309
|
+
feedback = _local_feedback(reviewer, text, references, user)
|
|
310
|
+
if feedback:
|
|
311
|
+
return feedback
|
|
203
312
|
|
|
204
313
|
return _fallback_feedback(text, references)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Minimal OCR endpoint leveraging pytesseract when available."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import io
|
|
5
|
+
import os
|
|
6
|
+
from typing import Any, Dict
|
|
7
|
+
|
|
8
|
+
from fastapi import FastAPI, File, HTTPException, UploadFile
|
|
9
|
+
|
|
10
|
+
app = FastAPI(title="Compair Local OCR", version="0.1.0")
|
|
11
|
+
|
|
12
|
+
try: # Optional dependency
|
|
13
|
+
import pytesseract # type: ignore
|
|
14
|
+
from PIL import Image # type: ignore
|
|
15
|
+
except ImportError: # pragma: no cover - optional
|
|
16
|
+
pytesseract = None # type: ignore
|
|
17
|
+
Image = None # type: ignore
|
|
18
|
+
|
|
19
|
+
_OCR_FALLBACK = os.getenv("COMPAIR_LOCAL_OCR_FALLBACK", "text") # text | none
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _extract_text(data: bytes) -> str:
|
|
23
|
+
if pytesseract is None or Image is None:
|
|
24
|
+
if _OCR_FALLBACK == "text":
|
|
25
|
+
try:
|
|
26
|
+
return data.decode("utf-8")
|
|
27
|
+
except UnicodeDecodeError:
|
|
28
|
+
return data.decode("latin-1", errors="ignore")
|
|
29
|
+
return ""
|
|
30
|
+
try:
|
|
31
|
+
image = Image.open(io.BytesIO(data))
|
|
32
|
+
return pytesseract.image_to_string(image)
|
|
33
|
+
except Exception:
|
|
34
|
+
return ""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@app.post("/ocr-file")
|
|
38
|
+
async def ocr_file(file: UploadFile = File(...)) -> Dict[str, Any]:
|
|
39
|
+
payload = await file.read()
|
|
40
|
+
text = _extract_text(payload)
|
|
41
|
+
if not text:
|
|
42
|
+
raise HTTPException(status_code=501, detail="OCR not available or failed to extract text.")
|
|
43
|
+
return {"extracted_text": text}
|
|
44
|
+
|
|
@@ -36,6 +36,10 @@ def capabilities(settings: Settings = Depends(get_settings)) -> dict[str, object
|
|
|
36
36
|
"docs": None if edition == "core" else 100,
|
|
37
37
|
"feedback_per_day": None if edition == "core" else 50,
|
|
38
38
|
},
|
|
39
|
+
"features": {
|
|
40
|
+
"ocr_upload": settings.ocr_enabled,
|
|
41
|
+
"activity_feed": edition == "cloud",
|
|
42
|
+
},
|
|
39
43
|
"server": "Compair Cloud" if edition == "cloud" else "Compair Core",
|
|
40
44
|
"version": settings.version,
|
|
41
45
|
"legacy_routes": settings.include_legacy_routes,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: compair-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Open-source foundation of the Compair collaboration platform.
|
|
5
5
|
Author: RocketResearch, Inc.
|
|
6
6
|
License: MIT
|
|
@@ -86,7 +86,8 @@ Container definitions and build pipelines live outside this public package:
|
|
|
86
86
|
Key environment variables for the core edition:
|
|
87
87
|
|
|
88
88
|
- `COMPAIR_EDITION` (`core`) – corresponds to this core local implementation.
|
|
89
|
-
- `
|
|
89
|
+
- `COMPAIR_DATABASE_URL` – optional explicit SQLAlchemy URL (e.g. `postgresql+psycopg2://user:pass@host/db`). When omitted, Compair falls back to a local SQLite file.
|
|
90
|
+
- `COMPAIR_DB_DIR` / `COMPAIR_DB_NAME` – directory and filename for the bundled SQLite database (default: `~/.compair-core/data/compair.db`). Legacy `COMPAIR_SQLITE_*` variables remain supported.
|
|
90
91
|
- `COMPAIR_LOCAL_MODEL_URL` – endpoint for your local embeddings/feedback service (defaults to `http://local-model:9000`).
|
|
91
92
|
- `COMPAIR_EMAIL_BACKEND` – the core mailer logs emails to stdout; cloud overrides this with transactional delivery.
|
|
92
93
|
- `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.
|
|
@@ -94,8 +95,10 @@ Key environment variables for the core edition:
|
|
|
94
95
|
- `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.
|
|
95
96
|
- `COMPAIR_EMBEDDING_DIM` – force the embedding vector size stored in the database (defaults to 384 for core, 1536 for cloud). Keep this in sync with whichever embedding model you configure.
|
|
96
97
|
- `COMPAIR_VECTOR_BACKEND` (`auto`) – set to `pgvector` when running against PostgreSQL with the pgvector extension, or `json` to store embeddings as JSON (the default for SQLite deployments).
|
|
97
|
-
- `COMPAIR_GENERATION_PROVIDER` (`local`) – choose how feedback is produced. Options: `local` (call the bundled FastAPI service), `openai` (use ChatGPT-compatible APIs with an API key), or `fallback` (skip generation and surface similar references only).
|
|
98
|
+
- `COMPAIR_GENERATION_PROVIDER` (`local`) – choose how feedback is produced. Options: `local` (call the bundled FastAPI service), `openai` (use ChatGPT-compatible APIs with an API key), `http` (POST the request to a custom endpoint), or `fallback` (skip generation and surface similar references only).
|
|
98
99
|
- `COMPAIR_OPENAI_API_KEY` / `COMPAIR_OPENAI_MODEL` – when using the OpenAI provider, supply your API key and optional model name (defaults to `gpt-4o-mini`). The fallback kicks in automatically if the key or SDK is unavailable.
|
|
100
|
+
- `COMPAIR_GENERATION_ENDPOINT` – HTTP endpoint invoked when `COMPAIR_GENERATION_PROVIDER=http`; the service receives a JSON payload (`document`, `references`, `length_instruction`) and should return `{"feedback": ...}`.
|
|
101
|
+
- `COMPAIR_OCR_ENDPOINT` – endpoint the backend calls for OCR uploads (defaults to the bundled Tesseract wrapper at `http://local-ocr:9001/ocr-file`). Provide your own service by overriding this URL.
|
|
99
102
|
|
|
100
103
|
See `compair_core/server/settings.py` for the full settings surface.
|
|
101
104
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
compair_core/__init__.py,sha256=ktPgTk1QCd7PF-CUzfcd49JvkEut68SEefx2qcL5M5s,122
|
|
2
|
-
compair_core/api.py,sha256=
|
|
3
|
-
compair_core/compair/__init__.py,sha256=
|
|
2
|
+
compair_core/api.py,sha256=Xdpu0wFHPRMYy1CpvuAJkc_gOkawbZwm3iPDiK8S_R4,136536
|
|
3
|
+
compair_core/compair/__init__.py,sha256=LEmm8dmLk3J5nuDHyGA1H4k8Z9Xtdl0eukXs5mrp5mg,3265
|
|
4
4
|
compair_core/compair/celery_app.py,sha256=OM_Saza9yC9Q0kz_WXctfswrKkG7ruT52Zl5E4guiT0,640
|
|
5
5
|
compair_core/compair/default_groups.py,sha256=dbacrFkSjqEQZ_uoFU5gYhgIoP_3lmvz6LJNHCJvxlw,498
|
|
6
6
|
compair_core/compair/embeddings.py,sha256=hlDt_C4JWKQCx_pWZZeBSNaF2gvkIUupQyl5Wq4HR34,2754
|
|
7
|
-
compair_core/compair/feedback.py,sha256=
|
|
7
|
+
compair_core/compair/feedback.py,sha256=Z3UkcrtQhrH7rRRGhe5_HAeqkFglK8VkNxs1sTMvBtM,12071
|
|
8
8
|
compair_core/compair/logger.py,sha256=mB9gV3FfC0qE_G9NBErpEAJhyGxDxEVKqWKu3n8hOkc,802
|
|
9
9
|
compair_core/compair/main.py,sha256=d2d7ENXDWKVG_anOG8Kkr-r9W19h__7zwXSo-3zx4rY,8976
|
|
10
10
|
compair_core/compair/models.py,sha256=0ysM2HG1E8j4MmW6P7abEgNFfor_yfFffScYIl8xku8,16590
|
|
@@ -22,6 +22,7 @@ compair_core/server/deps.py,sha256=0X-Z5JQGeXwbMooWIOC2kXVmsiJIvgUtqkK2PmDjKpI,1
|
|
|
22
22
|
compair_core/server/settings.py,sha256=mWE5vgIx3jxm6LzyeH6QL1tCwxQ6bsZIQffVowqtkFQ,1681
|
|
23
23
|
compair_core/server/local_model/__init__.py,sha256=YlzDgorgAjGou9d_W29Xp3TVu08e4t9x8csFxn8cgSE,50
|
|
24
24
|
compair_core/server/local_model/app.py,sha256=943dnixGcaxHixBXVgJmG5G69gisFcwcIh65NJ5scGU,2552
|
|
25
|
+
compair_core/server/local_model/ocr.py,sha256=Nyw3ZsHwGPeqI7iK9SIXqrj8ZFrXfC9AYCPg0XK4KW8,1345
|
|
25
26
|
compair_core/server/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
27
|
compair_core/server/providers/console_mailer.py,sha256=7ady954yOPlT8t3spkDvdMdO3BTwosJUj1cpVNOwj8U,308
|
|
27
28
|
compair_core/server/providers/contracts.py,sha256=pYA_2AaPHw089O_UP2JtWRHbIiVkoNGhLuesuNATowU,1858
|
|
@@ -30,9 +31,9 @@ compair_core/server/providers/noop_analytics.py,sha256=OKw23SObxBlQzFdB0xEBg5qD1
|
|
|
30
31
|
compair_core/server/providers/noop_billing.py,sha256=V18Cpl1D1reM3xhgw-lShGliVpYO8IsiAPWOAIR34jM,1358
|
|
31
32
|
compair_core/server/providers/noop_ocr.py,sha256=fMaJrivDef38-ECgIuTXUBCIm_avgvZf3nQ3UTdFPNI,341
|
|
32
33
|
compair_core/server/routers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
-
compair_core/server/routers/capabilities.py,sha256=
|
|
34
|
-
compair_core-0.
|
|
35
|
-
compair_core-0.
|
|
36
|
-
compair_core-0.
|
|
37
|
-
compair_core-0.
|
|
38
|
-
compair_core-0.
|
|
34
|
+
compair_core/server/routers/capabilities.py,sha256=hM7HNM6efkyZ7xk0-CLI31qMJvbKM1MwC7xBgj_5-Qw,1479
|
|
35
|
+
compair_core-0.4.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
36
|
+
compair_core-0.4.1.dist-info/METADATA,sha256=JacoGu-SmPi4pvVGViHOHVHyXzrNvLYPHJbbp5w2yMM,6879
|
|
37
|
+
compair_core-0.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
38
|
+
compair_core-0.4.1.dist-info/top_level.txt,sha256=1dpwoLSY2DWQUVGS05Tq0MuFXg8sabYzg4V2deLzzuo,13
|
|
39
|
+
compair_core-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|