h-ai-brain 0.0.13__py3-none-any.whl → 0.0.16__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.
- h_ai/__init__.py +1 -3
- h_ai/application/hai_service.py +0 -51
- {h_ai_brain-0.0.13.dist-info → h_ai_brain-0.0.16.dist-info}/METADATA +2 -8
- h_ai_brain-0.0.16.dist-info/RECORD +31 -0
- {h_ai_brain-0.0.13.dist-info → h_ai_brain-0.0.16.dist-info}/WHEEL +1 -1
- h_ai/application/priority_queue_service.py +0 -30
- h_ai/application/web_docs_service.py +0 -36
- h_ai/domain/priorityqueue/__init__.py +0 -0
- h_ai/domain/priorityqueue/priority_queue_repository.py +0 -34
- h_ai/domain/priorityqueue/queue_item.py +0 -43
- h_ai/domain/web_docs/__init__.py +0 -0
- h_ai/domain/web_docs/doc_link_scorer_service.py +0 -45
- h_ai/domain/web_docs/documentation_pattern_repository.py +0 -44
- h_ai/domain/web_docs/ecosystem_link_scorer_service.py +0 -83
- h_ai/domain/web_docs/ecosystem_pattern_repository.py +0 -182
- h_ai/domain/web_docs/gitbook/__init__.py +0 -0
- h_ai/domain/web_docs/gitbook/text_chapter.py +0 -18
- h_ai/domain/web_docs/gitbook/text_page.py +0 -46
- h_ai/domain/web_docs/gitbook_web_fetcher_service.py +0 -171
- h_ai/domain/web_docs/web_docs_link_detector.py +0 -28
- h_ai/domain/web_docs/web_link.py +0 -11
- h_ai/domain/webpages/__init__.py +0 -0
- h_ai/domain/webpages/web_fetcher_repository.py +0 -10
- h_ai/domain/webpages/web_text_fetcher_repository.py +0 -12
- h_ai/infrastructure/beautifulsoup/__init__.py +0 -0
- h_ai/infrastructure/beautifulsoup/soup_processor.py +0 -240
- h_ai/infrastructure/playwright/__init__.py +0 -0
- h_ai/infrastructure/playwright/playwright_web_content_fetcher.py +0 -64
- h_ai/infrastructure/priorityqueue/__init__.py +0 -0
- h_ai/infrastructure/priorityqueue/in_memory_priority_queue_repository.py +0 -98
- h_ai_brain-0.0.13.dist-info/RECORD +0 -56
- {h_ai_brain-0.0.13.dist-info → h_ai_brain-0.0.16.dist-info}/licenses/LICENSE +0 -0
- {h_ai_brain-0.0.13.dist-info → h_ai_brain-0.0.16.dist-info}/licenses/NOTICE.txt +0 -0
- {h_ai_brain-0.0.13.dist-info → h_ai_brain-0.0.16.dist-info}/top_level.txt +0 -0
@@ -1,98 +0,0 @@
|
|
1
|
-
import queue
|
2
|
-
import threading
|
3
|
-
from queue import PriorityQueue
|
4
|
-
from typing import Dict, List, Optional
|
5
|
-
|
6
|
-
from ...domain.priorityqueue.priority_queue_repository import PriorityQueueRepository
|
7
|
-
from ...domain.priorityqueue.queue_item import QueueItem
|
8
|
-
|
9
|
-
|
10
|
-
class InMemoryPriorityQueueRepository(PriorityQueueRepository):
|
11
|
-
"""In-memory implementation of the PriorityQueueRepository using Python's PriorityQueue"""
|
12
|
-
|
13
|
-
def __init__(self):
|
14
|
-
# Dictionary mapping queue names to their PriorityQueue instances
|
15
|
-
self.queues: Dict[str, PriorityQueue] = {}
|
16
|
-
# Locks to ensure thread safety
|
17
|
-
self.locks: Dict[str, threading.Lock] = {}
|
18
|
-
|
19
|
-
def _get_or_create_queue(self, queue_name: str, maxsize: int = 10000) -> PriorityQueue:
|
20
|
-
"""Get or create a queue with the given name"""
|
21
|
-
if queue_name not in self.queues:
|
22
|
-
self.queues[queue_name] = PriorityQueue(maxsize=maxsize)
|
23
|
-
self.locks[queue_name] = threading.Lock()
|
24
|
-
return self.queues[queue_name]
|
25
|
-
|
26
|
-
def _get_lock(self, queue_name: str) -> threading.Lock:
|
27
|
-
"""Get the lock for the specified queue"""
|
28
|
-
if queue_name not in self.locks:
|
29
|
-
self.locks[queue_name] = threading.Lock()
|
30
|
-
return self.locks[queue_name]
|
31
|
-
|
32
|
-
def add_item(self, queue_name: str, item: QueueItem) -> None:
|
33
|
-
"""Add an item to the specified queue"""
|
34
|
-
q = self._get_or_create_queue(queue_name)
|
35
|
-
with self._get_lock(queue_name):
|
36
|
-
# The queue automatically orders by priority
|
37
|
-
q.put(item)
|
38
|
-
|
39
|
-
def get_highest_priority_item(self, queue_name: str, block: bool = False, timeout: Optional[float] = None) -> Optional[QueueItem]:
|
40
|
-
"""Get and remove the highest priority item from the queue"""
|
41
|
-
if queue_name not in self.queues:
|
42
|
-
return None
|
43
|
-
|
44
|
-
q = self.queues[queue_name]
|
45
|
-
try:
|
46
|
-
# We need to acquire the lock to check initially, but then we need to release it
|
47
|
-
# so that other threads can add items while we're blocking
|
48
|
-
with self._get_lock(queue_name):
|
49
|
-
# If not blocking and queue is empty, return immediately
|
50
|
-
if not block and q.empty():
|
51
|
-
return None
|
52
|
-
|
53
|
-
# Note: queue.get() with block=True will internally manage locking
|
54
|
-
# We don't hold our custom lock during the blocking wait
|
55
|
-
return q.get(block=block, timeout=timeout)
|
56
|
-
except queue.Empty:
|
57
|
-
# This will be raised if timeout occurs with no items
|
58
|
-
return None
|
59
|
-
|
60
|
-
|
61
|
-
def get_items(self, queue_name: str, limit: int = 10) -> List[QueueItem]:
|
62
|
-
"""Get multiple items from the queue in priority order without removing them"""
|
63
|
-
if queue_name not in self.queues:
|
64
|
-
return []
|
65
|
-
|
66
|
-
q = self.queues[queue_name]
|
67
|
-
result = []
|
68
|
-
|
69
|
-
with self._get_lock(queue_name):
|
70
|
-
# Create a temporary list to hold items that we'll put back
|
71
|
-
temp_items = []
|
72
|
-
|
73
|
-
# Get up to 'limit' items
|
74
|
-
count = 0
|
75
|
-
while not q.empty() and count < limit:
|
76
|
-
item = q.get()
|
77
|
-
temp_items.append(item)
|
78
|
-
result.append(item)
|
79
|
-
count += 1
|
80
|
-
|
81
|
-
# Put all the items back in the same order
|
82
|
-
for item in temp_items:
|
83
|
-
q.put(item)
|
84
|
-
|
85
|
-
return result
|
86
|
-
|
87
|
-
def queue_length(self, queue_name: str) -> int:
|
88
|
-
"""Get the number of items in the queue"""
|
89
|
-
if queue_name not in self.queues:
|
90
|
-
return 0
|
91
|
-
|
92
|
-
q = self.queues[queue_name]
|
93
|
-
with self._get_lock(queue_name):
|
94
|
-
return q.qsize()
|
95
|
-
|
96
|
-
def get_queue_names(self) -> List[str]:
|
97
|
-
"""Get a list of all available queue names"""
|
98
|
-
return list(self.queues.keys())
|
@@ -1,56 +0,0 @@
|
|
1
|
-
h_ai/__init__.py,sha256=bmHMDoui52Q73UvXdHslQ3w_LubmhRuKRlrjOYyCP8c,153
|
2
|
-
h_ai/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
h_ai/application/hai_service.py,sha256=nJFx12Kk7yjFvxL0nVQRTKl6ihyUcUcioByNgDxoui0,3042
|
4
|
-
h_ai/application/priority_queue_service.py,sha256=QzPOPDV-_KXTConRpuHmzFFe9HF8HLGPkX_Ael7Hs9g,1304
|
5
|
-
h_ai/application/web_docs_service.py,sha256=YiPBfPyjlloDq6CIOP0u7F1jNBK-elYRU8xl4qJ1oVc,1652
|
6
|
-
h_ai/application/system_prompts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
|
-
h_ai/application/system_prompts/roles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
h_ai/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
|
-
h_ai/domain/priorityqueue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
h_ai/domain/priorityqueue/priority_queue_repository.py,sha256=_px-WFlsj439EKV1qN-z85rQDeybhs2p-xGEXRpOtHE,1104
|
11
|
-
h_ai/domain/priorityqueue/queue_item.py,sha256=aP2Sd3ig9dgKnAsKE_rr3uRjJ_ClWIrvz0Y3nC8XbmE,1417
|
12
|
-
h_ai/domain/reasoning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
-
h_ai/domain/reasoning/llm_chat_repository.py,sha256=rY2izDyaDnoyyrCRS1qc9erHB98vARj4Mp-SnPwNhyY,211
|
14
|
-
h_ai/domain/reasoning/llm_generate_respository.py,sha256=DPiV6ldCE8YhDdVb5rj98MBudKalDQHV3CZ2ADTm_f8,178
|
15
|
-
h_ai/domain/reasoning/llm_tool_repository.py,sha256=nFwqtrJ0Gw8XUFX0uuO7-UejtgoqNuGeT51qZPQtxas,401
|
16
|
-
h_ai/domain/reasoning/text_analysis.py,sha256=rmCUHWzJ3muFBorVXx7HcU2Sw-UfXFOuAVXRAPkqS8E,5183
|
17
|
-
h_ai/domain/reasoning/tool_message.py,sha256=jpbfbJXj6oqZyB3lDxGOUyFB4faHtXAaEOVBHgTgSnk,67
|
18
|
-
h_ai/domain/web_docs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
|
-
h_ai/domain/web_docs/doc_link_scorer_service.py,sha256=EmLSOaX7BCUQcKHZquaUt-Ps_DssZrRqpch5MgbUhAc,1444
|
20
|
-
h_ai/domain/web_docs/documentation_pattern_repository.py,sha256=VhNzP3PUqgg9MaWhBVefj13XNxRBh6ZPUt-KH70ww2w,1302
|
21
|
-
h_ai/domain/web_docs/ecosystem_link_scorer_service.py,sha256=Slin3ZAdJ3o3CxTvJtfD-vd4R4f-MINd3PY2G3bCCQg,2899
|
22
|
-
h_ai/domain/web_docs/ecosystem_pattern_repository.py,sha256=uHBhEvz3HmhXRvFJ6BzJddZmngPSAQw-q39TgRLJiPg,6609
|
23
|
-
h_ai/domain/web_docs/gitbook_web_fetcher_service.py,sha256=Ye-TcuwgW1fhIY8x6v9_-pmPN9pVFWzlOpwRt-4teaA,6490
|
24
|
-
h_ai/domain/web_docs/web_docs_link_detector.py,sha256=NyMKFNs-41bqrxx6u-9GqIufy7pkDF_-_f1h8HECBK8,1192
|
25
|
-
h_ai/domain/web_docs/web_link.py,sha256=J4KC3MmjkvWlAPDdEdjcqAZCvuSnJMahudCohiBk3wk,307
|
26
|
-
h_ai/domain/web_docs/gitbook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
-
h_ai/domain/web_docs/gitbook/text_chapter.py,sha256=XiZZlt128uA6oq-4bQfOpFf-djoHiQEsWpFDzRCNXdk,534
|
28
|
-
h_ai/domain/web_docs/gitbook/text_page.py,sha256=pTHZAKFkeoJTtpk2bRQ__LdS4glAxy9zwm9jtVsgXzE,1503
|
29
|
-
h_ai/domain/webpages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
30
|
-
h_ai/domain/webpages/web_fetcher_repository.py,sha256=OA69IJ3DiOlMjZTBsziv1gRvZ1zc7JZLyfnz7BVOlYk,245
|
31
|
-
h_ai/domain/webpages/web_text_fetcher_repository.py,sha256=OHpAFcg4FDvMHFhnfj-pYBLREHM8dRA8u90gomwKBFQ,299
|
32
|
-
h_ai/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
|
-
h_ai/infrastructure/beautifulsoup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
|
-
h_ai/infrastructure/beautifulsoup/soup_processor.py,sha256=WdU2YyEk-kVomqR9tGjrnCKX3TgxYeUoufj8NLqK3OA,9871
|
35
|
-
h_ai/infrastructure/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
|
-
h_ai/infrastructure/llm/data_handler.py,sha256=M2h1azkjBP9GyaffTggKQZb2CQmOvAk2yo9NrsFMYAo,987
|
37
|
-
h_ai/infrastructure/llm/llm_response_cleaner.py,sha256=pp1K7I77hagrC1r6Ib61-iSNQnU6wlM54bRmOUa7eFk,859
|
38
|
-
h_ai/infrastructure/llm/prompt_helper.py,sha256=QjxPbNW7hu2wBIi9GLJ7r00ELytT2Wr1JKDAA1jB2U4,238
|
39
|
-
h_ai/infrastructure/llm/prompt_loader.py,sha256=8h6QGq_h-s-UzC9fIxpeMCrhjHd7347NaAq7uLf-ook,455
|
40
|
-
h_ai/infrastructure/llm/ollama/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
41
|
-
h_ai/infrastructure/llm/ollama/ollama_chat_repository.py,sha256=GALea7UWLtKyt767Frtl3uv8rvy42HrOKMIQGpqq-H0,2108
|
42
|
-
h_ai/infrastructure/llm/ollama/ollama_generate_repository.py,sha256=jorJrsIR3WPkvls7NE3BXllEtiDePCgMX5DFADz2s8E,1712
|
43
|
-
h_ai/infrastructure/llm/ollama/ollama_tool_repository.py,sha256=7UZ-qsgXQUcJFx1qY7SVI7p3FhIy0Drdqs7jZIp42Ag,4683
|
44
|
-
h_ai/infrastructure/llm/ollama/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
|
-
h_ai/infrastructure/llm/ollama/models/ollama_chat_message.py,sha256=ZIz4PQ3869vI3xAYYufPrxXpacajRDtOI8RDl5Dm9RQ,305
|
46
|
-
h_ai/infrastructure/llm/ollama/models/ollama_chat_session.py,sha256=GZ_ddpbWa8iy6NZq50vokUFVZBiX0WNa81z9-r9RzTY,392
|
47
|
-
h_ai/infrastructure/playwright/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
48
|
-
h_ai/infrastructure/playwright/playwright_web_content_fetcher.py,sha256=FVwcK6hv_6aE4fYlJapLHyxNHsztQkKaulklHabyrEc,2684
|
49
|
-
h_ai/infrastructure/priorityqueue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
50
|
-
h_ai/infrastructure/priorityqueue/in_memory_priority_queue_repository.py,sha256=zxnrbzoLfiKQMB28dI1bPe0qUtvIDG8OEFcTQL_UeFg,3886
|
51
|
-
h_ai_brain-0.0.13.dist-info/licenses/LICENSE,sha256=SbvpEU5JIU3yzMMkyzrI0dGqHDoJR_lMKGdl6GZHsy4,11558
|
52
|
-
h_ai_brain-0.0.13.dist-info/licenses/NOTICE.txt,sha256=vxeIKUiGqAePLvDW4AVm3Xh-3BcsvMtCMn1tbsr9zsE,668
|
53
|
-
h_ai_brain-0.0.13.dist-info/METADATA,sha256=EBqKf8UZ3mk1jlfpOBEaOiRb2VJkzYP7UCSy3FWXfgw,737
|
54
|
-
h_ai_brain-0.0.13.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
55
|
-
h_ai_brain-0.0.13.dist-info/top_level.txt,sha256=3MChDBWvDJV4cEHuZhzeODxQ4ewtw-arOuyaDOc6sIo,5
|
56
|
-
h_ai_brain-0.0.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|