prompt-caller 0.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prompt_caller
3
- Version: 0.1.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
@@ -129,14 +129,16 @@ class PromptCaller:
129
129
 
130
130
  return response
131
131
 
132
- def agent(self, promptName, context=None, tools=None, allowed_steps=3):
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
- output = None
138
+ dynamicOutput = None
137
139
 
138
- if "output" in configuration:
139
- output = configuration.get("output")
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
- tools.extend([dynamicModel])
162
- tools_dict["dynamicmodel"] = dynamicModel
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.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
@@ -35,7 +35,7 @@ class BdistWheelCommand(bdist_wheel):
35
35
 
36
36
  setuptools.setup(
37
37
  name="prompt_caller",
38
- version="0.1.1",
38
+ version="0.1.2",
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",
File without changes
File without changes
File without changes