local-deep-research 0.1.26__py3-none-any.whl → 0.2.2__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.
- local_deep_research/__init__.py +23 -22
- local_deep_research/__main__.py +16 -0
- local_deep_research/advanced_search_system/__init__.py +7 -0
- local_deep_research/advanced_search_system/filters/__init__.py +8 -0
- local_deep_research/advanced_search_system/filters/base_filter.py +38 -0
- local_deep_research/advanced_search_system/filters/cross_engine_filter.py +200 -0
- local_deep_research/advanced_search_system/findings/base_findings.py +81 -0
- local_deep_research/advanced_search_system/findings/repository.py +452 -0
- local_deep_research/advanced_search_system/knowledge/__init__.py +1 -0
- local_deep_research/advanced_search_system/knowledge/base_knowledge.py +151 -0
- local_deep_research/advanced_search_system/knowledge/standard_knowledge.py +159 -0
- local_deep_research/advanced_search_system/questions/__init__.py +1 -0
- local_deep_research/advanced_search_system/questions/base_question.py +64 -0
- local_deep_research/advanced_search_system/questions/decomposition_question.py +445 -0
- local_deep_research/advanced_search_system/questions/standard_question.py +119 -0
- local_deep_research/advanced_search_system/repositories/__init__.py +7 -0
- local_deep_research/advanced_search_system/strategies/__init__.py +1 -0
- local_deep_research/advanced_search_system/strategies/base_strategy.py +118 -0
- local_deep_research/advanced_search_system/strategies/iterdrag_strategy.py +450 -0
- local_deep_research/advanced_search_system/strategies/parallel_search_strategy.py +312 -0
- local_deep_research/advanced_search_system/strategies/rapid_search_strategy.py +270 -0
- local_deep_research/advanced_search_system/strategies/standard_strategy.py +300 -0
- local_deep_research/advanced_search_system/tools/__init__.py +1 -0
- local_deep_research/advanced_search_system/tools/base_tool.py +100 -0
- local_deep_research/advanced_search_system/tools/knowledge_tools/__init__.py +1 -0
- local_deep_research/advanced_search_system/tools/question_tools/__init__.py +1 -0
- local_deep_research/advanced_search_system/tools/search_tools/__init__.py +1 -0
- local_deep_research/api/__init__.py +5 -5
- local_deep_research/api/research_functions.py +154 -160
- local_deep_research/app.py +8 -0
- local_deep_research/citation_handler.py +25 -16
- local_deep_research/{config.py → config/config_files.py} +102 -110
- local_deep_research/config/llm_config.py +472 -0
- local_deep_research/config/search_config.py +77 -0
- local_deep_research/defaults/__init__.py +10 -5
- local_deep_research/defaults/main.toml +2 -2
- local_deep_research/defaults/search_engines.toml +60 -34
- local_deep_research/main.py +121 -19
- local_deep_research/migrate_db.py +147 -0
- local_deep_research/report_generator.py +87 -45
- local_deep_research/search_system.py +153 -283
- local_deep_research/setup_data_dir.py +35 -0
- local_deep_research/test_migration.py +178 -0
- local_deep_research/utilities/__init__.py +0 -0
- local_deep_research/utilities/db_utils.py +49 -0
- local_deep_research/{utilties → utilities}/enums.py +2 -2
- local_deep_research/{utilties → utilities}/llm_utils.py +63 -29
- local_deep_research/utilities/search_utilities.py +242 -0
- local_deep_research/{utilties → utilities}/setup_utils.py +4 -2
- local_deep_research/web/__init__.py +0 -1
- local_deep_research/web/app.py +86 -1709
- local_deep_research/web/app_factory.py +289 -0
- local_deep_research/web/database/README.md +70 -0
- local_deep_research/web/database/migrate_to_ldr_db.py +289 -0
- local_deep_research/web/database/migrations.py +447 -0
- local_deep_research/web/database/models.py +117 -0
- local_deep_research/web/database/schema_upgrade.py +107 -0
- local_deep_research/web/models/database.py +294 -0
- local_deep_research/web/models/settings.py +94 -0
- local_deep_research/web/routes/api_routes.py +559 -0
- local_deep_research/web/routes/history_routes.py +354 -0
- local_deep_research/web/routes/research_routes.py +715 -0
- local_deep_research/web/routes/settings_routes.py +1583 -0
- local_deep_research/web/services/research_service.py +947 -0
- local_deep_research/web/services/resource_service.py +149 -0
- local_deep_research/web/services/settings_manager.py +669 -0
- local_deep_research/web/services/settings_service.py +187 -0
- local_deep_research/web/services/socket_service.py +210 -0
- local_deep_research/web/static/css/custom_dropdown.css +277 -0
- local_deep_research/web/static/css/settings.css +1223 -0
- local_deep_research/web/static/css/styles.css +525 -48
- local_deep_research/web/static/js/components/custom_dropdown.js +428 -0
- local_deep_research/web/static/js/components/detail.js +348 -0
- local_deep_research/web/static/js/components/fallback/formatting.js +122 -0
- local_deep_research/web/static/js/components/fallback/ui.js +215 -0
- local_deep_research/web/static/js/components/history.js +487 -0
- local_deep_research/web/static/js/components/logpanel.js +949 -0
- local_deep_research/web/static/js/components/progress.js +1107 -0
- local_deep_research/web/static/js/components/research.js +1865 -0
- local_deep_research/web/static/js/components/results.js +766 -0
- local_deep_research/web/static/js/components/settings.js +3981 -0
- local_deep_research/web/static/js/components/settings_sync.js +106 -0
- local_deep_research/web/static/js/main.js +226 -0
- local_deep_research/web/static/js/services/api.js +253 -0
- local_deep_research/web/static/js/services/audio.js +31 -0
- local_deep_research/web/static/js/services/formatting.js +119 -0
- local_deep_research/web/static/js/services/pdf.js +622 -0
- local_deep_research/web/static/js/services/socket.js +882 -0
- local_deep_research/web/static/js/services/ui.js +546 -0
- local_deep_research/web/templates/base.html +72 -0
- local_deep_research/web/templates/components/custom_dropdown.html +47 -0
- local_deep_research/web/templates/components/log_panel.html +32 -0
- local_deep_research/web/templates/components/mobile_nav.html +22 -0
- local_deep_research/web/templates/components/settings_form.html +299 -0
- local_deep_research/web/templates/components/sidebar.html +21 -0
- local_deep_research/web/templates/pages/details.html +73 -0
- local_deep_research/web/templates/pages/history.html +51 -0
- local_deep_research/web/templates/pages/progress.html +57 -0
- local_deep_research/web/templates/pages/research.html +139 -0
- local_deep_research/web/templates/pages/results.html +59 -0
- local_deep_research/web/templates/settings_dashboard.html +78 -192
- local_deep_research/web/utils/__init__.py +0 -0
- local_deep_research/web/utils/formatters.py +76 -0
- local_deep_research/web_search_engines/engines/full_search.py +18 -16
- local_deep_research/web_search_engines/engines/meta_search_engine.py +182 -131
- local_deep_research/web_search_engines/engines/search_engine_arxiv.py +224 -139
- local_deep_research/web_search_engines/engines/search_engine_brave.py +88 -71
- local_deep_research/web_search_engines/engines/search_engine_ddg.py +48 -39
- local_deep_research/web_search_engines/engines/search_engine_github.py +415 -204
- local_deep_research/web_search_engines/engines/search_engine_google_pse.py +123 -90
- local_deep_research/web_search_engines/engines/search_engine_guardian.py +210 -157
- local_deep_research/web_search_engines/engines/search_engine_local.py +532 -369
- local_deep_research/web_search_engines/engines/search_engine_local_all.py +42 -36
- local_deep_research/web_search_engines/engines/search_engine_pubmed.py +358 -266
- local_deep_research/web_search_engines/engines/search_engine_searxng.py +212 -160
- local_deep_research/web_search_engines/engines/search_engine_semantic_scholar.py +213 -170
- local_deep_research/web_search_engines/engines/search_engine_serpapi.py +84 -68
- local_deep_research/web_search_engines/engines/search_engine_wayback.py +186 -154
- local_deep_research/web_search_engines/engines/search_engine_wikipedia.py +115 -77
- local_deep_research/web_search_engines/search_engine_base.py +174 -99
- local_deep_research/web_search_engines/search_engine_factory.py +192 -102
- local_deep_research/web_search_engines/search_engines_config.py +22 -15
- {local_deep_research-0.1.26.dist-info → local_deep_research-0.2.2.dist-info}/METADATA +177 -97
- local_deep_research-0.2.2.dist-info/RECORD +135 -0
- {local_deep_research-0.1.26.dist-info → local_deep_research-0.2.2.dist-info}/WHEEL +1 -2
- {local_deep_research-0.1.26.dist-info → local_deep_research-0.2.2.dist-info}/entry_points.txt +3 -0
- local_deep_research/defaults/llm_config.py +0 -338
- local_deep_research/utilties/search_utilities.py +0 -114
- local_deep_research/web/static/js/app.js +0 -3763
- local_deep_research/web/templates/api_keys_config.html +0 -82
- local_deep_research/web/templates/collections_config.html +0 -90
- local_deep_research/web/templates/index.html +0 -348
- local_deep_research/web/templates/llm_config.html +0 -120
- local_deep_research/web/templates/main_config.html +0 -89
- local_deep_research/web/templates/search_engines_config.html +0 -154
- local_deep_research/web/templates/settings.html +0 -519
- local_deep_research-0.1.26.dist-info/RECORD +0 -61
- local_deep_research-0.1.26.dist-info/top_level.txt +0 -1
- /local_deep_research/{utilties → config}/__init__.py +0 -0
- {local_deep_research-0.1.26.dist-info → local_deep_research-0.2.2.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,149 @@
|
|
1
|
+
import json
|
2
|
+
import logging
|
3
|
+
from datetime import datetime
|
4
|
+
|
5
|
+
from ..models.database import get_db_connection
|
6
|
+
|
7
|
+
logger = logging.getLogger(__name__)
|
8
|
+
|
9
|
+
|
10
|
+
def get_resources_for_research(research_id):
|
11
|
+
"""
|
12
|
+
Retrieve resources associated with a specific research project
|
13
|
+
|
14
|
+
Args:
|
15
|
+
research_id (int): The ID of the research
|
16
|
+
|
17
|
+
Returns:
|
18
|
+
list: List of resource objects for the research
|
19
|
+
"""
|
20
|
+
try:
|
21
|
+
conn = get_db_connection()
|
22
|
+
cursor = conn.cursor()
|
23
|
+
|
24
|
+
# Query to get resources for the research
|
25
|
+
cursor.execute(
|
26
|
+
"SELECT id, research_id, title, url, content_preview, source_type, metadata "
|
27
|
+
"FROM research_resources WHERE research_id = ? ORDER BY id ASC",
|
28
|
+
(research_id,),
|
29
|
+
)
|
30
|
+
|
31
|
+
resources = []
|
32
|
+
for row in cursor.fetchall():
|
33
|
+
id, research_id, title, url, content_preview, source_type, metadata_str = (
|
34
|
+
row
|
35
|
+
)
|
36
|
+
|
37
|
+
# Parse metadata if available
|
38
|
+
metadata = {}
|
39
|
+
if metadata_str:
|
40
|
+
try:
|
41
|
+
metadata = json.loads(metadata_str)
|
42
|
+
except json.JSONDecodeError:
|
43
|
+
logger.warning(f"Invalid JSON in metadata for resource {id}")
|
44
|
+
|
45
|
+
resources.append(
|
46
|
+
{
|
47
|
+
"id": id,
|
48
|
+
"research_id": research_id,
|
49
|
+
"title": title,
|
50
|
+
"url": url,
|
51
|
+
"content_preview": content_preview,
|
52
|
+
"source_type": source_type,
|
53
|
+
"metadata": metadata,
|
54
|
+
}
|
55
|
+
)
|
56
|
+
|
57
|
+
conn.close()
|
58
|
+
return resources
|
59
|
+
|
60
|
+
except Exception as e:
|
61
|
+
logger.error(f"Error retrieving resources for research {research_id}: {str(e)}")
|
62
|
+
raise
|
63
|
+
|
64
|
+
|
65
|
+
def add_resource(
|
66
|
+
research_id, title, url, content_preview=None, source_type="web", metadata=None
|
67
|
+
):
|
68
|
+
"""
|
69
|
+
Add a new resource to the research_resources table
|
70
|
+
|
71
|
+
Args:
|
72
|
+
research_id (int): The ID of the research
|
73
|
+
title (str): The title of the resource
|
74
|
+
url (str): The URL of the resource
|
75
|
+
content_preview (str, optional): A preview or snippet of the resource content
|
76
|
+
source_type (str, optional): The type of resource (web, pdf, etc.)
|
77
|
+
metadata (dict, optional): Additional metadata for the resource
|
78
|
+
|
79
|
+
Returns:
|
80
|
+
int: The ID of the newly created resource
|
81
|
+
"""
|
82
|
+
try:
|
83
|
+
conn = get_db_connection()
|
84
|
+
cursor = conn.cursor()
|
85
|
+
|
86
|
+
created_at = datetime.utcnow().isoformat()
|
87
|
+
metadata_json = json.dumps(metadata) if metadata else None
|
88
|
+
|
89
|
+
cursor.execute(
|
90
|
+
"INSERT INTO research_resources (research_id, title, url, content_preview, source_type, metadata, created_at) "
|
91
|
+
"VALUES (?, ?, ?, ?, ?, ?, ?)",
|
92
|
+
(
|
93
|
+
research_id,
|
94
|
+
title,
|
95
|
+
url,
|
96
|
+
content_preview,
|
97
|
+
source_type,
|
98
|
+
metadata_json,
|
99
|
+
created_at,
|
100
|
+
),
|
101
|
+
)
|
102
|
+
|
103
|
+
resource_id = cursor.lastrowid
|
104
|
+
conn.commit()
|
105
|
+
conn.close()
|
106
|
+
|
107
|
+
logger.info(f"Added resource {resource_id} for research {research_id}: {title}")
|
108
|
+
return resource_id
|
109
|
+
|
110
|
+
except Exception as e:
|
111
|
+
logger.error(f"Error adding resource for research {research_id}: {str(e)}")
|
112
|
+
raise
|
113
|
+
|
114
|
+
|
115
|
+
def delete_resource(resource_id):
|
116
|
+
"""
|
117
|
+
Delete a resource from the database
|
118
|
+
|
119
|
+
Args:
|
120
|
+
resource_id (int): The ID of the resource to delete
|
121
|
+
|
122
|
+
Returns:
|
123
|
+
bool: True if the resource was deleted successfully, False otherwise
|
124
|
+
"""
|
125
|
+
try:
|
126
|
+
conn = get_db_connection()
|
127
|
+
cursor = conn.cursor()
|
128
|
+
|
129
|
+
# First check if the resource exists
|
130
|
+
cursor.execute("SELECT id FROM research_resources WHERE id = ?", (resource_id,))
|
131
|
+
result = cursor.fetchone()
|
132
|
+
|
133
|
+
if not result:
|
134
|
+
conn.close()
|
135
|
+
return False
|
136
|
+
|
137
|
+
# Delete the resource
|
138
|
+
cursor.execute("DELETE FROM research_resources WHERE id = ?", (resource_id,))
|
139
|
+
|
140
|
+
rows_affected = cursor.rowcount
|
141
|
+
conn.commit()
|
142
|
+
conn.close()
|
143
|
+
|
144
|
+
logger.info(f"Deleted resource {resource_id}, {rows_affected} rows affected")
|
145
|
+
return rows_affected > 0
|
146
|
+
|
147
|
+
except Exception as e:
|
148
|
+
logger.error(f"Error deleting resource {resource_id}: {str(e)}")
|
149
|
+
raise
|