prompt-caller 0.1.1__py3-none-any.whl → 0.1.2__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.
- prompt_caller/prompt_caller.py +16 -7
- {prompt_caller-0.1.1.dist-info → prompt_caller-0.1.2.dist-info}/METADATA +1 -1
- prompt_caller-0.1.2.dist-info/RECORD +8 -0
- prompt_caller-0.1.1.dist-info/RECORD +0 -8
- {prompt_caller-0.1.1.dist-info → prompt_caller-0.1.2.dist-info}/LICENSE +0 -0
- {prompt_caller-0.1.1.dist-info → prompt_caller-0.1.2.dist-info}/WHEEL +0 -0
- {prompt_caller-0.1.1.dist-info → prompt_caller-0.1.2.dist-info}/top_level.txt +0 -0
prompt_caller/prompt_caller.py
CHANGED
|
@@ -129,14 +129,16 @@ class PromptCaller:
|
|
|
129
129
|
|
|
130
130
|
return response
|
|
131
131
|
|
|
132
|
-
def agent(
|
|
132
|
+
def agent(
|
|
133
|
+
self, promptName, context=None, tools=None, output=None, allowed_steps=10
|
|
134
|
+
):
|
|
133
135
|
|
|
134
136
|
configuration, messages = self.loadPrompt(promptName, context)
|
|
135
137
|
|
|
136
|
-
|
|
138
|
+
dynamicOutput = None
|
|
137
139
|
|
|
138
|
-
if "output" in configuration:
|
|
139
|
-
|
|
140
|
+
if output is None and "output" in configuration:
|
|
141
|
+
dynamicOutput = configuration.get("output")
|
|
140
142
|
configuration.pop("output")
|
|
141
143
|
|
|
142
144
|
for message in messages:
|
|
@@ -156,10 +158,13 @@ class PromptCaller:
|
|
|
156
158
|
tools_dict = {t.name.lower(): t for t in tools}
|
|
157
159
|
|
|
158
160
|
if output:
|
|
161
|
+
tools.extend([output])
|
|
162
|
+
tools_dict[output.__name__.lower()] = output
|
|
163
|
+
elif dynamicOutput:
|
|
159
164
|
dynamicModel = self.createPydanticModel(output)
|
|
160
165
|
|
|
161
|
-
|
|
162
|
-
|
|
166
|
+
tools.extend([dynamicModel])
|
|
167
|
+
tools_dict["dynamicmodel"] = dynamicModel
|
|
163
168
|
|
|
164
169
|
chat = chat.bind_tools(tools)
|
|
165
170
|
|
|
@@ -174,9 +179,12 @@ class PromptCaller:
|
|
|
174
179
|
tool_name = tool_call["name"].lower()
|
|
175
180
|
|
|
176
181
|
# If it's the final formatting tool, validate and return
|
|
177
|
-
if tool_name == "dynamicmodel":
|
|
182
|
+
if dynamicOutput and tool_name == "dynamicmodel":
|
|
178
183
|
return dynamicModel.model_validate(tool_call["args"])
|
|
179
184
|
|
|
185
|
+
if output and tool_name == output.__name__.lower():
|
|
186
|
+
return output.model_validate(tool_call["args"])
|
|
187
|
+
|
|
180
188
|
selected_tool = tools_dict.get(tool_name)
|
|
181
189
|
if not selected_tool:
|
|
182
190
|
raise ValueError(f"Unknown tool: {tool_name}")
|
|
@@ -202,5 +210,6 @@ class PromptCaller:
|
|
|
202
210
|
return response
|
|
203
211
|
|
|
204
212
|
except Exception as e:
|
|
213
|
+
print(e)
|
|
205
214
|
# Replace with appropriate logging in production
|
|
206
215
|
raise RuntimeError("Error during agent process") from e
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: prompt_caller
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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
|
|
@@ -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=zAJq_5v-ku_O9ACAw7C7JU1RmVwlIvunbd-31B0XX6E,7119
|
|
4
|
+
prompt_caller-0.1.2.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
5
|
+
prompt_caller-0.1.2.dist-info/METADATA,sha256=IjSAGTvmJbi7X6_5f3OxvH6QA7l9H6Opx4d9wtGGRak,4909
|
|
6
|
+
prompt_caller-0.1.2.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
7
|
+
prompt_caller-0.1.2.dist-info/top_level.txt,sha256=iihiDRq-0VrKB8IKjxf7Lrtv-fLMq4tvgM4fH3x0I94,14
|
|
8
|
+
prompt_caller-0.1.2.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=fy-pLXmYD2j5fnAxgBvxCNBrkQvDPGX0nWyqnaWeqSo,6737
|
|
4
|
-
prompt_caller-0.1.1.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
5
|
-
prompt_caller-0.1.1.dist-info/METADATA,sha256=j1xmg_Y_NAhh7CmlCgAcfSMuHChZ9C4DPcszLADg7dk,4909
|
|
6
|
-
prompt_caller-0.1.1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
7
|
-
prompt_caller-0.1.1.dist-info/top_level.txt,sha256=iihiDRq-0VrKB8IKjxf7Lrtv-fLMq4tvgM4fH3x0I94,14
|
|
8
|
-
prompt_caller-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|