gemini-agent-framework 0.1.8__tar.gz → 0.1.10__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.4
2
2
  Name: gemini-agent-framework
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: A framework for building agents that use Gemini's function calling capabilities
5
5
  Project-URL: Homepage, https://github.com/m7mdony/gemini-agent-framework
6
6
  Project-URL: Documentation, https://github.com/m7mdony/gemini-agent-framework#readme
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "gemini-agent-framework"
7
- version = "0.1.8"
7
+ version = "0.1.10"
8
8
  description = "A framework for building agents that use Gemini's function calling capabilities"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -0,0 +1,4 @@
1
+ from .agent import Agent
2
+
3
+ __version__ = "0.1.10"
4
+ __all__ = ["Agent"]
@@ -143,6 +143,7 @@ class Agent:
143
143
  def set_variable(self, name: str, value: Any, description: str = "", type_hint: type = None) -> None:
144
144
  """
145
145
  Stores a variable in the agent's memory with metadata.
146
+ If a variable with the same name exists, creates a new variable with a counter suffix.
146
147
 
147
148
  Args:
148
149
  name: The name of the variable
@@ -150,6 +151,29 @@ class Agent:
150
151
  description: A description of what the variable represents
151
152
  type_hint: Optional type hint for the variable
152
153
  """
154
+ # Check if the base name exists
155
+ if name in self._stored_variables:
156
+ # Find all variables that start with the base name
157
+ existing_vars = [var_name for var_name in self._stored_variables.keys()
158
+ if var_name.startswith(name + '_') or var_name == name]
159
+
160
+ # Find the highest counter used
161
+ max_counter = 0
162
+ for var_name in existing_vars:
163
+ if var_name == name:
164
+ max_counter = max(max_counter, 1)
165
+ else:
166
+ try:
167
+ counter = int(var_name.split('_')[-1])
168
+ max_counter = max(max_counter, counter)
169
+ except ValueError:
170
+ continue
171
+
172
+ # Create new name with incremented counter
173
+ new_name = f"{name}_{max_counter + 1}"
174
+ print(f"Variable '{name}' already exists. Creating new variable '{new_name}'")
175
+ name = new_name
176
+
153
177
  self._stored_variables[name] = {
154
178
  'value': value,
155
179
  'description': description,
@@ -157,6 +181,8 @@ class Agent:
157
181
  'created_at': datetime.now().isoformat()
158
182
  }
159
183
 
184
+ return name
185
+
160
186
  def get_variable(self, name: str) -> Any:
161
187
  """
162
188
  Retrieves a stored variable's value.
@@ -213,7 +239,6 @@ class Agent:
213
239
  - If a step requires multiple tools, execute them sequentially
214
240
  - If you're unsure about the next step, explain your reasoning
215
241
  - You can use both stored variables and values from the prompt
216
- - You don't have the ability to set new varaibles during the conversation.
217
242
  - When using stored variables, ALWAYS use the {{"variable": "variable_name"}} syntax
218
243
  """.format(
219
244
  tools_list="\n".join([f"- {name}: {desc}" for name, desc in
@@ -385,15 +410,21 @@ class Agent:
385
410
 
386
411
  result_key = f"result_{len(self._intermediate_results)}"
387
412
  self._intermediate_results[result_key] = function_result
388
-
413
+
414
+ varaible_name = self.set_variable(result_key, function_result, "the result of function call with name {tool_name} and arguments {args}")
389
415
  function_response_part = {
390
416
  "functionResponse": {
391
417
  "name": tool_name,
392
418
  "response": {
393
419
  "content": function_result,
420
+ "key": varaible_name,
421
+ "content_type": type(function_result).__name__
394
422
  }
395
423
  }
396
424
  }
425
+
426
+ payload["contents"].append({"role": "user", "parts": [{"text": f"the return value of the function stored in the variable {varaible_name}"}]})
427
+
397
428
  payload["contents"].append({"role": "user", "parts": [function_response_part]})
398
429
 
399
430
  except Exception as e:
@@ -1,4 +0,0 @@
1
- from .agent import Agent
2
-
3
- __version__ = "0.1.8"
4
- __all__ = ["Agent"]