h-ai-brain 0.0.20__py3-none-any.whl → 0.0.22__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.
@@ -1,12 +1,9 @@
1
- from h_message_bus import NatsPublisherAdapter
2
-
3
1
  from ..domain.llm_config import LLMConfig
4
2
  from ..infrastructure.llm.ollama.ollama_generate_repository import OllamaGenerateRepository
5
3
 
6
4
 
7
5
  class HaiService:
8
- def __init__(self, nats_publisher_adapter: NatsPublisherAdapter, llm_config: LLMConfig):
9
- self.nats_publisher_adapter = nats_publisher_adapter
6
+ def __init__(self, llm_config: LLMConfig):
10
7
  self.llm_config = llm_config
11
8
  self.llm_generate_repository = OllamaGenerateRepository(
12
9
  self.llm_config.url,
@@ -1,7 +1,7 @@
1
1
  import json
2
2
 
3
3
 
4
- def parse_json_data(json_string: str) -> dict |None:
4
+ def parse_json_data(json_string: str) -> dict | None:
5
5
  try:
6
6
  # Check for empty string
7
7
  if not json_string or not json_string.strip():
@@ -14,17 +14,21 @@ def parse_json_data(json_string: str) -> dict |None:
14
14
  if match:
15
15
  json_string = match.group(1).strip()
16
16
  else:
17
- # If no code block found, try the existing logic
18
- if json_string.strip().startswith('json'):
19
- json_string = json_string.strip()[4:].strip()
17
+ # If no code block found, check for various JSON prefixes
18
+ stripped = json_string.strip()
19
+ # Check for <json> prefix
20
+ if stripped.startswith('<json>'):
21
+ json_string = stripped[6:].strip()
22
+ # Check for 'json' prefix
23
+ elif stripped.startswith('json'):
24
+ json_string = stripped[4:].strip()
20
25
 
21
26
  # Parse the JSON data
22
27
  data = json.loads(json_string)
23
-
24
28
  return data
25
29
  except json.JSONDecodeError as e:
26
30
  print(f"Error parsing JSON data: {e}")
27
31
  return {}
28
32
  except Exception as e:
29
33
  print(f"Unexpected error while parsing JSON data: {e}")
30
- return {}
34
+ return {}
@@ -42,11 +42,11 @@ class OllamaGenerateRepository(LlmGenerateRepository):
42
42
  payload["num_ctx"] = f"{max_tokens}"
43
43
 
44
44
  try:
45
- print(payload)
45
+ #print(payload)
46
46
  response = requests.post(url, json=payload)
47
47
  response.raise_for_status()
48
48
 
49
- print(response.json())
49
+ #print(response.json())
50
50
 
51
51
  response_content = response.json()["response"]
52
52
  return clean_llm_response(response_content)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h_ai_brain
3
- Version: 0.0.20
3
+ Version: 0.0.22
4
4
  Summary: AI Research agent API
5
5
  Author-email: shoebill <shoebill.hai@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -10,7 +10,6 @@ Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  License-File: NOTICE.txt
13
- Requires-Dist: h_message_bus~=0.0.22
14
13
  Requires-Dist: requests~=2.32.3
15
14
  Provides-Extra: dev
16
15
  Requires-Dist: pytest; extra == "dev"
@@ -1,6 +1,6 @@
1
1
  h_ai/__init__.py,sha256=63uVFHPxXmLrZVo2ZPixL2cU4jwf3XTAuwIVGHGkqJI,75
2
2
  h_ai/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- h_ai/application/hai_service.py,sha256=k7bhMwqJxrpj2rtH_rQokOEYdIzl6bx69bmoyvqzybA,844
3
+ h_ai/application/hai_service.py,sha256=LPRAfwlyGpAY8qUL-pB3c_KhOWa93ztr_CJo11Sy7Xc,686
4
4
  h_ai/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  h_ai/domain/llm_config.py,sha256=xdyRoc26yDoKy8Y5L724TT6LoF3MEOpi7SZPQvS-lx8,258
6
6
  h_ai/domain/reasoning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -11,20 +11,20 @@ h_ai/domain/reasoning/text_analysis.py,sha256=rmCUHWzJ3muFBorVXx7HcU2Sw-UfXFOuAV
11
11
  h_ai/domain/reasoning/tool_message.py,sha256=jpbfbJXj6oqZyB3lDxGOUyFB4faHtXAaEOVBHgTgSnk,67
12
12
  h_ai/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  h_ai/infrastructure/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- h_ai/infrastructure/llm/data_handler.py,sha256=M2h1azkjBP9GyaffTggKQZb2CQmOvAk2yo9NrsFMYAo,987
14
+ h_ai/infrastructure/llm/data_handler.py,sha256=9wAxF5v409DGu7hn_4MGubGe0XyiowYtC30ftvnRDdE,1198
15
15
  h_ai/infrastructure/llm/llm_response_cleaner.py,sha256=pp1K7I77hagrC1r6Ib61-iSNQnU6wlM54bRmOUa7eFk,859
16
16
  h_ai/infrastructure/llm/prompt_helper.py,sha256=QjxPbNW7hu2wBIi9GLJ7r00ELytT2Wr1JKDAA1jB2U4,238
17
17
  h_ai/infrastructure/llm/prompt_loader.py,sha256=hVep4BuheFc6Arple3OrV249KSwEqjIqHbAEJ_ymuvI,460
18
18
  h_ai/infrastructure/llm/ollama/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  h_ai/infrastructure/llm/ollama/ollama_chat_repository.py,sha256=GALea7UWLtKyt767Frtl3uv8rvy42HrOKMIQGpqq-H0,2108
20
- h_ai/infrastructure/llm/ollama/ollama_generate_repository.py,sha256=grLQwAQn2E1C-MPb0DBwuolLlSGb-AJL-yZas3gR2h8,1967
20
+ h_ai/infrastructure/llm/ollama/ollama_generate_repository.py,sha256=np6vYfn9sVrf_oKMN0y1QLdf7X2seWBOjvPS8OQghkc,1969
21
21
  h_ai/infrastructure/llm/ollama/ollama_tool_repository.py,sha256=7UZ-qsgXQUcJFx1qY7SVI7p3FhIy0Drdqs7jZIp42Ag,4683
22
22
  h_ai/infrastructure/llm/ollama/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  h_ai/infrastructure/llm/ollama/models/ollama_chat_message.py,sha256=ZIz4PQ3869vI3xAYYufPrxXpacajRDtOI8RDl5Dm9RQ,305
24
24
  h_ai/infrastructure/llm/ollama/models/ollama_chat_session.py,sha256=GZ_ddpbWa8iy6NZq50vokUFVZBiX0WNa81z9-r9RzTY,392
25
- h_ai_brain-0.0.20.dist-info/licenses/LICENSE,sha256=SbvpEU5JIU3yzMMkyzrI0dGqHDoJR_lMKGdl6GZHsy4,11558
26
- h_ai_brain-0.0.20.dist-info/licenses/NOTICE.txt,sha256=vxeIKUiGqAePLvDW4AVm3Xh-3BcsvMtCMn1tbsr9zsE,668
27
- h_ai_brain-0.0.20.dist-info/METADATA,sha256=BcSQW9rcNsnMTYKcMSQT7kR_EYcJjaTg3rDuAG0Vvmc,569
28
- h_ai_brain-0.0.20.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
29
- h_ai_brain-0.0.20.dist-info/top_level.txt,sha256=3MChDBWvDJV4cEHuZhzeODxQ4ewtw-arOuyaDOc6sIo,5
30
- h_ai_brain-0.0.20.dist-info/RECORD,,
25
+ h_ai_brain-0.0.22.dist-info/licenses/LICENSE,sha256=SbvpEU5JIU3yzMMkyzrI0dGqHDoJR_lMKGdl6GZHsy4,11558
26
+ h_ai_brain-0.0.22.dist-info/licenses/NOTICE.txt,sha256=vxeIKUiGqAePLvDW4AVm3Xh-3BcsvMtCMn1tbsr9zsE,668
27
+ h_ai_brain-0.0.22.dist-info/METADATA,sha256=1qw7KdgK6bWTAEZVsfqGpjEe-94RVtApgK6e67EnqUs,531
28
+ h_ai_brain-0.0.22.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
29
+ h_ai_brain-0.0.22.dist-info/top_level.txt,sha256=3MChDBWvDJV4cEHuZhzeODxQ4ewtw-arOuyaDOc6sIo,5
30
+ h_ai_brain-0.0.22.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5