cwyodmodules 0.3.44__py3-none-any.whl → 0.3.45__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.
- cwyodmodules/__init__.py +0 -0
- cwyodmodules/batch/utilities/helpers/config/config_helper.py +362 -362
- cwyodmodules/batch/utilities/helpers/config/default.json +148 -148
- cwyodmodules/batch/utilities/helpers/secret_helper.py +79 -80
- cwyodmodules/graphrag/indexing/extraction.py +237 -230
- cwyodmodules/graphrag/main.py +34 -34
- cwyodmodules/graphrag/query/generate.py +106 -91
- {cwyodmodules-0.3.44.dist-info → cwyodmodules-0.3.45.dist-info}/METADATA +1 -1
- {cwyodmodules-0.3.44.dist-info → cwyodmodules-0.3.45.dist-info}/RECORD +12 -11
- {cwyodmodules-0.3.44.dist-info → cwyodmodules-0.3.45.dist-info}/WHEEL +0 -0
- {cwyodmodules-0.3.44.dist-info → cwyodmodules-0.3.45.dist-info}/licenses/LICENSE +0 -0
- {cwyodmodules-0.3.44.dist-info → cwyodmodules-0.3.45.dist-info}/top_level.txt +0 -0
@@ -1,92 +1,107 @@
|
|
1
|
-
from
|
2
|
-
from
|
3
|
-
from
|
4
|
-
|
5
|
-
from
|
6
|
-
from
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
chunk_texts.append(
|
87
|
-
|
88
|
-
)
|
89
|
-
|
90
|
-
|
91
|
-
|
1
|
+
from ..llm.llm import generate_response
|
2
|
+
from .graph_search import local_query_graph, global_query_graph
|
3
|
+
from .vector_search import _similarity_search
|
4
|
+
from ..database.base import get_db, for_notebook
|
5
|
+
from ..database.models import Chunk
|
6
|
+
from .utils import (
|
7
|
+
separate_by_rank,
|
8
|
+
get_nodes,
|
9
|
+
get_text_from_nodes,
|
10
|
+
get_all_connected_nodes,
|
11
|
+
get_final_text,
|
12
|
+
get_context_from_db,
|
13
|
+
process_chunks,
|
14
|
+
get_node_by_id,
|
15
|
+
get_node_from_chunk,
|
16
|
+
)
|
17
|
+
from ..llm.query_generation import (
|
18
|
+
generate_query_from_question_prompt,
|
19
|
+
generate_response_from_context_prompt,
|
20
|
+
)
|
21
|
+
import asyncio
|
22
|
+
from typing import List, Dict, Tuple, Any, Set
|
23
|
+
from collections import defaultdict
|
24
|
+
import networkx as nx
|
25
|
+
import pandas as pd
|
26
|
+
|
27
|
+
|
28
|
+
async def _local_query(
|
29
|
+
query: str, top_k: int, max_nodes: int=3, order_range: int=5
|
30
|
+
) -> Tuple[str | None, List[str], Dict[str, Dict[str, Any]], List[str]]:
|
31
|
+
|
32
|
+
db = next(get_db())
|
33
|
+
nodes, keywords = await local_query_graph(query=query, top_k=top_k, order_range=order_range)
|
34
|
+
chunk_texts: List[str] = []
|
35
|
+
for chunk_id in nodes:
|
36
|
+
if len(chunk_texts) >= max_nodes:
|
37
|
+
break
|
38
|
+
chunk_texts.append(
|
39
|
+
db.get(Chunk, chunk_id).text
|
40
|
+
)
|
41
|
+
|
42
|
+
context = "\n".join(chunk_texts)
|
43
|
+
response = await generate_response(context=context, query=query)
|
44
|
+
db.close()
|
45
|
+
return response, chunk_texts, nodes, keywords
|
46
|
+
|
47
|
+
|
48
|
+
async def _global_query(
|
49
|
+
query: str, top_k: int, max_nodes: int=3, alpha: float=0.7
|
50
|
+
) -> Tuple[str | None, List[str], Dict[str, Dict[str, Any]], List[str]]:
|
51
|
+
|
52
|
+
db = next(get_db())
|
53
|
+
chunks, keywords = await global_query_graph(query=query, top_k=top_k, alpha=alpha, edge_nodes=max_nodes)
|
54
|
+
chunk_texts: List[str] = []
|
55
|
+
for chunk_id in chunks:
|
56
|
+
chunk_texts.append(
|
57
|
+
db.get(Chunk, chunk_id).text
|
58
|
+
)
|
59
|
+
|
60
|
+
context = "\n".join(chunk_texts)
|
61
|
+
response = await generate_response(context=context, query=query)
|
62
|
+
db.close()
|
63
|
+
return response, chunk_texts, chunks, keywords
|
64
|
+
|
65
|
+
|
66
|
+
async def _hybrid_query(query: str, top_k: int, max_nodes: int=3, alpha: float=0.7, order_range: int=5
|
67
|
+
) -> Tuple[str | None, List[str], Tuple[Dict[str, Any], Dict[str, Dict[str, Any]]], Set[str]]:
|
68
|
+
db = next(get_db())
|
69
|
+
local_query_task = asyncio.create_task(local_query_graph(query=query, top_k=top_k, order_range=order_range))
|
70
|
+
global_query_task = asyncio.create_task(global_query_graph(query=query, top_k=top_k, alpha=alpha, edge_nodes=max_nodes))
|
71
|
+
|
72
|
+
(local_nodes, local_keywords), (global_chunks, global_keywords) = await asyncio.gather(*[local_query_task, global_query_task])
|
73
|
+
chunk_texts: List[str] = []
|
74
|
+
|
75
|
+
seen_ids = set()
|
76
|
+
for chunk_id in local_nodes:
|
77
|
+
if len(chunk_texts) >= max_nodes:
|
78
|
+
break
|
79
|
+
seen_ids.add(chunk_id)
|
80
|
+
chunk_texts.append(
|
81
|
+
db.get(Chunk, chunk_id).text
|
82
|
+
)
|
83
|
+
|
84
|
+
for chunk_id in global_chunks:
|
85
|
+
if chunk_id in seen_ids: continue
|
86
|
+
chunk_texts.append(
|
87
|
+
db.get(Chunk, chunk_id).text
|
88
|
+
)
|
89
|
+
|
90
|
+
context = "\n".join(chunk_texts)
|
91
|
+
response = await generate_response(context=context, query=query)
|
92
|
+
db.close()
|
93
|
+
return response, chunk_texts, (global_chunks, local_nodes), set(local_keywords + global_keywords)
|
94
|
+
|
95
|
+
|
96
|
+
async def _naive_rag(query: str, top_k: int) -> Tuple[str, List[str]]:
|
97
|
+
db = next(get_db())
|
98
|
+
nodes = await _similarity_search(text=query, table='chunk', top_k=top_k)
|
99
|
+
chunk_texts: List[str] = []
|
100
|
+
for (node, _) in nodes:
|
101
|
+
chunk_texts.append(
|
102
|
+
node.text
|
103
|
+
)
|
104
|
+
context = "\n".join(chunk_texts)
|
105
|
+
response = await generate_response(context=context, query=query)
|
106
|
+
db.close()
|
92
107
|
return response, chunk_texts
|
@@ -1,3 +1,4 @@
|
|
1
|
+
cwyodmodules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1
2
|
cwyodmodules/mgmt_config.py,sha256=xRp9absSmQifcKKCn6fyqcMSJ9hDvMTqPPAViezJHZw,5308
|
2
3
|
cwyodmodules/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
4
|
cwyodmodules/api/chat_history.py,sha256=bVXFmhTHIfEiHv_nBrfizO-cQRHhKgrdcZ07OD1b0Tw,20683
|
@@ -40,13 +41,13 @@ cwyodmodules/batch/utilities/helpers/env_helper.py,sha256=S0EG0XzILrJ_iPCAwKN-kz
|
|
40
41
|
cwyodmodules/batch/utilities/helpers/lightrag_helper.py,sha256=7lb9JMm5IohsO73LWo5bWmlzWCGYNsx_fYl-aFdwATQ,3845
|
41
42
|
cwyodmodules/batch/utilities/helpers/llm_helper.py,sha256=lHLYrUidtaemmKrVbWoo7oIvwluUoPUk16U5lV-YIX8,8282
|
42
43
|
cwyodmodules/batch/utilities/helpers/orchestrator_helper.py,sha256=mCcZyMFG0otnw9gzWd-PYocHmDdFDVg-RT9oDPiDZPk,897
|
43
|
-
cwyodmodules/batch/utilities/helpers/secret_helper.py,sha256=
|
44
|
+
cwyodmodules/batch/utilities/helpers/secret_helper.py,sha256=KacIc2hHpWtgButUnR3sFC9StLS36HjYvNpTmf2f4gc,2834
|
44
45
|
cwyodmodules/batch/utilities/helpers/config/agent_mode.py,sha256=8XMbu8dwMXva_xxeZNDlwOjDaZwIcwc-xJK1-QsaJ3w,82
|
45
46
|
cwyodmodules/batch/utilities/helpers/config/assistant_strategy.py,sha256=uT8h646zEURU9x8oDOH7pWoZKb0Mw6dA2nJtA2M-ufg,171
|
46
|
-
cwyodmodules/batch/utilities/helpers/config/config_helper.py,sha256=
|
47
|
+
cwyodmodules/batch/utilities/helpers/config/config_helper.py,sha256=rHP9YgkwG9UodAlRALesQ54M_dDsl801s_gP710vqHk,15685
|
47
48
|
cwyodmodules/batch/utilities/helpers/config/conversation_flow.py,sha256=4nP8a-I-sME5-2unzWWBNpTzWdfpfc5_EAYU6Pn6LAQ,94
|
48
49
|
cwyodmodules/batch/utilities/helpers/config/database_type.py,sha256=Zmmlh1NAKDdd-2ei478boncRKcx8v3lDkPf4kO2j4ss,132
|
49
|
-
cwyodmodules/batch/utilities/helpers/config/default.json,sha256=
|
50
|
+
cwyodmodules/batch/utilities/helpers/config/default.json,sha256=kwZg04XoLlKnva22o_YIuC31jWeSTpuewJTG9oyJP9o,15430
|
50
51
|
cwyodmodules/batch/utilities/helpers/config/default_contract_assistant_prompt.txt,sha256=X39WGcxzQPIvqG7NpAMPsgmSwSyMEoK1DVWiuEHEHRg,3210
|
51
52
|
cwyodmodules/batch/utilities/helpers/config/default_employee_assistant_prompt.txt,sha256=toQFo0wXYrEK7zAItAS9rbtyhT6DJZKBhiL6C9VPUQk,3942
|
52
53
|
cwyodmodules/batch/utilities/helpers/config/embedding_config.py,sha256=9pCJxpsouln9dngjVHaKGFYP14PrwmSts_UFDytSiVk,950
|
@@ -91,13 +92,13 @@ cwyodmodules/batch/utilities/tools/question_answer_tool.py,sha256=8GWurj50bUND_4
|
|
91
92
|
cwyodmodules/batch/utilities/tools/text_processing_tool.py,sha256=zCF83SQaC8k6z6-Gevxj6AdDKzhU3P_6FG0hAnrG5Zk,1824
|
92
93
|
cwyodmodules/graphrag/__init__.py,sha256=O5fi4Q3RC9Gt8ItNZGV1HjyIJvEz7grYXTFMmUWstxw,111
|
93
94
|
cwyodmodules/graphrag/config.py,sha256=TvG45dezHkqgZzWnPxhpyWciIiKOrD_3JQ3APkoD6Hw,1525
|
94
|
-
cwyodmodules/graphrag/main.py,sha256=
|
95
|
+
cwyodmodules/graphrag/main.py,sha256=Ot4hu0muElQGge9L9-8lZSTswgG8YPRoQjXE6wnZ2Gw,2211
|
95
96
|
cwyodmodules/graphrag/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
96
97
|
cwyodmodules/graphrag/database/base.py,sha256=d8CCJYAyEqu3F9m4qfvszMKJGOP0tD0FpTEUbjDDHqU,751
|
97
98
|
cwyodmodules/graphrag/database/models.py,sha256=4NZt2ZSeyaR1bkrUZQHYWPxWHK49-XNV6Wt3n3zVTcg,2803
|
98
99
|
cwyodmodules/graphrag/indexing/__init__.py,sha256=TdI1oChZYljm_ao4GPQ3Oe8ESeeDKGsyheqoHFf5sJQ,125
|
99
100
|
cwyodmodules/graphrag/indexing/chunking.py,sha256=hSEH6KoHemQg1tB4-_BN4r7ZMLBQ94ctV9EUwgKiQcc,7216
|
100
|
-
cwyodmodules/graphrag/indexing/extraction.py,sha256=
|
101
|
+
cwyodmodules/graphrag/indexing/extraction.py,sha256=LwV29UVyhdAIkcd30GSQrfx-ilxsg4tHHCsPmNqrA9M,10822
|
101
102
|
cwyodmodules/graphrag/indexing/types.py,sha256=wIn-q-eGVdmcNvDt0gGXIdqJcvwK5exRqtuWtLu2z0Y,2457
|
102
103
|
cwyodmodules/graphrag/indexing/upsert.py,sha256=BhinBPaq2z0ApHWSG0XzmqXFsrXuiCJcQyL1hhnM1C0,4814
|
103
104
|
cwyodmodules/graphrag/indexing/utils.py,sha256=kvjpBSyRsJcdCybz1Eqd2itFEe4cm76AxqJ_F7n3JEs,169
|
@@ -105,12 +106,12 @@ cwyodmodules/graphrag/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
105
106
|
cwyodmodules/graphrag/llm/llm.py,sha256=sxWqiiMG-iuVvNPYnlqC9mDdld2JP8iPGhzaBq-zk6M,4850
|
106
107
|
cwyodmodules/graphrag/llm/prompt.py,sha256=h4F4j-i6MxpeSz1Kiyhr_hMdiIQOcNosR_HR-zmSoMU,6674
|
107
108
|
cwyodmodules/graphrag/query/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
108
|
-
cwyodmodules/graphrag/query/generate.py,sha256=
|
109
|
+
cwyodmodules/graphrag/query/generate.py,sha256=BZiB6iw7PkIovw-CyYFogMHnDxK0Qu_4uCe494nYEFY,3816
|
109
110
|
cwyodmodules/graphrag/query/graph_search.py,sha256=95h3ecSWx4864XgKABtG0fh3Nk8HkqJVzoCrO8daJ-Y,7724
|
110
111
|
cwyodmodules/graphrag/query/types.py,sha256=1Iq1dp4I4a56_cuFjOZ0NTgd0A2_MpVFznp_czgt6cI,617
|
111
112
|
cwyodmodules/graphrag/query/vector_search.py,sha256=9Gwu9LPjtoAYUU8WKqCvbCHAIg3dpk71reoYd1scLnQ,1807
|
112
|
-
cwyodmodules-0.3.
|
113
|
-
cwyodmodules-0.3.
|
114
|
-
cwyodmodules-0.3.
|
115
|
-
cwyodmodules-0.3.
|
116
|
-
cwyodmodules-0.3.
|
113
|
+
cwyodmodules-0.3.45.dist-info/licenses/LICENSE,sha256=UqBDTipijsSW2ZSOXyTZnMsXmLoEHTgNEM0tL4g-Sso,1150
|
114
|
+
cwyodmodules-0.3.45.dist-info/METADATA,sha256=dhCo5n3jzElUG7B7kF2FimtLv8dXN5kYYF15zVZaaNU,2002
|
115
|
+
cwyodmodules-0.3.45.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
116
|
+
cwyodmodules-0.3.45.dist-info/top_level.txt,sha256=99RENLbkdRX-qpJvsxZ5AfmTL5s6shSaKOWYpz1vwzg,13
|
117
|
+
cwyodmodules-0.3.45.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|