Temporary store
labridge.func_modules.paper.store.temporary_store
¶
labridge.func_modules.paper.store.temporary_store.RecentPaperStore
¶
Bases: object
This class stores the recent papers of a specific user. It is constructed as a tree, with a root node.
Different papers are inserted as child nodes of the root node, the node_id is the absolute file path (in the recent paper warehouse) of the paper.
For each paper node, TextNodes recording paper contents are stored as its child nodes. Like:
root_node
/ \
/ \
Paper1 Paper2
/ ... \
node_1 node_n
PARAMETER | DESCRIPTION |
---|---|
vector_index |
The vector database storing recent papers.
TYPE:
|
persist_dir |
The persist directory of the vector database.
TYPE:
|
Note
The metadata date
and time
is recorded in a list format for the convenience of metadata filtering.
For example: ['2024-08-10'], ['09:05:03'].
Source code in labridge\func_modules\paper\store\temporary_store.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.user_id: str
property
¶
Return the user_id of this RecentPaperStore
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.check_valid_paper(paper_file_path)
¶
Check whether the paper path is valid or not.
- Whether the paper_file_path exists.
- Whether the suffix is
.pdf
.
PARAMETER | DESCRIPTION |
---|---|
paper_file_path |
The paper path.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the paper_file_path is not valid. |
Source code in labridge\func_modules\paper\store\temporary_store.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.delete(paper_file_path)
¶
Delete a paper from the recent paper vector index and the recent paper warehouse.
PARAMETER | DESCRIPTION |
---|---|
paper_file_path |
The file path of the paper, equally the node_id of the paper_node.
TYPE:
|
Source code in labridge\func_modules\paper\store\temporary_store.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.file_exists(file_path)
¶
Judge whether a paper exists in the RecentPaperStore according to its filename.
PARAMETER | DESCRIPTION |
---|---|
file_path |
The file path of the paper.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
Whether the paper exist or not.
TYPE:
|
Source code in labridge\func_modules\paper\store\temporary_store.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.from_storage(persist_dir, embed_model)
classmethod
¶
Load from a existing storage.
PARAMETER | DESCRIPTION |
---|---|
persist_dir |
The persist directory of the existing storage.
TYPE:
|
embed_model |
The used embedding model.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RecentPaperStore |
Source code in labridge\func_modules\paper\store\temporary_store.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.from_user_id(user_id, embed_model)
classmethod
¶
Construct from a user_id. If the corresponding persist_dir of the user does not exist, a new RecentPaperStore will be created for the user.
PARAMETER | DESCRIPTION |
---|---|
user_id |
The user_id of a Lab member.
TYPE:
|
embed_model |
The used embedding model.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RecentPaperStore |
Source code in labridge\func_modules\paper\store\temporary_store.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.get_all_relevant_node_ids(node_ids)
¶
Get all the ids of the nodes that are belong to the same papers with the input node_ids.
PARAMETER | DESCRIPTION |
---|---|
node_ids |
The node ids.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[List[str]]
|
Optional[List[str]]: The relevant doc nodes. If no relevant node exists, return None. |
Source code in labridge\func_modules\paper\store\temporary_store.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.get_paper_node(paper_file_path)
¶
Get the paper_node of a paper.
PARAMETER | DESCRIPTION |
---|---|
paper_file_path |
The file path of the paper, equally the node_id of the paper_node.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[BaseNode]
|
Optional[BaseNode]: The paper node. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the paper node does not exist. |
Source code in labridge\func_modules\paper\store\temporary_store.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.get_paper_nodes(paper_file_path)
¶
Get the doc nodes of a paper.
PARAMETER | DESCRIPTION |
---|---|
paper_file_path |
The file path of the paper, equally the node_id of the paper_node.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[List[BaseNode]]
|
Optional[List[BaseNode]]: The doc nodes of the paper. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the paper does not exist. |
Source code in labridge\func_modules\paper\store\temporary_store.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.get_summary_node(paper_file_path)
¶
Get the summary node of a paper.
PARAMETER | DESCRIPTION |
---|---|
paper_file_path |
The file path of the paper, equally the node_id of the paper_node.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[BaseNode]
|
Optional[BaseNode]: The summary node the paper. If it does not exist, return None. |
Source code in labridge\func_modules\paper\store\temporary_store.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.persist(persist_dir=None)
¶
Persis to the disk.
PARAMETER | DESCRIPTION |
---|---|
persist_dir |
The save directory. Defaults to
TYPE:
|
Source code in labridge\func_modules\paper\store\temporary_store.py
479 480 481 482 483 484 485 486 487 488 489 |
|
labridge.func_modules.paper.store.temporary_store.RecentPaperStore.put(paper_file_path, extra_metadata=None)
¶
put a new paper into the vector index.
PARAMETER | DESCRIPTION |
---|---|
paper_file_path |
The absolute path of the paper.
TYPE:
|
extra_metadata |
Extra metadata of the paper. For example, if the paper is downloaded from arXiv, much structured information will be provided by the downloader.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None |
Source code in labridge\func_modules\paper\store\temporary_store.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
labridge.func_modules.paper.store.temporary_store.tmp_paper_get_file_metadata(file_path)
¶
Record these metadata in each doc node:
- the absolute file path of the paper.
- the date when the file is put in.
- the time when the file is put in.
Source code in labridge\func_modules\paper\store\temporary_store.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|