deepsights-api 1.3.0__tar.gz → 1.3.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.
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/.github/workflows/run_tests.yml +1 -1
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/CHANGELOG.md +15 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/CLAUDE.md +3 -3
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/PKG-INFO +41 -14
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/README.md +40 -13
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/__init__.py +1 -4
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/api/api.py +1 -1
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/resources/_search.py +0 -3
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/resources/news.py +0 -3
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/resources/secondary.py +0 -3
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/deepsights/_mip_identity.py +7 -6
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/deepsights/deepsights.py +9 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/__init__.py +1 -1
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/__init__.py +2 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/__init__.py +7 -12
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_list.py +5 -22
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_model.py +21 -64
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_search.py +7 -43
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/documents.py +2 -4
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/resources/__init__.py +8 -3
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/resources/_model.py +2 -2
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/resources/answersV2/answerV2.py +0 -16
- {deepsights_api-1.3.0/deepsights/userclient/resources/hybridsearch → deepsights_api-1.3.2/deepsights/userclient/resources/documents}/__init__.py +2 -2
- deepsights_api-1.3.2/deepsights/userclient/resources/documents/documents.py +276 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/resources/reports/report.py +0 -16
- {deepsights_api-1.3.0/deepsights/userclient/resources/topicsearch → deepsights_api-1.3.2/deepsights/userclient/resources/search}/__init__.py +6 -2
- deepsights_api-1.3.2/deepsights/userclient/resources/search/_model.py +88 -0
- deepsights_api-1.3.0/deepsights/userclient/resources/topicsearch/topicsearch.py → deepsights_api-1.3.2/deepsights/userclient/resources/search/search.py +10 -26
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/userclient.py +10 -5
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/utils/_utils.py +9 -12
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/main.py +69 -16
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/pyproject.toml +1 -1
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/contentstore/test_news_search.py +19 -19
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/contentstore/test_secondary_search.py +19 -19
- deepsights_api-1.3.2/tests/documentstore/test_list.py +236 -0
- deepsights_api-1.3.2/tests/documentstore/test_load.py +460 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/documentstore/test_search.py +10 -72
- deepsights_api-1.3.2/tests/userclient/documents/test_document_pages_load.py +246 -0
- deepsights_api-1.3.2/tests/userclient/documents/test_documents_list.py +237 -0
- deepsights_api-1.3.2/tests/userclient/documents/test_documents_load.py +235 -0
- deepsights_api-1.3.0/tests/userclient/hybridsearch/test_hybridsearch.py → deepsights_api-1.3.2/tests/userclient/documents/test_documents_search.py +5 -5
- {deepsights_api-1.3.0/tests/userclient/topicsearch → deepsights_api-1.3.2/tests/userclient/search}/test_topicsearch.py +5 -5
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/uv.lock +1 -1
- deepsights_api-1.3.0/deepsights/userclient/resources/hybridsearch/hybridsearch.py +0 -80
- deepsights_api-1.3.0/tests/documentstore/test_list.py +0 -37
- deepsights_api-1.3.0/tests/documentstore/test_load.py +0 -141
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/.claude/settings.local.json +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/.github/workflows/build_docs.yml +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/.github/workflows/run_pylint.yml +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/.gitignore +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/.pylintrc +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/.python-version +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/.vscode/settings.json +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/LICENSE +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/api/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/api/resource.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/contentstore.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/resources/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/resources/_download.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/resources/_model.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/deepsights/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/deepsights/resources/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/deepsights/resources/quota/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/deepsights/resources/quota/_model.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/deepsights/resources/quota/quota.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/documentstore.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_cache.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_delete.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_download.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_load.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_segmenter.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_upload.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/resources/answersV2/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/resources/answersV2/_model.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/resources/reports/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/userclient/resources/reports/_model.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/utils/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/utils/_cache.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/utils/_ranking.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/utils/model.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/docs/.gitkeep +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/requirements.txt +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/setup.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/conftest.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/data/test_data.json +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/data/test_presentation.pdf +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/data/test_text.txt +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/deepsights/identity/test_mip_identity.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/deepsights/quota/test_quota.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/deepsights/userclient/test_userclient.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/documentstore/test_download.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/documentstore/test_lifecycle.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/helpers/__init__.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/helpers/common.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/helpers/validation.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/userclient/answersV2/test_answersV2.py +0 -0
- {deepsights_api-1.3.0 → deepsights_api-1.3.2}/tests/userclient/reports/test_reports.py +0 -0
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
<!--next-version-placeholder-->
|
|
4
4
|
|
|
5
|
+
## v1.3.2 (18-Jun-2025)
|
|
6
|
+
|
|
7
|
+
- Improved error logging for answer polling
|
|
8
|
+
- Documentation fix
|
|
9
|
+
|
|
10
|
+
## v1.3.1 (17-Jun-2025)
|
|
11
|
+
|
|
12
|
+
- **BREAKING CHANGE**: Removed topic_search from documentstore (moved to userclient only)
|
|
13
|
+
- Added comprehensive userclient document management: documents_list(), documents_load(), document_pages_load()
|
|
14
|
+
- Enhanced userclient with hybrid_search functionality
|
|
15
|
+
- Topic search models moved from documentstore to userclient.topic_search module
|
|
16
|
+
- Deprecated documentstore.search_documents() in favor of documentsearch.hybrid_search()
|
|
17
|
+
- Added extensive test coverage for new userclient document methods
|
|
18
|
+
- Clean up of packaging
|
|
19
|
+
|
|
5
20
|
## v1.3.0 (15-Jun-2025)
|
|
6
21
|
|
|
7
22
|
- Added topic-search & hybrid-search support for documentstore and userclient
|
|
@@ -47,11 +47,11 @@ DeepSights (main client)
|
|
|
47
47
|
|
|
48
48
|
### Key Features
|
|
49
49
|
|
|
50
|
-
**Search & Retrieval**: Vector-based document search with embeddings, hybrid search combining text/vector results,
|
|
50
|
+
**Search & Retrieval**: Vector-based document search with embeddings, hybrid search combining text/vector results, recency weighting algorithms, and AI-powered topic search (via user client).
|
|
51
51
|
|
|
52
|
-
**Document Management**: Complete lifecycle (upload/search/download/delete) with page-level search and batch operations.
|
|
52
|
+
**Document Management**: Complete lifecycle (upload/search/download/delete) with page-level search and batch operations. User client provides permission-based document listing, loading, and page access.
|
|
53
53
|
|
|
54
|
-
**AI Integration**: User impersonation for AI answers and report generation with permission-based access control.
|
|
54
|
+
**AI Integration**: User impersonation for AI answers and report generation with permission-based access control. Enhanced user client capabilities include document management, hybrid search, and topic search.
|
|
55
55
|
|
|
56
56
|
## Environment Configuration
|
|
57
57
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deepsights-api
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: Python library for the DeepSights APIs
|
|
5
5
|
Project-URL: Documentation, https://marketlogicsoftware.github.io/deepsights-api/
|
|
6
6
|
Project-URL: Repository, https://github.com/marketlogicsoftware/deepsights-api
|
|
@@ -61,7 +61,7 @@ The **Content Store** holds public and paid 3rd party content, including industr
|
|
|
61
61
|
|
|
62
62
|
### User Client
|
|
63
63
|
|
|
64
|
-
The **User Client** serves to impersonate existing platform users with their access permissions. The `userclient` API supports obtaining AI-generated answers and reports in
|
|
64
|
+
The **User Client** serves to impersonate existing platform users with their access permissions. The `userclient` API supports obtaining AI-generated answers and reports in response to business questions, as well as document management operations with user-specific permissions including document listing, loading, page access, hybrid search, and topic search capabilities.
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
## Getting started
|
|
@@ -129,25 +129,56 @@ response = uc.answersV2.create_and_wait(
|
|
|
129
129
|
)
|
|
130
130
|
|
|
131
131
|
print(response.answer)
|
|
132
|
-
print(f"Sources: {len(response.
|
|
132
|
+
print(f"Sources: {len(response.document_sources)} documents cited")
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
#### Document Search & Retrieval
|
|
136
136
|
```python
|
|
137
|
-
#
|
|
138
|
-
|
|
137
|
+
# Hybrid search combining text and vector search
|
|
138
|
+
results = ds.documentstore.documents.search(
|
|
139
139
|
query="consumer behavior trends 2024",
|
|
140
|
-
|
|
140
|
+
extended_search=False
|
|
141
141
|
)
|
|
142
142
|
|
|
143
|
-
for
|
|
144
|
-
print(f"
|
|
143
|
+
for result in results:
|
|
144
|
+
print(f"📄 {result.artifact_title}")
|
|
145
|
+
print(f"📝 {result.artifact_summary[:100]}...")
|
|
146
|
+
print(f"📑 {len(result.page_references)} relevant pages\n")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### User-Specific Document Management
|
|
150
|
+
```python
|
|
151
|
+
# Access documents through user permissions
|
|
152
|
+
uc = ds.get_userclient("analyst@company.com")
|
|
153
|
+
|
|
154
|
+
# List documents with user-specific access
|
|
155
|
+
total_docs, documents = uc.documents.documents_list(
|
|
156
|
+
page_size=20,
|
|
157
|
+
sort_field="creation_date",
|
|
158
|
+
sort_order="DESC"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# Load specific documents with pages
|
|
162
|
+
loaded_docs = uc.documents.documents_load(
|
|
163
|
+
document_ids=["doc_id_1", "doc_id_2"],
|
|
164
|
+
load_pages=True
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# Load specific document pages
|
|
168
|
+
pages = uc.documents.document_pages_load(["page_id_1", "page_id_2"])
|
|
169
|
+
|
|
170
|
+
# Hybrid search through user client
|
|
171
|
+
search_results = uc.documents.search(
|
|
172
|
+
query="consumer behavior insights",
|
|
173
|
+
extended_search=True
|
|
174
|
+
)
|
|
145
175
|
```
|
|
146
176
|
|
|
147
177
|
#### Topic Search with AI Analysis
|
|
148
178
|
```python
|
|
149
|
-
# AI-powered topic search
|
|
150
|
-
|
|
179
|
+
# AI-powered topic search available through user client
|
|
180
|
+
uc = ds.get_userclient("analyst@company.com")
|
|
181
|
+
results = uc.topic_search.search(
|
|
151
182
|
query="sustainable packaging trends",
|
|
152
183
|
extended_search=True
|
|
153
184
|
)
|
|
@@ -157,10 +188,6 @@ for result in results:
|
|
|
157
188
|
print(f"📊 Relevance: {result.relevance_class}")
|
|
158
189
|
print(f"📝 Summary: {result.artifact_summary[:100]}...")
|
|
159
190
|
print(f"📑 {len(result.page_references)} relevant pages found\n")
|
|
160
|
-
|
|
161
|
-
# User client version with OAuth authentication
|
|
162
|
-
uc = ds.get_userclient("analyst@company.com")
|
|
163
|
-
user_results = uc.topic_search.search("market disruption AI")
|
|
164
191
|
```
|
|
165
192
|
|
|
166
193
|
#### Content Store Access
|
|
@@ -31,7 +31,7 @@ The **Content Store** holds public and paid 3rd party content, including industr
|
|
|
31
31
|
|
|
32
32
|
### User Client
|
|
33
33
|
|
|
34
|
-
The **User Client** serves to impersonate existing platform users with their access permissions. The `userclient` API supports obtaining AI-generated answers and reports in
|
|
34
|
+
The **User Client** serves to impersonate existing platform users with their access permissions. The `userclient` API supports obtaining AI-generated answers and reports in response to business questions, as well as document management operations with user-specific permissions including document listing, loading, page access, hybrid search, and topic search capabilities.
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
## Getting started
|
|
@@ -99,25 +99,56 @@ response = uc.answersV2.create_and_wait(
|
|
|
99
99
|
)
|
|
100
100
|
|
|
101
101
|
print(response.answer)
|
|
102
|
-
print(f"Sources: {len(response.
|
|
102
|
+
print(f"Sources: {len(response.document_sources)} documents cited")
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
#### Document Search & Retrieval
|
|
106
106
|
```python
|
|
107
|
-
#
|
|
108
|
-
|
|
107
|
+
# Hybrid search combining text and vector search
|
|
108
|
+
results = ds.documentstore.documents.search(
|
|
109
109
|
query="consumer behavior trends 2024",
|
|
110
|
-
|
|
110
|
+
extended_search=False
|
|
111
111
|
)
|
|
112
112
|
|
|
113
|
-
for
|
|
114
|
-
print(f"
|
|
113
|
+
for result in results:
|
|
114
|
+
print(f"📄 {result.artifact_title}")
|
|
115
|
+
print(f"📝 {result.artifact_summary[:100]}...")
|
|
116
|
+
print(f"📑 {len(result.page_references)} relevant pages\n")
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### User-Specific Document Management
|
|
120
|
+
```python
|
|
121
|
+
# Access documents through user permissions
|
|
122
|
+
uc = ds.get_userclient("analyst@company.com")
|
|
123
|
+
|
|
124
|
+
# List documents with user-specific access
|
|
125
|
+
total_docs, documents = uc.documents.documents_list(
|
|
126
|
+
page_size=20,
|
|
127
|
+
sort_field="creation_date",
|
|
128
|
+
sort_order="DESC"
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
# Load specific documents with pages
|
|
132
|
+
loaded_docs = uc.documents.documents_load(
|
|
133
|
+
document_ids=["doc_id_1", "doc_id_2"],
|
|
134
|
+
load_pages=True
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# Load specific document pages
|
|
138
|
+
pages = uc.documents.document_pages_load(["page_id_1", "page_id_2"])
|
|
139
|
+
|
|
140
|
+
# Hybrid search through user client
|
|
141
|
+
search_results = uc.documents.search(
|
|
142
|
+
query="consumer behavior insights",
|
|
143
|
+
extended_search=True
|
|
144
|
+
)
|
|
115
145
|
```
|
|
116
146
|
|
|
117
147
|
#### Topic Search with AI Analysis
|
|
118
148
|
```python
|
|
119
|
-
# AI-powered topic search
|
|
120
|
-
|
|
149
|
+
# AI-powered topic search available through user client
|
|
150
|
+
uc = ds.get_userclient("analyst@company.com")
|
|
151
|
+
results = uc.topic_search.search(
|
|
121
152
|
query="sustainable packaging trends",
|
|
122
153
|
extended_search=True
|
|
123
154
|
)
|
|
@@ -127,10 +158,6 @@ for result in results:
|
|
|
127
158
|
print(f"📊 Relevance: {result.relevance_class}")
|
|
128
159
|
print(f"📝 Summary: {result.artifact_summary[:100]}...")
|
|
129
160
|
print(f"📑 {len(result.page_references)} relevant pages found\n")
|
|
130
|
-
|
|
131
|
-
# User client version with OAuth authentication
|
|
132
|
-
uc = ds.get_userclient("analyst@company.com")
|
|
133
|
-
user_results = uc.topic_search.search("market disruption AI")
|
|
134
161
|
```
|
|
135
162
|
|
|
136
163
|
#### Content Store Access
|
|
@@ -17,9 +17,6 @@ This module contains the client library to interact with the Market Logic DeepSi
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
from deepsights.deepsights import DeepSights
|
|
20
|
-
from deepsights.documentstore import
|
|
21
|
-
SortingField,
|
|
22
|
-
SortingOrder,
|
|
23
|
-
)
|
|
20
|
+
from deepsights.documentstore.resources import SortingField, SortingOrder
|
|
24
21
|
|
|
25
22
|
__all__ = ["SortingField", "SortingOrder", "DeepSights"]
|
|
@@ -152,7 +152,6 @@ def contentstore_vector_search(
|
|
|
152
152
|
recency_weight: float = 0.0,
|
|
153
153
|
search_from_timestamp: datetime = None,
|
|
154
154
|
search_to_timestamp: datetime = None,
|
|
155
|
-
apply_evidence_filter: bool = False,
|
|
156
155
|
search_only_ai_allowed_content: bool = True,
|
|
157
156
|
) -> List[BaseModel]:
|
|
158
157
|
"""
|
|
@@ -170,7 +169,6 @@ def contentstore_vector_search(
|
|
|
170
169
|
recency_weight (float, optional): The weight to apply to recency in result ranking. Defaults to 0.0.
|
|
171
170
|
search_from_timestamp (datetime, optional): The start timestamp for the search. Defaults to None.
|
|
172
171
|
search_to_timestamp (datetime, optional): The end timestamp for the search. Defaults to None.
|
|
173
|
-
apply_evidence_filter (bool, optional): Whether to apply the evidence filter. Defaults to False.
|
|
174
172
|
search_only_ai_allowed_content (bool, optional): Whether to search only AI-allowed content. Defaults to True.
|
|
175
173
|
|
|
176
174
|
Returns:
|
|
@@ -202,7 +200,6 @@ def contentstore_vector_search(
|
|
|
202
200
|
"content_restrictions": (
|
|
203
201
|
"ALLOWED_FOR_AI_SUMMARIZATION" if search_only_ai_allowed_content else "NONE"
|
|
204
202
|
),
|
|
205
|
-
"use_evidence_filtering": apply_evidence_filter,
|
|
206
203
|
}
|
|
207
204
|
response = api.post("item-service/items/_vector-search", body=body)
|
|
208
205
|
|
|
@@ -59,7 +59,6 @@ class NewsResource(APIResource):
|
|
|
59
59
|
search_from_timestamp: datetime = None,
|
|
60
60
|
search_to_timestamp: datetime = None,
|
|
61
61
|
search_only_ai_allowed_content: bool = True,
|
|
62
|
-
apply_evidence_filter: bool = False,
|
|
63
62
|
) -> List[NewsSearchResult]:
|
|
64
63
|
"""
|
|
65
64
|
Perform a vector-based search for news articles.
|
|
@@ -74,7 +73,6 @@ class NewsResource(APIResource):
|
|
|
74
73
|
search_from_timestamp (datetime, optional): The start timestamp for the search. Defaults to None.
|
|
75
74
|
search_to_timestamp (datetime, optional): The end timestamp for the search. Defaults to None.
|
|
76
75
|
search_only_ai_allowed_content (bool, optional): Whether to search only AI-allowed content. Defaults to True.
|
|
77
|
-
apply_evidence_filter (bool, optional): Whether to apply the evidence filter. Defaults to False.
|
|
78
76
|
Returns:
|
|
79
77
|
|
|
80
78
|
List[NewsSearchResult]: A list of search results as NewsSearchResult objects.
|
|
@@ -94,7 +92,6 @@ class NewsResource(APIResource):
|
|
|
94
92
|
search_from_timestamp=search_from_timestamp,
|
|
95
93
|
search_to_timestamp=search_to_timestamp,
|
|
96
94
|
search_only_ai_allowed_content=search_only_ai_allowed_content,
|
|
97
|
-
apply_evidence_filter=apply_evidence_filter,
|
|
98
95
|
)
|
|
99
96
|
|
|
100
97
|
#################################################
|
{deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/contentstore/resources/secondary.py
RENAMED
|
@@ -59,7 +59,6 @@ class SecondaryResource(APIResource):
|
|
|
59
59
|
search_from_timestamp: datetime = None,
|
|
60
60
|
search_to_timestamp: datetime = None,
|
|
61
61
|
search_only_ai_allowed_content: bool = True,
|
|
62
|
-
apply_evidence_filter: bool = False,
|
|
63
62
|
) -> List[SecondarySearchResult]:
|
|
64
63
|
"""
|
|
65
64
|
Perform a vector-based search for secondary reports.
|
|
@@ -74,7 +73,6 @@ class SecondaryResource(APIResource):
|
|
|
74
73
|
search_from_timestamp (datetime, optional): The start timestamp for the search. Defaults to None.
|
|
75
74
|
search_to_timestamp (datetime, optional): The end timestamp for the search. Defaults to None.
|
|
76
75
|
search_only_ai_allowed_content (bool, optional): Whether to search only AI-allowed content. Defaults to True.
|
|
77
|
-
apply_evidence_filter (bool, optional): Whether to apply the evidence filter. Defaults to False.
|
|
78
76
|
Returns:
|
|
79
77
|
|
|
80
78
|
List[SecondarySearchResult]: A list of search results as SecondarySearchResult objects.
|
|
@@ -94,7 +92,6 @@ class SecondaryResource(APIResource):
|
|
|
94
92
|
search_from_timestamp=search_from_timestamp,
|
|
95
93
|
search_to_timestamp=search_to_timestamp,
|
|
96
94
|
search_only_ai_allowed_content=search_only_ai_allowed_content,
|
|
97
|
-
apply_evidence_filter=apply_evidence_filter,
|
|
98
95
|
)
|
|
99
96
|
|
|
100
97
|
#################################################
|
|
@@ -66,17 +66,20 @@ class MIPIdentityResolver(APIKeyAPI):
|
|
|
66
66
|
#################################################
|
|
67
67
|
def get_oauth_token(self, email: str) -> Optional[str]:
|
|
68
68
|
"""
|
|
69
|
-
Retrieves an
|
|
69
|
+
Retrieves an OAuth token for impersonating a user.
|
|
70
70
|
|
|
71
71
|
Args:
|
|
72
|
-
email (str):
|
|
72
|
+
email (str): Email address of the user to impersonate.
|
|
73
73
|
|
|
74
74
|
Returns:
|
|
75
|
-
Optional[str]:
|
|
75
|
+
Optional[str]: OAuth token if user exists, None otherwise.
|
|
76
76
|
|
|
77
77
|
Raises:
|
|
78
|
-
ValueError: If
|
|
78
|
+
ValueError: If email format is invalid.
|
|
79
79
|
"""
|
|
80
|
+
if not self._api_key:
|
|
81
|
+
return None
|
|
82
|
+
|
|
80
83
|
self._check_email(email)
|
|
81
84
|
body = {"user_email": email}
|
|
82
85
|
|
|
@@ -89,8 +92,6 @@ class MIPIdentityResolver(APIKeyAPI):
|
|
|
89
92
|
except HTTPError as e:
|
|
90
93
|
if e.response.status_code == 404:
|
|
91
94
|
return None
|
|
92
|
-
# Let other HTTP errors (500, 503, 429, etc.) bubble up
|
|
93
|
-
# as they should be handled by the base API retry logic
|
|
94
95
|
raise
|
|
95
96
|
|
|
96
97
|
return response["access_token"]
|
|
@@ -97,3 +97,12 @@ class DeepSights(APIKeyAPI):
|
|
|
97
97
|
self.userclients[user_email] = UserClient(oauth_token)
|
|
98
98
|
|
|
99
99
|
return self.userclients[user_email]
|
|
100
|
+
|
|
101
|
+
def get_userclient_by_token(self, oauth_token: str) -> UserClient:
|
|
102
|
+
"""
|
|
103
|
+
Retrieves a user client for the given OAuth token.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
oauth_token (str): The OAuth token to be used for authentication.
|
|
107
|
+
"""
|
|
108
|
+
return UserClient(oauth_token)
|
|
@@ -17,6 +17,6 @@ This module contains the client for the document store in the DeepSights API.
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
from deepsights.documentstore.documentstore import DocumentStore
|
|
20
|
-
from deepsights.documentstore.resources
|
|
20
|
+
from deepsights.documentstore.resources import SortingField, SortingOrder
|
|
21
21
|
|
|
22
22
|
__all__ = ["DocumentStore", "SortingField", "SortingOrder"]
|
{deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/__init__.py
RENAMED
|
@@ -18,6 +18,8 @@ This module contains models and resources for interacting with the document stor
|
|
|
18
18
|
|
|
19
19
|
from deepsights.documentstore.resources.documents import (
|
|
20
20
|
DocumentResource,
|
|
21
|
+
)
|
|
22
|
+
from deepsights.documentstore.resources.documents._model import (
|
|
21
23
|
SortingField,
|
|
22
24
|
SortingOrder,
|
|
23
25
|
)
|
|
@@ -16,25 +16,20 @@
|
|
|
16
16
|
This module contains the resource to interact with documents via the DeepSights API.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
from deepsights.documentstore.resources.documents.
|
|
19
|
+
from deepsights.documentstore.resources.documents._model import (
|
|
20
|
+
HybridSearchPageReference,
|
|
21
|
+
HybridSearchResult,
|
|
20
22
|
SortingField,
|
|
21
23
|
SortingOrder,
|
|
22
24
|
)
|
|
23
|
-
from deepsights.documentstore.resources.documents.
|
|
24
|
-
|
|
25
|
-
TopicSearchPageReference,
|
|
26
|
-
HybridSearchResult,
|
|
27
|
-
HybridSearchPageReference,
|
|
25
|
+
from deepsights.documentstore.resources.documents.documents import (
|
|
26
|
+
DocumentResource,
|
|
28
27
|
)
|
|
29
|
-
from deepsights.documentstore.resources.documents.documents import DocumentResource
|
|
30
28
|
|
|
31
29
|
__all__ = [
|
|
32
|
-
"DocumentResource",
|
|
33
|
-
"SortingField",
|
|
30
|
+
"DocumentResource",
|
|
31
|
+
"SortingField",
|
|
34
32
|
"SortingOrder",
|
|
35
|
-
"TopicSearchResult",
|
|
36
|
-
"TopicSearchPageReference",
|
|
37
33
|
"HybridSearchResult",
|
|
38
34
|
"HybridSearchPageReference",
|
|
39
35
|
]
|
|
40
|
-
|
{deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_list.py
RENAMED
|
@@ -20,28 +20,11 @@ from typing import List
|
|
|
20
20
|
|
|
21
21
|
from deepsights.api import APIResource
|
|
22
22
|
from deepsights.documentstore.resources.documents._cache import set_document
|
|
23
|
-
from deepsights.documentstore.resources.documents._model import
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"""
|
|
29
|
-
Represents the sorting order for documents.
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
ASCENDING = "ASC"
|
|
33
|
-
DESCENDING = "DESC"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
#################################################
|
|
37
|
-
class SortingField:
|
|
38
|
-
"""
|
|
39
|
-
Represents the sorting field for documents.
|
|
40
|
-
"""
|
|
41
|
-
|
|
42
|
-
TITLE = "title"
|
|
43
|
-
PUBLICATION_DATE = "publication_date"
|
|
44
|
-
CREATION_DATE = "origin.creation_time"
|
|
23
|
+
from deepsights.documentstore.resources.documents._model import (
|
|
24
|
+
Document,
|
|
25
|
+
SortingField,
|
|
26
|
+
SortingOrder,
|
|
27
|
+
)
|
|
45
28
|
|
|
46
29
|
|
|
47
30
|
#################################################
|
{deepsights_api-1.3.0 → deepsights_api-1.3.2}/deepsights/documentstore/resources/documents/_model.py
RENAMED
|
@@ -32,6 +32,27 @@ from deepsights.utils import (
|
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
#################################################
|
|
36
|
+
class SortingOrder:
|
|
37
|
+
"""
|
|
38
|
+
Represents the sorting order for documents.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
ASCENDING = "ASC"
|
|
42
|
+
DESCENDING = "DESC"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
#################################################
|
|
46
|
+
class SortingField:
|
|
47
|
+
"""
|
|
48
|
+
Represents the sorting field for documents.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
TITLE = "title"
|
|
52
|
+
PUBLICATION_DATE = "publication_date"
|
|
53
|
+
CREATION_DATE = "origin.creation_time"
|
|
54
|
+
|
|
55
|
+
|
|
35
56
|
#################################################
|
|
36
57
|
class DocumentPage(DeepSightsIdModel):
|
|
37
58
|
"""
|
|
@@ -172,70 +193,6 @@ class DocumentSearchResult(DeepSightsIdModel):
|
|
|
172
193
|
return super().__repr__()
|
|
173
194
|
|
|
174
195
|
|
|
175
|
-
#################################################
|
|
176
|
-
class TopicSearchPageReference(DeepSightsBaseModel):
|
|
177
|
-
"""
|
|
178
|
-
Represents a page reference in topic search results.
|
|
179
|
-
|
|
180
|
-
Attributes:
|
|
181
|
-
id (str): The ID of the page.
|
|
182
|
-
external_id (str): External ID of the artifact page.
|
|
183
|
-
number (int): Page number.
|
|
184
|
-
title (str): The title of the page.
|
|
185
|
-
"""
|
|
186
|
-
|
|
187
|
-
id: str = Field(
|
|
188
|
-
description="The ID of the page.",
|
|
189
|
-
validation_alias=AliasChoices("id", "page_id"),
|
|
190
|
-
)
|
|
191
|
-
external_id: Optional[str] = Field(
|
|
192
|
-
description="External ID of the artifact page.",
|
|
193
|
-
validation_alias=AliasChoices("external_id", "page_external_id"),
|
|
194
|
-
)
|
|
195
|
-
number: Optional[int] = Field(
|
|
196
|
-
description="Page number.",
|
|
197
|
-
validation_alias=AliasChoices("number", "page_number"),
|
|
198
|
-
)
|
|
199
|
-
title: Optional[str] = Field(
|
|
200
|
-
description="The title of the page.",
|
|
201
|
-
validation_alias=AliasChoices("title", "page_title"),
|
|
202
|
-
)
|
|
203
|
-
text: Optional[str] = Field(
|
|
204
|
-
description="The text of the page.",
|
|
205
|
-
validation_alias=AliasChoices("text", "page_text"),
|
|
206
|
-
)
|
|
207
|
-
relevance_class: Optional[str] = Field(description="Relevance classification.")
|
|
208
|
-
relevance_assessment: Optional[str] = Field(description="Relevance assessment.")
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
#################################################
|
|
212
|
-
class TopicSearchResult(DeepSightsBaseModel):
|
|
213
|
-
"""
|
|
214
|
-
Represents a topic search result for a document.
|
|
215
|
-
|
|
216
|
-
Attributes:
|
|
217
|
-
artifact_id (str): The ID of the artifact.
|
|
218
|
-
artifact_title (str): The title of the artifact.
|
|
219
|
-
artifact_summary (str): Summary of the artifact.
|
|
220
|
-
artifact_source (str): Source of the artifact.
|
|
221
|
-
artifact_publication_date (datetime): Publication date of the artifact.
|
|
222
|
-
page_references (List[TopicSearchPageReference]): Page references.
|
|
223
|
-
relevance_class (str): Relevance classification.
|
|
224
|
-
"""
|
|
225
|
-
|
|
226
|
-
artifact_id: str = Field(description="The ID of the artifact.")
|
|
227
|
-
artifact_title: str = Field(description="The title of the artifact.")
|
|
228
|
-
artifact_summary: Optional[str] = Field(description="Summary of the artifact.")
|
|
229
|
-
artifact_source: Optional[str] = Field(description="Source of the artifact.")
|
|
230
|
-
artifact_publication_date: Optional[datetime] = Field(
|
|
231
|
-
description="Publication date of the artifact."
|
|
232
|
-
)
|
|
233
|
-
page_references: List[TopicSearchPageReference] = Field(
|
|
234
|
-
description="Page references."
|
|
235
|
-
)
|
|
236
|
-
relevance_class: Optional[str] = Field(description="Relevance classification.")
|
|
237
|
-
|
|
238
|
-
|
|
239
196
|
#################################################
|
|
240
197
|
class HybridSearchPageReference(DeepSightsBaseModel):
|
|
241
198
|
"""
|
|
@@ -27,7 +27,6 @@ from deepsights.documentstore.resources.documents._model import (
|
|
|
27
27
|
DocumentPageSearchResult,
|
|
28
28
|
DocumentSearchResult,
|
|
29
29
|
HybridSearchResult,
|
|
30
|
-
TopicSearchResult,
|
|
31
30
|
)
|
|
32
31
|
from deepsights.utils import promote_exact_matches, rerank_by_recency
|
|
33
32
|
|
|
@@ -140,6 +139,11 @@ def documents_search(
|
|
|
140
139
|
"The 'query' argument is only used when 'promote_exact_match' is set to True."
|
|
141
140
|
)
|
|
142
141
|
|
|
142
|
+
# emit deprecation warning
|
|
143
|
+
print(
|
|
144
|
+
"WARNING: The documents_search function is deprecated and will be removed in a future version. Please use the hybrid_search function instead."
|
|
145
|
+
)
|
|
146
|
+
|
|
143
147
|
# get the page matches
|
|
144
148
|
page_matches = document_pages_search(
|
|
145
149
|
resource,
|
|
@@ -200,46 +204,6 @@ def documents_search(
|
|
|
200
204
|
return results
|
|
201
205
|
|
|
202
206
|
|
|
203
|
-
#################################################
|
|
204
|
-
def topic_search(
|
|
205
|
-
resource: APIResource, query: str, extended_search: bool = False
|
|
206
|
-
) -> List[TopicSearchResult]:
|
|
207
|
-
"""
|
|
208
|
-
Searches for documents by topic using AI-powered analysis.
|
|
209
|
-
|
|
210
|
-
Args:
|
|
211
|
-
resource (APIResource): An instance of the DeepSights API resource.
|
|
212
|
-
query (str): The search query topic.
|
|
213
|
-
extended_search (bool, optional): Whether to perform extended search. Defaults to False.
|
|
214
|
-
|
|
215
|
-
Returns:
|
|
216
|
-
List[TopicSearchResult]: The list of topic search results.
|
|
217
|
-
"""
|
|
218
|
-
# Input validation
|
|
219
|
-
if query is None:
|
|
220
|
-
raise ValueError("The 'query' argument is required.")
|
|
221
|
-
if not isinstance(query, str):
|
|
222
|
-
raise ValueError("The 'query' must be a string.")
|
|
223
|
-
query = query.strip()
|
|
224
|
-
if len(query) == 0:
|
|
225
|
-
raise ValueError("The 'query' cannot be empty.")
|
|
226
|
-
if len(query) > 100:
|
|
227
|
-
raise ValueError("The 'query' must be 100 characters or less.")
|
|
228
|
-
|
|
229
|
-
body = {
|
|
230
|
-
"query": query,
|
|
231
|
-
"extended_search": extended_search,
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
response = resource.api.post(
|
|
235
|
-
"supercharged-search-service/topic-searches", body=body
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
# Extract the search results from the response
|
|
239
|
-
search_results = response.get("context", {}).get("search_results", [])
|
|
240
|
-
return [TopicSearchResult(**result) for result in search_results]
|
|
241
|
-
|
|
242
|
-
|
|
243
207
|
#################################################
|
|
244
208
|
def hybrid_search(
|
|
245
209
|
resource: APIResource, query: str, extended_search: bool = False
|
|
@@ -270,11 +234,11 @@ def hybrid_search(
|
|
|
270
234
|
"query": query,
|
|
271
235
|
"extended_search": extended_search,
|
|
272
236
|
}
|
|
273
|
-
|
|
237
|
+
|
|
274
238
|
response = resource.api.post(
|
|
275
239
|
"supercharged-search-service/hybrid-searches", body=body
|
|
276
240
|
)
|
|
277
|
-
|
|
241
|
+
|
|
278
242
|
# Extract the search results from the response
|
|
279
243
|
search_results = response.get("context", {}).get("search_results", [])
|
|
280
244
|
return [HybridSearchResult(**result) for result in search_results]
|
|
@@ -33,7 +33,6 @@ from deepsights.documentstore.resources.documents._search import (
|
|
|
33
33
|
document_pages_search,
|
|
34
34
|
documents_search,
|
|
35
35
|
hybrid_search,
|
|
36
|
-
topic_search,
|
|
37
36
|
)
|
|
38
37
|
from deepsights.documentstore.resources.documents._upload import (
|
|
39
38
|
document_upload,
|
|
@@ -54,8 +53,7 @@ class DocumentResource(APIResource):
|
|
|
54
53
|
load = documents_load
|
|
55
54
|
load_pages = document_pages_load
|
|
56
55
|
download = document_download
|
|
57
|
-
|
|
56
|
+
search_documents = documents_search
|
|
58
57
|
search_pages = document_pages_search
|
|
59
|
-
|
|
60
|
-
topic_search = topic_search
|
|
58
|
+
search = hybrid_search
|
|
61
59
|
list = documents_list
|