prompt-caller 0.2.0__tar.gz → 0.2.1__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.2.0 → prompt_caller-0.2.1}/PKG-INFO +2 -2
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/prompt_caller/prompt_caller.py +14 -49
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/prompt_caller.egg-info/PKG-INFO +2 -2
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/prompt_caller.egg-info/requires.txt +1 -1
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/setup.py +2 -2
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/LICENSE +0 -0
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/README.md +0 -0
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/prompt_caller/__init__.py +0 -0
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/prompt_caller/__main__.py +0 -0
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/prompt_caller.egg-info/SOURCES.txt +0 -0
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/prompt_caller.egg-info/dependency_links.txt +0 -0
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/prompt_caller.egg-info/top_level.txt +0 -0
- {prompt_caller-0.2.0 → prompt_caller-0.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prompt_caller
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
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
|
|
@@ -13,7 +13,7 @@ License-File: LICENSE
|
|
|
13
13
|
Requires-Dist: pyyaml>=6.0.2
|
|
14
14
|
Requires-Dist: python-dotenv>=1.2.1
|
|
15
15
|
Requires-Dist: Jinja2>=3.1.4
|
|
16
|
-
Requires-Dist: langchain
|
|
16
|
+
Requires-Dist: langchain>=1.2.7
|
|
17
17
|
Requires-Dist: langchain-openai>=1.1.7
|
|
18
18
|
Requires-Dist: langchain-google-genai>=4.2.0
|
|
19
19
|
Requires-Dist: openai>=2.16.0
|
|
@@ -161,72 +161,40 @@ class PromptCaller:
|
|
|
161
161
|
|
|
162
162
|
return response
|
|
163
163
|
|
|
164
|
-
def
|
|
165
|
-
"""Middleware to handle tool responses that contain
|
|
164
|
+
def _create_media_middleware(self):
|
|
165
|
+
"""Middleware to handle tool responses that contain media content (images, PDFs)."""
|
|
166
166
|
|
|
167
167
|
@wrap_tool_call
|
|
168
|
-
def
|
|
169
|
-
# Execute the actual tool
|
|
168
|
+
def handle_media_response(request, handler):
|
|
170
169
|
result = handler(request)
|
|
171
170
|
|
|
172
|
-
# Check if result content is pdf data
|
|
173
171
|
if hasattr(result, "content"):
|
|
174
172
|
content = result.content
|
|
175
|
-
# Try to parse if it's a string representation of a list
|
|
176
|
-
if isinstance(content, str) and content.startswith("["):
|
|
177
|
-
try:
|
|
178
|
-
content = ast.literal_eval(content)
|
|
179
|
-
except (ValueError, SyntaxError):
|
|
180
|
-
pass
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
isinstance(content, list)
|
|
184
|
-
and content
|
|
185
|
-
and isinstance(content[0], dict)
|
|
186
|
-
and "input_file" in content[0]
|
|
187
|
-
and "pdf" in content[0]["file_data"]
|
|
188
|
-
):
|
|
189
|
-
# Use Command to add both tool result and image to messages
|
|
190
|
-
return Command(
|
|
191
|
-
update={"messages": [result, HumanMessage(content=content)]}
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
return result # Return normal result
|
|
195
|
-
|
|
196
|
-
return handle_pdf_response
|
|
197
|
-
|
|
198
|
-
def _create_image_middleware(self):
|
|
199
|
-
"""Middleware to handle tool responses that contain image content."""
|
|
200
173
|
|
|
201
|
-
@wrap_tool_call
|
|
202
|
-
def handle_image_response(request, handler):
|
|
203
|
-
# Execute the actual tool
|
|
204
|
-
result = handler(request)
|
|
205
|
-
|
|
206
|
-
# Check if result content is image data (list with image_url dict)
|
|
207
|
-
if hasattr(result, "content"):
|
|
208
|
-
content = result.content
|
|
209
|
-
# Try to parse if it's a string representation of a list
|
|
210
174
|
if isinstance(content, str) and content.startswith("["):
|
|
211
175
|
try:
|
|
212
176
|
content = ast.literal_eval(content)
|
|
213
177
|
except (ValueError, SyntaxError):
|
|
214
178
|
pass
|
|
215
179
|
|
|
180
|
+
# Check if content is media (image or PDF)
|
|
216
181
|
if (
|
|
217
182
|
isinstance(content, list)
|
|
218
183
|
and content
|
|
219
184
|
and isinstance(content[0], dict)
|
|
220
|
-
and "image_url" in content[0]
|
|
221
185
|
):
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
186
|
+
is_media = (
|
|
187
|
+
"image_url" in content[0] # Image
|
|
188
|
+
or ("input_file" == content[0].get("type", "").strip()) # PDF
|
|
225
189
|
)
|
|
190
|
+
if is_media:
|
|
191
|
+
return Command(
|
|
192
|
+
update={"messages": [result, HumanMessage(content=content)]}
|
|
193
|
+
)
|
|
226
194
|
|
|
227
|
-
return result
|
|
195
|
+
return result
|
|
228
196
|
|
|
229
|
-
return
|
|
197
|
+
return handle_media_response
|
|
230
198
|
|
|
231
199
|
def agent(
|
|
232
200
|
self, promptName, context=None, tools=None, output=None, allowed_steps=10
|
|
@@ -267,10 +235,7 @@ class PromptCaller:
|
|
|
267
235
|
tools=tools,
|
|
268
236
|
system_prompt=system_prompt,
|
|
269
237
|
response_format=response_format,
|
|
270
|
-
middleware=[
|
|
271
|
-
self._create_image_middleware(),
|
|
272
|
-
self._create_pdf_middleware(),
|
|
273
|
-
],
|
|
238
|
+
middleware=[self._create_media_middleware()],
|
|
274
239
|
)
|
|
275
240
|
|
|
276
241
|
result = agent_graph.invoke(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prompt_caller
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
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
|
|
@@ -13,7 +13,7 @@ License-File: LICENSE
|
|
|
13
13
|
Requires-Dist: pyyaml>=6.0.2
|
|
14
14
|
Requires-Dist: python-dotenv>=1.2.1
|
|
15
15
|
Requires-Dist: Jinja2>=3.1.4
|
|
16
|
-
Requires-Dist: langchain
|
|
16
|
+
Requires-Dist: langchain>=1.2.7
|
|
17
17
|
Requires-Dist: langchain-openai>=1.1.7
|
|
18
18
|
Requires-Dist: langchain-google-genai>=4.2.0
|
|
19
19
|
Requires-Dist: openai>=2.16.0
|
|
@@ -35,7 +35,7 @@ class BdistWheelCommand(bdist_wheel):
|
|
|
35
35
|
|
|
36
36
|
setuptools.setup(
|
|
37
37
|
name="prompt_caller",
|
|
38
|
-
version="0.2.
|
|
38
|
+
version="0.2.1",
|
|
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",
|
|
@@ -53,7 +53,7 @@ setuptools.setup(
|
|
|
53
53
|
"pyyaml>=6.0.2",
|
|
54
54
|
"python-dotenv>=1.2.1",
|
|
55
55
|
"Jinja2>=3.1.4",
|
|
56
|
-
"langchain
|
|
56
|
+
"langchain>=1.2.7",
|
|
57
57
|
"langchain-openai>=1.1.7",
|
|
58
58
|
"langchain-google-genai>=4.2.0",
|
|
59
59
|
"openai>=2.16.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|