soliplex 0.93__tar.gz → 0.93.2__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.
- {soliplex-0.93/src/soliplex.egg-info → soliplex-0.93.2}/PKG-INFO +1 -1
- {soliplex-0.93 → soliplex-0.93.2}/pyproject.toml +1 -1
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/agents.py +30 -16
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/loggers.py +3 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/tools/file_uploads.py +13 -4
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/util.py +61 -1
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/room_file_uploads.py +33 -6
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/thread_file_uploads.py +33 -5
- {soliplex-0.93 → soliplex-0.93.2/src/soliplex.egg-info}/PKG-INFO +1 -1
- {soliplex-0.93 → soliplex-0.93.2}/LICENSE +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/MANIFEST.in +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/README.md +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/example/skills/bare-bones/SKILL.md +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/example/skills/stanzas/SKILL.md +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/setup.cfg +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/skills/soliplex-docs/SKILL.md +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/agents.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/agui/__init__.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/agui/parser.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/agui/persistence.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/agui/schema.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/agui/sse_delivery.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/agui/text_search.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/agui/util.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/__init__.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/env.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/216d48e1e2e5_soliplex_v0_53.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/4b63e5f3f39e_soliplex_v0_51_1.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/63edaa5987f6_soliplex_v0_67.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/98cd91f27cb5_soliplex_v0_92.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/a1c7d3e90b42_soliplex_v0_80.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/b7e2f41c9d05_soliplex_v0_82.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/d5009d4f9874_soliplex_v0_44.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/e5d2f5ef98a3_soliplex_v0_93.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/alembic_migrations/versions/f13fea6c1953_soliplex_v0_86.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/authn.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/authz/__init__.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/authz/persistence.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/authz/schema.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/capabilities/filesystem.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/capabilities/rag_audit.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/admin_users.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/ask.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/__init__.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/_common.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/admin_users.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/completions.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/databases.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/environment.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/installation.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/interpolation.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/logfire.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/logging.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/non_local_paths.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/oidc.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/ollama.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/quizzes.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/room_authz.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/rooms.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/secrets.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/audit/skills.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/cli_util.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/database.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/main.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/ollama.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/room_authz.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/serve.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/service_token.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/cli/types.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/completions.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/__init__.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/_utils.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/agui.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/authsystem.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/completions.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/exceptions.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/installation.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/interpolation.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/logfire.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/meta.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/middleware.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/quizzes.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/rag.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/rooms.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/routing.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/secrets.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/skills.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/sse_delivery.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/config/tools.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/examples.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/installation.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/labels.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/log_ingest.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/main.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/mcp_auth.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/mcp_client.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/mcp_server.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/models.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/ollama.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/quizzes.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/rag_audit.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/sandbox_audit.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/secrets.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/skills/bwrap_sandbox/SKILL.md +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/skills/bwrap_sandbox/__init__.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/titles.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/token_mint.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/tools/__init__.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/tools/agui_run_feedback.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/tools/rag.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/tui/cli.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/tui/main.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/tui/rest_api.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/tui/serve.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/__init__.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/agui.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/authn.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/authz.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/completions.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/installation.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/labels.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/log_ingest.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/quizzes.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/rooms.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/sandbox_workdirs.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/stats.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/streaming.py +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/templates/consent.html.mako +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex/views/templates/cookie-too-large.html.mako +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex.egg-info/SOURCES.txt +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex.egg-info/dependency_links.txt +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex.egg-info/entry_points.txt +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex.egg-info/requires.txt +0 -0
- {soliplex-0.93 → soliplex-0.93.2}/src/soliplex.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: soliplex
|
|
3
|
-
Version: 0.93
|
|
3
|
+
Version: 0.93.2
|
|
4
4
|
Summary: An AI-powered Retrieval-Augmented Generation (RAG) system with a modern web interface.
|
|
5
5
|
Author-email: Enfold <info@enfoldsystems.net>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "soliplex"
|
|
7
|
-
version = "0.93"
|
|
7
|
+
version = "0.93.2"
|
|
8
8
|
description = "An AI-powered Retrieval-Augmented Generation (RAG) system with a modern web interface."
|
|
9
9
|
authors = [{ name = "Enfold", email = "info@enfoldsystems.net" }]
|
|
10
10
|
readme = "README.md"
|
|
@@ -509,18 +509,35 @@ _OPENAI_COMPAT_PROFILE = {
|
|
|
509
509
|
"openai_chat_supports_multiple_system_messages": False,
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
+
# vLLM grammar-constrains strict tool arguments, and for a tool without
|
|
513
|
+
# parameters the constrained decode can run on to 'max_tokens'.
|
|
514
|
+
_VLLM_PROFILE = {
|
|
515
|
+
"openai_supports_strict_tool_definition": False,
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
def _context_window_kw(agent_config: AgentConfig) -> dict:
|
|
520
|
+
"""Kwargs overriding PydanticAI 'context_window', if configured."""
|
|
521
|
+
return (
|
|
522
|
+
{"context_window": agent_config.context_window}
|
|
523
|
+
if agent_config.context_window is not None
|
|
524
|
+
else {}
|
|
525
|
+
)
|
|
526
|
+
|
|
512
527
|
|
|
513
|
-
def _profile_kw(
|
|
528
|
+
def _profile_kw(
|
|
529
|
+
agent_config: AgentConfig,
|
|
530
|
+
*,
|
|
531
|
+
openai_compat: bool,
|
|
532
|
+
) -> dict:
|
|
514
533
|
"""Return the 'profile=' keyword for the model, or nothing.
|
|
515
534
|
|
|
516
535
|
A partial profile is merged over Pydantic AI's own, so only what the
|
|
517
|
-
configuration actually says is passed.
|
|
518
|
-
lets Pydantic AI fill it for a model it knows; set, it overrides.
|
|
536
|
+
configuration actually says is passed.
|
|
519
537
|
"""
|
|
520
|
-
profile =
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
profile["context_window"] = agent_config.context_window
|
|
538
|
+
profile = (
|
|
539
|
+
_OPENAI_COMPAT_PROFILE if openai_compat else {}
|
|
540
|
+
) | _context_window_kw(agent_config)
|
|
524
541
|
|
|
525
542
|
return {"profile": profile} if profile else {}
|
|
526
543
|
|
|
@@ -529,16 +546,12 @@ def get_context_window_from_config(
|
|
|
529
546
|
*,
|
|
530
547
|
agent_config: AgentConfig,
|
|
531
548
|
) -> int | None:
|
|
532
|
-
"""Return the model's context window, or None
|
|
549
|
+
"""Return the model's context window, or None.
|
|
533
550
|
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
hosted models it recognises, and leaves it unset for a local one.
|
|
551
|
+
Use the explicitly-configured window, or else the value derived
|
|
552
|
+
from Pydantic AI's profile.
|
|
537
553
|
|
|
538
|
-
None
|
|
539
|
-
agent template with no model name, or a provider whose key is not
|
|
540
|
-
set. Both fail loudly the moment a run starts; listing the room is
|
|
541
|
-
not that moment.
|
|
554
|
+
None means that no value could be derived.
|
|
542
555
|
"""
|
|
543
556
|
if agent_config.context_window is not None:
|
|
544
557
|
return agent_config.context_window
|
|
@@ -590,10 +603,11 @@ def get_model_from_config(
|
|
|
590
603
|
|
|
591
604
|
elif agent_config.provider_type == LLMProviderType.VLLM:
|
|
592
605
|
provider = vllm_providers.VLLMProvider(**provider_kw)
|
|
606
|
+
|
|
593
607
|
return openai_models.OpenAIChatModel(
|
|
594
608
|
model_name=model_name,
|
|
595
609
|
provider=provider,
|
|
596
|
-
|
|
610
|
+
profile=_VLLM_PROFILE | _context_window_kw(agent_config),
|
|
597
611
|
**model_settings_kw,
|
|
598
612
|
)
|
|
599
613
|
|
|
@@ -50,6 +50,9 @@ UPLOADS_GET_ROOM_THREAD_FILE = "uploads get room thread file"
|
|
|
50
50
|
UPLOADS_POST_ROOM = "uploads post room"
|
|
51
51
|
UPLOADS_DELETE_ROOM_FILE = "uploads delete room file"
|
|
52
52
|
UPLOADS_POST_ROOM_THREAD = "uploads post room thread"
|
|
53
|
+
UPLOADS_POST_ROOM_STORE_FAILED = "uploads post room store failed"
|
|
54
|
+
UPLOADS_POST_ROOM_THREAD_STORE_FAILED = "uploads post room thread store failed"
|
|
55
|
+
UPLOADS_PARTIAL_NOT_REMOVED = "partial upload file not removed: %s"
|
|
53
56
|
|
|
54
57
|
WORKDIRS_GET_ROOM_THREAD = "workdirs get room thread"
|
|
55
58
|
WORKDIRS_GET_ROOM_THREAD_FILE = "workdirs get room thread file"
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import pydantic_ai
|
|
4
4
|
|
|
5
5
|
from soliplex import agents
|
|
6
|
+
from soliplex import util
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class UploadsPathNotConfigured(ValueError):
|
|
@@ -45,7 +46,11 @@ async def list_room_file_uploads(
|
|
|
45
46
|
|
|
46
47
|
room_dir = uploads_path / room_id
|
|
47
48
|
|
|
48
|
-
return [
|
|
49
|
+
return [
|
|
50
|
+
sub.name
|
|
51
|
+
for sub in room_dir.glob("*")
|
|
52
|
+
if not util.is_hidden_upload_name(sub.name) and sub.is_file()
|
|
53
|
+
]
|
|
49
54
|
|
|
50
55
|
|
|
51
56
|
async def get_room_file_upload(
|
|
@@ -71,7 +76,7 @@ async def get_room_file_upload(
|
|
|
71
76
|
room_dir = uploads_path / room_id
|
|
72
77
|
file_path = room_dir / filename
|
|
73
78
|
|
|
74
|
-
if not file_path.exists():
|
|
79
|
+
if util.is_hidden_upload_name(filename) or not file_path.exists():
|
|
75
80
|
raise UploadNotFound("room", filename)
|
|
76
81
|
|
|
77
82
|
try:
|
|
@@ -96,7 +101,11 @@ async def list_thread_file_uploads(
|
|
|
96
101
|
|
|
97
102
|
thread_dir = uploads_path / thread_id
|
|
98
103
|
|
|
99
|
-
return [
|
|
104
|
+
return [
|
|
105
|
+
sub.name
|
|
106
|
+
for sub in thread_dir.glob("*")
|
|
107
|
+
if not util.is_hidden_upload_name(sub.name) and sub.is_file()
|
|
108
|
+
]
|
|
100
109
|
|
|
101
110
|
|
|
102
111
|
async def get_thread_file_upload(
|
|
@@ -122,7 +131,7 @@ async def get_thread_file_upload(
|
|
|
122
131
|
thread_dir = uploads_path / thread_id
|
|
123
132
|
file_path = thread_dir / filename
|
|
124
133
|
|
|
125
|
-
if not file_path.exists():
|
|
134
|
+
if util.is_hidden_upload_name(filename) or not file_path.exists():
|
|
126
135
|
raise UploadNotFound("thread", filename)
|
|
127
136
|
|
|
128
137
|
try:
|
|
@@ -7,13 +7,17 @@ import logging
|
|
|
7
7
|
import os
|
|
8
8
|
import pathlib
|
|
9
9
|
import re
|
|
10
|
+
import shutil
|
|
10
11
|
import stat
|
|
11
12
|
import subprocess
|
|
12
13
|
import typing
|
|
14
|
+
import uuid
|
|
13
15
|
|
|
14
16
|
import logfire
|
|
15
17
|
from starlette import datastructures
|
|
16
18
|
|
|
19
|
+
from soliplex import loggers
|
|
20
|
+
|
|
17
21
|
FOUR_OR_MORE_PERIODS = re.compile(r"\.{4,}")
|
|
18
22
|
TWO_OR_MORE_ELLIPSES = re.compile(r"…{2,}")
|
|
19
23
|
|
|
@@ -202,17 +206,73 @@ def modified_at(stat_result: os.stat_result) -> datetime.datetime | None:
|
|
|
202
206
|
return None
|
|
203
207
|
|
|
204
208
|
|
|
209
|
+
# An upload is written to a hidden file in its target's directory, then
|
|
210
|
+
# renamed onto the target's name.
|
|
211
|
+
UPLOAD_PARTIAL_PREFIX = ".soliplex-upload-"
|
|
212
|
+
|
|
213
|
+
_UPLOAD_COPY_CHUNK_BYTES = 1024 * 1024
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def is_hidden_upload_name(name: str) -> bool:
|
|
217
|
+
"""Is 'name' hidden in an uploads directory?
|
|
218
|
+
|
|
219
|
+
Hidden files (a leading '.') cannot be uploaded, and are never listed,
|
|
220
|
+
downloaded, or deleted through the API, nor shown to the agent's
|
|
221
|
+
tools. They include partial uploads ('UPLOAD_PARTIAL_PREFIX') and the
|
|
222
|
+
Linux NFS client's '.nfsXXXX' files.
|
|
223
|
+
"""
|
|
224
|
+
return name.startswith(".")
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def store_upload(source: typing.BinaryIO, target: pathlib.Path):
|
|
228
|
+
"""Copy 'source' onto 'target', replacing any file or symlink there
|
|
229
|
+
|
|
230
|
+
Blocking: call from a worker thread. 'source' is copied in chunks
|
|
231
|
+
from its start into a hidden file in 'target's directory (created if
|
|
232
|
+
needed), which is then renamed onto 'target'. On failure, the hidden
|
|
233
|
+
file is removed and 'target' is left as it was; if the removal fails
|
|
234
|
+
too, it is logged, naming the hidden file left behind.
|
|
235
|
+
|
|
236
|
+
Raises:
|
|
237
|
+
|
|
238
|
+
- 'OSError' if the directory, the hidden file, or the rename fails.
|
|
239
|
+
"""
|
|
240
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
241
|
+
partial = target.parent / f"{UPLOAD_PARTIAL_PREFIX}{uuid.uuid4().hex}"
|
|
242
|
+
flags = os.O_CREAT | os.O_EXCL | os.O_WRONLY | getattr(os, "O_BINARY", 0)
|
|
243
|
+
|
|
244
|
+
try:
|
|
245
|
+
with open(os.open(partial, flags, 0o666), "wb") as out:
|
|
246
|
+
source.seek(0)
|
|
247
|
+
shutil.copyfileobj(source, out, _UPLOAD_COPY_CHUNK_BYTES)
|
|
248
|
+
out.flush()
|
|
249
|
+
os.fsync(out.fileno())
|
|
250
|
+
|
|
251
|
+
os.replace(partial, target)
|
|
252
|
+
except BaseException:
|
|
253
|
+
# Closed already: on NFS, unlinking an open file leaves '.nfs*'.
|
|
254
|
+
try:
|
|
255
|
+
partial.unlink(missing_ok=True)
|
|
256
|
+
except OSError:
|
|
257
|
+
logger.exception(loggers.UPLOADS_PARTIAL_NOT_REMOVED, partial)
|
|
258
|
+
raise
|
|
259
|
+
|
|
260
|
+
|
|
205
261
|
def upload_files(directory: pathlib.Path) -> dict[str, os.stat_result]:
|
|
206
262
|
"""Map each file in the uploads 'directory' to its stat.
|
|
207
263
|
|
|
208
264
|
Symlinks are followed, as the download views follow them: the
|
|
209
265
|
operator may link a shared file in. A missing 'directory' has no
|
|
210
266
|
files. One stat decides each entry, so an entry which is not a
|
|
211
|
-
regular file when stat'd, or cannot be stat'd, is left out
|
|
267
|
+
regular file when stat'd, or cannot be stat'd, is left out, as are
|
|
268
|
+
hidden files (see 'is_hidden_upload_name').
|
|
212
269
|
"""
|
|
213
270
|
files = {}
|
|
214
271
|
|
|
215
272
|
for file_or_sub in directory.glob("*"):
|
|
273
|
+
if is_hidden_upload_name(file_or_sub.name):
|
|
274
|
+
continue
|
|
275
|
+
|
|
216
276
|
try:
|
|
217
277
|
stat_result = file_or_sub.stat()
|
|
218
278
|
except OSError: # removed, a dangling or looping link, access denied
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import pathlib
|
|
2
2
|
|
|
3
|
+
import anyio
|
|
3
4
|
import fastapi
|
|
4
5
|
from fastapi import responses
|
|
5
6
|
|
|
@@ -174,7 +175,7 @@ async def get_uploads_room_filename(
|
|
|
174
175
|
|
|
175
176
|
file_path = room_dir / filename
|
|
176
177
|
|
|
177
|
-
if not file_path.is_file():
|
|
178
|
+
if views_util.is_hidden_upload_name(filename) or not file_path.is_file():
|
|
178
179
|
raise fastapi.HTTPException(
|
|
179
180
|
status_code=404,
|
|
180
181
|
detail=f"No room upload: {filename}",
|
|
@@ -250,11 +251,34 @@ async def post_uploads_room(
|
|
|
250
251
|
headers={"Allow": ""},
|
|
251
252
|
)
|
|
252
253
|
|
|
253
|
-
room_dir = pathlib.Path(uploads_path) / room_id
|
|
254
|
-
room_dir.mkdir(parents=True, exist_ok=True)
|
|
255
254
|
stripped_filename = pathlib.Path(upload_file.filename).name
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
|
|
256
|
+
if views_util.is_hidden_upload_name(stripped_filename):
|
|
257
|
+
raise fastapi.HTTPException(
|
|
258
|
+
status_code=400,
|
|
259
|
+
detail=f"Upload filename starts with '.': {stripped_filename}",
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
upload_target = pathlib.Path(uploads_path) / room_id / stripped_filename
|
|
263
|
+
try:
|
|
264
|
+
await anyio.to_thread.run_sync(
|
|
265
|
+
views_util.store_upload,
|
|
266
|
+
upload_file.file,
|
|
267
|
+
upload_target,
|
|
268
|
+
)
|
|
269
|
+
except OSError:
|
|
270
|
+
the_logger.exception(
|
|
271
|
+
loggers.UPLOADS_POST_ROOM_STORE_FAILED,
|
|
272
|
+
room_id=room_id,
|
|
273
|
+
filename=stripped_filename,
|
|
274
|
+
)
|
|
275
|
+
raise fastapi.HTTPException(
|
|
276
|
+
status_code=500,
|
|
277
|
+
detail=(
|
|
278
|
+
f"{loggers.UPLOADS_POST_ROOM_STORE_FAILED}: "
|
|
279
|
+
f"{stripped_filename}"
|
|
280
|
+
),
|
|
281
|
+
) from None
|
|
258
282
|
|
|
259
283
|
the_audit.room_upload_added(room_id=room_id, filename=stripped_filename)
|
|
260
284
|
|
|
@@ -341,7 +365,10 @@ async def delete_uploads_room(
|
|
|
341
365
|
stripped_filename = pathlib.Path(filename).name
|
|
342
366
|
file_path = room_dir / stripped_filename
|
|
343
367
|
|
|
344
|
-
if
|
|
368
|
+
if (
|
|
369
|
+
views_util.is_hidden_upload_name(stripped_filename)
|
|
370
|
+
or not file_path.is_file()
|
|
371
|
+
):
|
|
345
372
|
raise fastapi.HTTPException(
|
|
346
373
|
status_code=404,
|
|
347
374
|
detail=f"No room upload: {filename}",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import pathlib
|
|
2
2
|
|
|
3
|
+
import anyio
|
|
3
4
|
import fastapi
|
|
4
5
|
import pydantic
|
|
5
6
|
from fastapi import responses
|
|
@@ -143,7 +144,10 @@ async def get_uploads_room_id_thread_thread_id_filename(
|
|
|
143
144
|
|
|
144
145
|
file_path = thread_dir / filename
|
|
145
146
|
|
|
146
|
-
if
|
|
147
|
+
if (
|
|
148
|
+
soliplex_views_util.is_hidden_upload_name(filename)
|
|
149
|
+
or not file_path.is_file()
|
|
150
|
+
):
|
|
147
151
|
raise fastapi.HTTPException(
|
|
148
152
|
status_code=404,
|
|
149
153
|
detail=f"No thread upload: {filename}",
|
|
@@ -201,10 +205,34 @@ async def post_uploads_room_id_thread_thread_id(
|
|
|
201
205
|
headers={"Allow": "GET"},
|
|
202
206
|
)
|
|
203
207
|
|
|
204
|
-
thread_dir = pathlib.Path(uploads_path) / thread_id
|
|
205
|
-
thread_dir.mkdir(parents=True, exist_ok=True)
|
|
206
208
|
stripped_filename = pathlib.Path(upload_file.filename).name
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
|
|
210
|
+
if soliplex_views_util.is_hidden_upload_name(stripped_filename):
|
|
211
|
+
raise fastapi.HTTPException(
|
|
212
|
+
status_code=400,
|
|
213
|
+
detail=f"Upload filename starts with '.': {stripped_filename}",
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
upload_target = pathlib.Path(uploads_path) / thread_id / stripped_filename
|
|
217
|
+
try:
|
|
218
|
+
await anyio.to_thread.run_sync(
|
|
219
|
+
soliplex_views_util.store_upload,
|
|
220
|
+
upload_file.file,
|
|
221
|
+
upload_target,
|
|
222
|
+
)
|
|
223
|
+
except OSError:
|
|
224
|
+
the_logger.exception(
|
|
225
|
+
loggers.UPLOADS_POST_ROOM_THREAD_STORE_FAILED,
|
|
226
|
+
room_id=room_id,
|
|
227
|
+
thread_id=thread_id,
|
|
228
|
+
filename=stripped_filename,
|
|
229
|
+
)
|
|
230
|
+
raise fastapi.HTTPException(
|
|
231
|
+
status_code=500,
|
|
232
|
+
detail=(
|
|
233
|
+
f"{loggers.UPLOADS_POST_ROOM_THREAD_STORE_FAILED}: "
|
|
234
|
+
f"{stripped_filename}"
|
|
235
|
+
),
|
|
236
|
+
) from None
|
|
209
237
|
|
|
210
238
|
return fastapi.Response(status_code=204)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: soliplex
|
|
3
|
-
Version: 0.93
|
|
3
|
+
Version: 0.93.2
|
|
4
4
|
Summary: An AI-powered Retrieval-Augmented Generation (RAG) system with a modern web interface.
|
|
5
5
|
Author-email: Enfold <info@enfoldsystems.net>
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|