sinapsis-chatbots-base 0.1.0__tar.gz → 0.1.2__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.
Files changed (20) hide show
  1. {sinapsis_chatbots_base-0.1.0/src/sinapsis_chatbots_base.egg-info → sinapsis_chatbots_base-0.1.2}/PKG-INFO +2 -2
  2. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/pyproject.toml +5 -3
  3. sinapsis_chatbots_base-0.1.2/src/sinapsis_chatbots_base/helpers/huggingface_access_keys.py +35 -0
  4. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base/templates/__init__.py +0 -1
  5. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base/templates/llm_text_completion_base.py +10 -6
  6. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base/templates/query_contextualize.py +4 -1
  7. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base/templates/query_contextualize_from_file.py +3 -0
  8. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2/src/sinapsis_chatbots_base.egg-info}/PKG-INFO +2 -2
  9. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base.egg-info/SOURCES.txt +1 -0
  10. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/LICENSE +0 -0
  11. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/README.md +0 -0
  12. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/setup.cfg +0 -0
  13. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/__init__.py +0 -0
  14. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base/__init__.py +0 -0
  15. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base/helpers/__init__.py +0 -0
  16. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base/helpers/llm_keys.py +0 -0
  17. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base/helpers/postprocess_text.py +0 -0
  18. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base.egg-info/dependency_links.txt +0 -0
  19. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base.egg-info/requires.txt +0 -0
  20. {sinapsis_chatbots_base-0.1.0 → sinapsis_chatbots_base-0.1.2}/src/sinapsis_chatbots_base.egg-info/top_level.txt +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sinapsis-chatbots-base
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Package with base functionality for llm text creation
5
5
  Project-URL: Homepage, https://sinapsis.tech
6
6
  Project-URL: Documentation, https://docs.sinapsis.tech/docs
7
7
  Project-URL: Tutorials, https://docs.sinapsis.tech/tutorials
8
8
  Project-URL: Repository, https://github.com/Sinapsis-AI/sinapsis-chatbots.git
9
- Requires-Python: >=3.10.12
9
+ Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: sinapsis>=0.2.0
@@ -1,9 +1,10 @@
1
1
  [project]
2
2
  name = "sinapsis-chatbots-base"
3
- version = "0.1.0"
3
+ version = "0.1.2"
4
4
  description = "Package with base functionality for llm text creation"
5
5
  readme = "README.md"
6
- requires-python = ">=3.10.12"
6
+ requires-python = ">=3.10"
7
+ license-files = ["LICENSE"]
7
8
  dependencies = [
8
9
  "sinapsis>=0.2.0",
9
10
  ]
@@ -43,7 +44,8 @@ url = "https://pypi.sinapsis.tech/"
43
44
  [project.optional-dependencies]
44
45
 
45
46
  chatbot = [
46
- "sinapsis-huggingface-transformers>=0.1.0"]
47
+ "sinapsis-huggingface-transformers>=0.1.0",
48
+ ]
47
49
 
48
50
  all = ["sinapsis-chatbots-base[chatbot]"]
49
51
 
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ from typing import Any
3
+
4
+ from pydantic import BaseModel
5
+ from sinapsis_core.utils.env_var_keys import EnvVarEntry, doc_str, return_docs_for_vars
6
+
7
+
8
+ class _HuggingfaceEnvVars(BaseModel):
9
+ """
10
+ Env vars for HuggingFace
11
+ """
12
+
13
+ HF_TOKEN: EnvVarEntry = EnvVarEntry(
14
+ var_name="OPENAI_API_KHF_TOKEN",
15
+ default_value=" ",
16
+ allowed_values=None,
17
+ description="set api key for HuggingFace API",
18
+ )
19
+
20
+
21
+ HuggingFaceEnvVars = _HuggingfaceEnvVars()
22
+
23
+ doc_str = return_docs_for_vars(HuggingFaceEnvVars, docs=doc_str, string_for_doc="""HF env vars available: \n""")
24
+ __doc__ = doc_str
25
+
26
+
27
+ def __getattr__(name: str) -> Any:
28
+ """to use as an import, when updating the value is not important"""
29
+ if name in HuggingFaceEnvVars.model_fields:
30
+ return HuggingFaceEnvVars.model_fields[name].default.value
31
+
32
+ raise AttributeError(f"Agent does not have `{name}` env var")
33
+
34
+
35
+ _all__ = (*list(HuggingFaceEnvVars.model_fields.keys()), "HuggingFaceEnvVars")
@@ -5,7 +5,6 @@ from typing import Callable
5
5
  _root_lib_path = "sinapsis_chatbots_base.templates"
6
6
 
7
7
  _template_lookup = {
8
- "QueryContextualizeFromText": f"{_root_lib_path}.query_contextualize_from_text",
9
8
  "QueryContextualizeFromFile": f"{_root_lib_path}.query_contextualize_from_file",
10
9
  }
11
10
 
@@ -7,10 +7,12 @@ from pathlib import Path
7
7
  from typing import Any, Literal
8
8
 
9
9
  from sinapsis_core.data_containers.data_packet import DataContainer, TextPacket
