sinapsis-chatbots-base 0.1.4__tar.gz → 0.1.6__tar.gz
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.
- {sinapsis_chatbots_base-0.1.4/src/sinapsis_chatbots_base.egg-info → sinapsis_chatbots_base-0.1.6}/PKG-INFO +1 -1
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/pyproject.toml +1 -1
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/templates/llm_text_completion_base.py +14 -10
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/templates/query_contextualize.py +0 -3
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6/src/sinapsis_chatbots_base.egg-info}/PKG-INFO +1 -1
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/LICENSE +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/README.md +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/setup.cfg +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/__init__.py +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/__init__.py +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/helpers/__init__.py +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/helpers/huggingface_access_keys.py +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/helpers/llm_keys.py +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/helpers/postprocess_text.py +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/templates/__init__.py +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/templates/query_contextualize_from_file.py +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base.egg-info/SOURCES.txt +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base.egg-info/dependency_links.txt +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base.egg-info/requires.txt +0 -0
- {sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base.egg-info/top_level.txt +0 -0
|
@@ -51,6 +51,7 @@ class LLMTextCompletionAttributes(TemplateAttributes):
|
|
|
51
51
|
llm_model_name: str
|
|
52
52
|
n_ctx: int = 9000
|
|
53
53
|
role: Literal["system", "user", "assistant"] = "assistant"
|
|
54
|
+
generic_key: str = "SourceHistoryAggregator"
|
|
54
55
|
prompt: str = ""
|
|
55
56
|
system_prompt: str | Path | None = None
|
|
56
57
|
chat_format: str = "chatml"
|
|
@@ -89,7 +90,7 @@ class LLMTextCompletionBase(Template):
|
|
|
89
90
|
|
|
90
91
|
def _set_system_prompt(self):
|
|
91
92
|
system_prompt = self.attributes.system_prompt
|
|
92
|
-
if ("/" in system_prompt) or ("\\" in system_prompt) or (system_prompt.endswith(".txt")):
|
|
93
|
+
if system_prompt and (("/" in system_prompt) or ("\\" in system_prompt) or (system_prompt.endswith(".txt"))):
|
|
93
94
|
return Path(system_prompt).read_text()
|
|
94
95
|
else:
|
|
95
96
|
return system_prompt
|
|
@@ -209,7 +210,7 @@ class LLMTextCompletionBase(Template):
|
|
|
209
210
|
tuple[str, str]: The pair of conversation_id and message
|
|
210
211
|
"""
|
|
211
212
|
if packet:
|
|
212
|
-
conv_id = packet.
|
|
213
|
+
conv_id = packet.source
|
|
213
214
|
prompt = packet.content
|
|
214
215
|
else:
|
|
215
216
|
conv_id = str(uuid.uuid4())
|
|
@@ -236,22 +237,25 @@ class LLMTextCompletionBase(Template):
|
|
|
236
237
|
|
|
237
238
|
self.logger.debug("Chatbot in progress")
|
|
238
239
|
responses = []
|
|
240
|
+
full_context = []
|
|
241
|
+
contexts = self._get_generic_data(container, self.attributes.generic_key)
|
|
242
|
+
for context in contexts:
|
|
243
|
+
context_message = self.generate_dict_msg(LLMChatKeys.user_value, context)
|
|
244
|
+
full_context.append(context_message)
|
|
239
245
|
for packet in container.texts:
|
|
240
246
|
conv_id, prompt = self.get_conv_id_and_content(packet)
|
|
241
|
-
self._set_context(conv_id)
|
|
242
|
-
|
|
243
247
|
if self.system_prompt:
|
|
244
248
|
system_prompt_msg = self.generate_dict_msg(LLMChatKeys.system_value, self.system_prompt)
|
|
245
|
-
|
|
249
|
+
full_context.append(system_prompt_msg)
|
|
246
250
|
|
|
247
251
|
message = self.generate_dict_msg(LLMChatKeys.user_value, prompt)
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
self.
|
|
252
|
+
|
|
253
|
+
full_context.append(message)
|
|
254
|
+
response = self.infer(full_context)
|
|
255
|
+
_ = self.generate_dict_msg(LLMChatKeys.assistant_value, response)
|
|
252
256
|
self.logger.debug("End of interaction.")
|
|
253
257
|
|
|
254
|
-
responses.append(TextPacket(source=
|
|
258
|
+
responses.append(TextPacket(source=conv_id, content=response, id=conv_id))
|
|
255
259
|
|
|
256
260
|
container.texts.extend(responses)
|
|
257
261
|
return container
|
|
@@ -68,9 +68,6 @@ class QueryContextualize(Template, abc.ABC):
|
|
|
68
68
|
if context:
|
|
69
69
|
text_packet.content += f" here is the context: {context}"
|
|
70
70
|
|
|
71
|
-
if context:
|
|
72
|
-
text_packet.content += f" here is the context: {context}"
|
|
73
|
-
|
|
74
71
|
@abc.abstractmethod
|
|
75
72
|
def add_context_to_content(self, kwd: str, container: DataContainer) -> str:
|
|
76
73
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sinapsis_chatbots_base-0.1.4 → sinapsis_chatbots_base-0.1.6}/src/sinapsis_chatbots_base/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|