h-ai-brain 0.0.17__py3-none-any.whl → 0.0.19__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/application/hai_service.py +15 -8
- h_ai/domain/llm_config.py +6 -0
- h_ai/infrastructure/llm/ollama/ollama_generate_repository.py +10 -6
- h_ai/infrastructure/llm/prompt_loader.py +1 -1
- {h_ai_brain-0.0.17.dist-info → h_ai_brain-0.0.19.dist-info}/METADATA +2 -2
- {h_ai_brain-0.0.17.dist-info → h_ai_brain-0.0.19.dist-info}/RECORD +10 -11
- {h_ai_brain-0.0.17.dist-info → h_ai_brain-0.0.19.dist-info}/WHEEL +1 -1
- h_ai/application/system_prompts/__init__.py +0 -0
- h_ai/application/system_prompts/roles/__init__.py +0 -0
- {h_ai_brain-0.0.17.dist-info → h_ai_brain-0.0.19.dist-info}/licenses/LICENSE +0 -0
- {h_ai_brain-0.0.17.dist-info → h_ai_brain-0.0.19.dist-info}/licenses/NOTICE.txt +0 -0
- {h_ai_brain-0.0.17.dist-info → h_ai_brain-0.0.19.dist-info}/top_level.txt +0 -0
h_ai/application/hai_service.py
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
from h_message_bus import NatsPublisherAdapter
|
2
|
-
|
3
|
-
from
|
2
|
+
|
3
|
+
from ..domain.llm_config import LLMConfig
|
4
|
+
from ..infrastructure.llm.ollama.ollama_generate_repository import OllamaGenerateRepository
|
5
|
+
|
4
6
|
|
5
7
|
class HaiService:
|
6
|
-
def __init__(self, nats_publisher_adapter: NatsPublisherAdapter):
|
8
|
+
def __init__(self, nats_publisher_adapter: NatsPublisherAdapter, llm_config: LLMConfig):
|
7
9
|
self.nats_publisher_adapter = nats_publisher_adapter
|
10
|
+
self.llm_config = llm_config
|
11
|
+
self.llm_generate_repository = OllamaGenerateRepository(
|
12
|
+
self.llm_config.url,
|
13
|
+
self.llm_config.model_name,
|
14
|
+
temperature=self.llm_config.temperature,
|
15
|
+
max_tokens=self.llm_config.max_tokens)
|
16
|
+
|
17
|
+
def ask_question(self, question: str, system_prompt: str = None, max_tokens = None) -> str:
|
18
|
+
return self.llm_generate_repository.generate(question, system_prompt, max_tokens)
|
19
|
+
|
8
20
|
|
9
|
-
async def get_knowledgebase_metadata(self) -> VectorReadMetaDataResponseMessage:
|
10
|
-
message = VectorReadMetaDataRequestMessage.create_message()
|
11
|
-
response = await self.nats_publisher_adapter.request(message)
|
12
|
-
metadata_result = VectorReadMetaDataResponseMessage.from_hai_message(response)
|
13
|
-
return metadata_result
|
@@ -2,20 +2,22 @@ import uuid
|
|
2
2
|
|
3
3
|
import requests
|
4
4
|
|
5
|
+
from ..llm_response_cleaner import clean_llm_response
|
5
6
|
from ....domain.reasoning.llm_generate_respository import LlmGenerateRepository
|
6
7
|
|
7
8
|
|
8
9
|
class OllamaGenerateRepository(LlmGenerateRepository):
|
9
10
|
|
10
|
-
def __init__(self, api_url: str, model_name: str, system_prompt: str = None, temperature: float = None, seed: int = None):
|
11
|
+
def __init__(self, api_url: str, model_name: str, system_prompt: str = None, temperature: float = None, seed: int = None, max_tokens: int = 5000):
|
11
12
|
self.model_name = model_name
|
12
13
|
self.system_prompt = system_prompt
|
13
14
|
self.api_url = api_url
|
14
15
|
self.temperature = temperature
|
15
16
|
self.seed = seed
|
17
|
+
self.max_tokens = max_tokens
|
16
18
|
|
17
19
|
|
18
|
-
def generate(self, user_prompt: str, system_prompt: str = None, session_id: str = None) -> str|None:
|
20
|
+
def generate(self, user_prompt: str, system_prompt: str = None, session_id: str = None, max_tokens: int = None) -> str|None:
|
19
21
|
url = f"{self.api_url}/generate"
|
20
22
|
random_guid = uuid.uuid4()
|
21
23
|
guid_str = str(random_guid)
|
@@ -26,16 +28,18 @@ class OllamaGenerateRepository(LlmGenerateRepository):
|
|
26
28
|
"system": system_prompt,
|
27
29
|
"stream": False,
|
28
30
|
"session": guid_str,
|
29
|
-
"num_ctx": "
|
30
|
-
"temperature": "
|
31
|
+
"num_ctx": f"{self.max_tokens}",
|
32
|
+
"temperature": f"{self.temperature}"
|
31
33
|
}
|
32
34
|
|
33
35
|
if session_id:
|
34
36
|
payload["session"] = session_id
|
35
37
|
if self.seed:
|
36
|
-
payload["seed"] = self.seed
|
38
|
+
payload["seed"] = f"{self.seed}"
|
37
39
|
if self.temperature:
|
38
|
-
payload["temperature"] = self.temperature
|
40
|
+
payload["temperature"] = f"{self.temperature}"
|
41
|
+
if max_tokens:
|
42
|
+
payload["num_ctx"] = f"{max_tokens}"
|
39
43
|
|
40
44
|
try:
|
41
45
|
print(payload)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: h_ai_brain
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.19
|
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,7 @@ 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.
|
13
|
+
Requires-Dist: h_message_bus~=0.0.22
|
14
14
|
Provides-Extra: dev
|
15
15
|
Requires-Dist: pytest; extra == "dev"
|
16
16
|
Dynamic: license-file
|
@@ -1,9 +1,8 @@
|
|
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=
|
4
|
-
h_ai/application/system_prompts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
h_ai/application/system_prompts/roles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
h_ai/application/hai_service.py,sha256=k7bhMwqJxrpj2rtH_rQokOEYdIzl6bx69bmoyvqzybA,844
|
6
4
|
h_ai/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
h_ai/domain/llm_config.py,sha256=xdyRoc26yDoKy8Y5L724TT6LoF3MEOpi7SZPQvS-lx8,258
|
7
6
|
h_ai/domain/reasoning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
7
|
h_ai/domain/reasoning/llm_chat_repository.py,sha256=rY2izDyaDnoyyrCRS1qc9erHB98vARj4Mp-SnPwNhyY,211
|
9
8
|
h_ai/domain/reasoning/llm_generate_respository.py,sha256=DPiV6ldCE8YhDdVb5rj98MBudKalDQHV3CZ2ADTm_f8,178
|
@@ -15,17 +14,17 @@ h_ai/infrastructure/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
15
14
|
h_ai/infrastructure/llm/data_handler.py,sha256=M2h1azkjBP9GyaffTggKQZb2CQmOvAk2yo9NrsFMYAo,987
|
16
15
|
h_ai/infrastructure/llm/llm_response_cleaner.py,sha256=pp1K7I77hagrC1r6Ib61-iSNQnU6wlM54bRmOUa7eFk,859
|
17
16
|
h_ai/infrastructure/llm/prompt_helper.py,sha256=QjxPbNW7hu2wBIi9GLJ7r00ELytT2Wr1JKDAA1jB2U4,238
|
18
|
-
h_ai/infrastructure/llm/prompt_loader.py,sha256=
|
17
|
+
h_ai/infrastructure/llm/prompt_loader.py,sha256=hVep4BuheFc6Arple3OrV249KSwEqjIqHbAEJ_ymuvI,460
|
19
18
|
h_ai/infrastructure/llm/ollama/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
19
|
h_ai/infrastructure/llm/ollama/ollama_chat_repository.py,sha256=GALea7UWLtKyt767Frtl3uv8rvy42HrOKMIQGpqq-H0,2108
|
21
|
-
h_ai/infrastructure/llm/ollama/ollama_generate_repository.py,sha256=
|
20
|
+
h_ai/infrastructure/llm/ollama/ollama_generate_repository.py,sha256=grLQwAQn2E1C-MPb0DBwuolLlSGb-AJL-yZas3gR2h8,1967
|
22
21
|
h_ai/infrastructure/llm/ollama/ollama_tool_repository.py,sha256=7UZ-qsgXQUcJFx1qY7SVI7p3FhIy0Drdqs7jZIp42Ag,4683
|
23
22
|
h_ai/infrastructure/llm/ollama/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
24
23
|
h_ai/infrastructure/llm/ollama/models/ollama_chat_message.py,sha256=ZIz4PQ3869vI3xAYYufPrxXpacajRDtOI8RDl5Dm9RQ,305
|
25
24
|
h_ai/infrastructure/llm/ollama/models/ollama_chat_session.py,sha256=GZ_ddpbWa8iy6NZq50vokUFVZBiX0WNa81z9-r9RzTY,392
|
26
|
-
h_ai_brain-0.0.
|
27
|
-
h_ai_brain-0.0.
|
28
|
-
h_ai_brain-0.0.
|
29
|
-
h_ai_brain-0.0.
|
30
|
-
h_ai_brain-0.0.
|
31
|
-
h_ai_brain-0.0.
|
25
|
+
h_ai_brain-0.0.19.dist-info/licenses/LICENSE,sha256=SbvpEU5JIU3yzMMkyzrI0dGqHDoJR_lMKGdl6GZHsy4,11558
|
26
|
+
h_ai_brain-0.0.19.dist-info/licenses/NOTICE.txt,sha256=vxeIKUiGqAePLvDW4AVm3Xh-3BcsvMtCMn1tbsr9zsE,668
|
27
|
+
h_ai_brain-0.0.19.dist-info/METADATA,sha256=AcpQoCaSmqAcQa8-J5Sj2KRZQYnrsqc-JAVbxATvhHA,536
|
28
|
+
h_ai_brain-0.0.19.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
29
|
+
h_ai_brain-0.0.19.dist-info/top_level.txt,sha256=3MChDBWvDJV4cEHuZhzeODxQ4ewtw-arOuyaDOc6sIo,5
|
30
|
+
h_ai_brain-0.0.19.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|