10
- from sinapsis_core.template_base import (
11
- Template,
10
+ from sinapsis_core.template_base import Template
11
+ from sinapsis_core.template_base.base_models import (
12
+ OutputTypes,
12
13
  TemplateAttributes,
13
14
  TemplateAttributeType,
15
+ UIPropertiesMetadata,
14
16
  )
15
17
 
16
18
  from sinapsis_chatbots_base.helpers.llm_keys import LLMChatKeys
@@ -69,6 +71,7 @@ class LLMTextCompletionBase(Template):
69
71
  """
70
72
 
71
73
  AttributesBaseModel = LLMTextCompletionAttributes
74
+ UIProperties = UIPropertiesMetadata(category="Chatbots", output_type=OutputTypes.TEXT)
72
75
 
73
76
  def __init__(self, attributes: TemplateAttributeType) -> None:
74
77
  """
@@ -121,12 +124,12 @@ class LLMTextCompletionBase(Template):
121
124
  raise NotImplementedError("Must be implemented by the subclass.")
122
125
 
123
126
  @abstractmethod
124
- def get_response(self, input_message: str | list) -> str | None:
127
+ def get_response(self, input_message: str | list | dict) -> str | None:
125
128
  """
126
129
  Generates a response from the model based on the provided text input.
127
130
 
128
131
  Args:
129
- input_message (str | list): The input text or prompt to which the model
132
+ input_message (str | list | dict): The input text or prompt to which the model
130
133
  will respond.
131
134
 
132
135
  Returns:
@@ -184,12 +187,12 @@ class LLMTextCompletionBase(Template):
184
187
  self.context[conv_id].append(message)
185
188
 
186
189
  @staticmethod
187
- def generate_dict_msg(role: str, msg_content: str | None) -> dict:
190
+ def generate_dict_msg(role: str, msg_content: str | list | None) -> dict:
188
191
  """For the provided content, generate a dictionary to be appended as the context
189
192
  for the response.
190
193
  Args:
191
194
  role (str): Role of the message, Can be system, user or assistant
192
- msg_content (str | None): Content of the message to be passed to the llm.
195
+ msg_content (str | list | None): Content of the message to be passed to the llm.
193
196
  Returns:
194
197
  The dictionary with the key pair values for role and content.
195
198
 
@@ -249,6 +252,7 @@ class LLMTextCompletionBase(Template):
249
252
  self.logger.debug("End of interaction.")
250
253
 
251
254
  responses.append(TextPacket(source=self.instance_name, content=response, id=conv_id))
255
+
252
256
  container.texts.extend(responses)
253
257
  return container
254
258
 
@@ -3,7 +3,8 @@ import abc
3
3
  from typing import Any
4
4
 
5
5
  from sinapsis_core.data_containers.data_packet import DataContainer
6
- from sinapsis_core.template_base import Template, TemplateAttributes
6
+ from sinapsis_core.template_base import Template
7
+ from sinapsis_core.template_base.base_models import OutputTypes, TemplateAttributes, UIPropertiesMetadata
7
8
 
8
9
 
9
10
  class QueryContextualize(Template, abc.ABC):
@@ -18,6 +19,8 @@ class QueryContextualize(Template, abc.ABC):
18
19
 
19
20
  keywords: list[str]
20
21
 
22
+ UIProperties = UIPropertiesMetadata(category="Chatbots", output_type=OutputTypes.TEXT)
23
+
21
24
  @abc.abstractmethod
22
25
  def retrieve_context(self, keyword: str, context_data: dict | Any) -> str:
23
26
  """
@@ -2,6 +2,7 @@
2
2
  from typing import Any
3
3
 
4
4
  from sinapsis_core.data_containers.data_packet import DataContainer
5
+ from sinapsis_core.template_base.base_models import OutputTypes, UIPropertiesMetadata
5
6
 
6
7
  from sinapsis_chatbots_base.templates.query_contextualize import (
7
8
  QueryContextualize,
@@ -38,6 +39,8 @@ class QueryContextualizeFromFile(QueryContextualize):
38
39
 
39
40
  generic_keys: list[str]
40
41
 
42
+ UIProperties = UIPropertiesMetadata(category="Chatbots", output_type=OutputTypes.TEXT)
43
+
41
44
  def retrieve_context(self, keyword: str, context_data: dict | Any) -> str:
42
45
  """Retrieve the context associated with the given keyword from the provided
43
46
  context data.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sinapsis-chatbots-base
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Package with base functionality for llm text creation
5
5
  Project-URL: Homepage, https://sinapsis.tech
6
6
  Project-URL: Documentation, https://docs.sinapsis.tech/docs
7
7
  Project-URL: Tutorials, https://docs.sinapsis.tech/tutorials
8
8
  Project-URL: Repository, https://github.com/Sinapsis-AI/sinapsis-chatbots.git
9
- Requires-Python: >=3.10.12
9
+ Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: sinapsis>=0.2.0
@@ -9,6 +9,7 @@ src/sinapsis_chatbots_base.egg-info/dependency_links.txt
9
9
  src/sinapsis_chatbots_base.egg-info/requires.txt
10
10
  src/sinapsis_chatbots_base.egg-info/top_level.txt
11
11
  src/sinapsis_chatbots_base/helpers/__init__.py
12
+ src/sinapsis_chatbots_base/helpers/huggingface_access_keys.py
12
13
  src/sinapsis_chatbots_base/helpers/llm_keys.py
13
14
  src/sinapsis_chatbots_base/helpers/postprocess_text.py
14
15
  src/sinapsis_chatbots_base/templates/__init__.py