prompt-caller 0.1.3__tar.gz → 0.1.4__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.
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/PKG-INFO +2 -1
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/prompt_caller/prompt_caller.py +35 -17
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/prompt_caller.egg-info/PKG-INFO +2 -1
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/prompt_caller.egg-info/requires.txt +1 -0
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/setup.py +2 -1
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/LICENSE +0 -0
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/README.md +0 -0
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/prompt_caller/__init__.py +0 -0
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/prompt_caller/__main__.py +0 -0
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/prompt_caller.egg-info/SOURCES.txt +0 -0
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/prompt_caller.egg-info/dependency_links.txt +0 -0
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/prompt_caller.egg-info/top_level.txt +0 -0
- {prompt_caller-0.1.3 → prompt_caller-0.1.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prompt_caller
|
|
3
|
-
Version: 0.1.
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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 += "\
|
|
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
|
+
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
|
|
|
@@ -35,7 +35,7 @@ class BdistWheelCommand(bdist_wheel):
|
|
|
35
35
|
|
|
36
36
|
setuptools.setup(
|
|
37
37
|
name="prompt_caller",
|
|
38
|
-
version="0.1.
|
|
38
|
+
version="0.1.4",
|
|
39
39
|
author="Thiago Nepomuceno",
|
|
40
40
|
author_email="thiago@neps.academy",
|
|
41
41
|
description="This package is responsible for calling prompts in a specific format. It uses LangChain and OpenAI API",
|
|
@@ -54,6 +54,7 @@ setuptools.setup(
|
|
|
54
54
|
"python-dotenv>=1.0.1",
|
|
55
55
|
"Jinja2>=3.1.4",
|
|
56
56
|
"langchain-openai>=0.3.5",
|
|
57
|
+
"langchain-google-genai==2.1.5",
|
|
57
58
|
"openai>=1.63.0",
|
|
58
59
|
"pillow>=11.0.0",
|
|
59
60
|
],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|