prompt-caller 0.1.3__py3-none-any.whl → 0.1.4__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.
@@ -19,7 +19,6 @@ load_dotenv()
19
19
 
20
20
 
21
21
  class PromptCaller:
22
-
23
22
  def __init__(self, promptPath="prompts"):
24
23
  self.promptPath = promptPath
25
24
 
@@ -40,14 +39,33 @@ class PromptCaller:
40
39
  template = Template(body)
41
40
  return template.render(context)
42
41
 
42
+ import re
43
+
43
44
  def _parseJSXBody(self, body):
44
45
  elements = []
45
- tag_pattern = r"<(system|user|assistant|image)>(.*?)</\1>"
46
+ # 1. Regex to find tags, attributes string, and content
47
+ tag_pattern = r"<(system|user|assistant|image)([^>]*)>(.*?)</\1>"
48
+
49
+ # 2. Regex to find key="value" pairs within the attributes string
50
+ attr_pattern = r'(\w+)\s*=\s*"(.*?)"'
46
51
 
47
52
  matches = re.findall(tag_pattern, body, re.DOTALL)
48
53
 
49
- for tag, content in matches:
50
- elements.append({"role": tag, "content": content.strip()})
54
+ for tag, attrs_string, content in matches:
55
+ # 3. Parse the attributes string (e.g., ' tag="image 1"') into a dict
56
+ attributes = {}
57
+ if attrs_string:
58
+ attr_matches = re.findall(attr_pattern, attrs_string)
59
+ for key, value in attr_matches:
60
+ attributes[key] = value
61
+
62
+ element = {"role": tag, "content": content.strip()}
63
+
64
+ # 4. Add the attributes to our element dict if they exist
65
+ if attributes:
66
+ element["attributes"] = attributes
67
+
68
+ elements.append(element)
51
69
 
52
70
  return elements
53
71
 
@@ -96,16 +114,18 @@ class PromptCaller:
96
114
  if base64_image.startswith("http"):
97
115
  base64_image = self.getImageBase64(base64_image)
98
116
 
99
- messages.append(
100
- HumanMessage(
101
- content=[
102
- {
103
- "type": "image_url",
104
- "image_url": {"url": base64_image},
105
- }
106
- ]
107
- )
108
- )
117
+ content = [
118
+ {
119
+ "type": "image_url",
120
+ "image_url": {"url": base64_image},
121
+ }
122
+ ]
123
+
124
+ tag = message.get("attributes", {}).get("tag")
125
+ if tag:
126
+ content.append({"type": "text", "text": f"({tag})"})
127
+
128
+ messages.append(HumanMessage(content=content))
109
129
 
110
130
  return configuration, messages
111
131
 
@@ -119,7 +139,6 @@ class PromptCaller:
119
139
  return create_model("DynamicModel", **fields)
120
140
 
121
141
  def call(self, promptName, context=None):
122
-
123
142
  configuration, messages = self.loadPrompt(promptName, context)
124
143
 
125
144
  output = None
@@ -141,7 +160,6 @@ class PromptCaller:
141
160
  def agent(
142
161
  self, promptName, context=None, tools=None, output=None, allowed_steps=10
143
162
  ):
144
-
145
163
  configuration, messages = self.loadPrompt(promptName, context)
146
164
 
147
165
  dynamicOutput = None
@@ -152,7 +170,7 @@ class PromptCaller:
152
170
 
153
171
  for message in messages:
154
172
  if isinstance(message, SystemMessage):
155
- message.content += "\nOnly use the tool DynamicModel when providing an output call."
173
+ message.content += "\n\nYou have to use the tool `dynamicmodel` when providing your final answer. If you don't, you have failed the task."
156
174
  break
157
175
 
158
176
  chat = self._createChat(configuration)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prompt_caller
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: This package is responsible for calling prompts in a specific format. It uses LangChain and OpenAI API
5
5
  Home-page: https://github.com/ThiNepo/prompt-caller
6
6
  Author: Thiago Nepomuceno
@@ -14,6 +14,7 @@ Requires-Dist: pyyaml>=6.0.2
14
14
  Requires-Dist: python-dotenv>=1.0.1
15
15
  Requires-Dist: Jinja2>=3.1.4
16
16
  Requires-Dist: langchain-openai>=0.3.5
17
+ Requires-Dist: langchain-google-genai==2.1.5
17
18
  Requires-Dist: openai>=1.63.0
18
19
  Requires-Dist: pillow>=11.0.0
19
20
 
@@ -0,0 +1,8 @@
1
+ prompt_caller/__init__.py,sha256=4EGdeAJ_Ig7A-b-e17-nYbiXjckT7uL3to5lchMsoW4,41
2
+ prompt_caller/__main__.py,sha256=dJ0dYtVmnhZuoV79R6YiAIta1ZkUKb-TEX4VEuYbgk0,139
3
+ prompt_caller/prompt_caller.py,sha256=0Rqfzp7hUgPH10auxEwJMoaASOSZNlTyDvS8Hd6X0Yk,8333
4
+ prompt_caller-0.1.4.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
5
+ prompt_caller-0.1.4.dist-info/METADATA,sha256=0x0EKp50KvL-dYuc9n8TEvouL53jD_V1fMw2bSKGPEY,4955
6
+ prompt_caller-0.1.4.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
7
+ prompt_caller-0.1.4.dist-info/top_level.txt,sha256=iihiDRq-0VrKB8IKjxf7Lrtv-fLMq4tvgM4fH3x0I94,14
8
+ prompt_caller-0.1.4.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- prompt_caller/__init__.py,sha256=4EGdeAJ_Ig7A-b-e17-nYbiXjckT7uL3to5lchMsoW4,41
2
- prompt_caller/__main__.py,sha256=dJ0dYtVmnhZuoV79R6YiAIta1ZkUKb-TEX4VEuYbgk0,139
3
- prompt_caller/prompt_caller.py,sha256=XKmYQuU4XMFeeUEPjTEukpinAlapHOB_ZgWORVb9GnI,7489
4
- prompt_caller-0.1.3.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
5
- prompt_caller-0.1.3.dist-info/METADATA,sha256=eOke1OseFZfeHAggOBrIDbXIRLTlkUrlPV1bn8t0WUY,4909
6
- prompt_caller-0.1.3.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
7
- prompt_caller-0.1.3.dist-info/top_level.txt,sha256=iihiDRq-0VrKB8IKjxf7Lrtv-fLMq4tvgM4fH3x0I94,14
8
- prompt_caller-0.1.3.dist-info/RECORD,,