gemini-agent-framework 0.2.1__tar.gz → 0.2.3__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.
Files changed (32) hide show
  1. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/PKG-INFO +1 -1
  2. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/pyproject.toml +1 -1
  3. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/src/gemini_agent/__init__.py +1 -1
  4. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/src/gemini_agent/agent.py +0 -8
  5. gemini_agent_framework-0.2.3/tests/formatting_payload_2.json +82 -0
  6. gemini_agent_framework-0.2.3/tests/payload_0.json +49 -0
  7. gemini_agent_framework-0.2.3/tests/payload_1.json +90 -0
  8. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/tests/test_variables.py +5 -2
  9. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/.flake8 +0 -0
  10. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/.github/workflows/ci.yml +0 -0
  11. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/.github/workflows/deploy-docs.yml +0 -0
  12. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/.github/workflows/docs.yml +0 -0
  13. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/.github/workflows/python-publish.yml +0 -0
  14. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/.github/workflows/tests.yml +0 -0
  15. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/.gitignore +0 -0
  16. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/CHANGELOG.md +0 -0
  17. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/CODE_OF_CONDUCT.md +0 -0
  18. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/CONTRIBUTING.md +0 -0
  19. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/LICENSE +0 -0
  20. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/README.md +0 -0
  21. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/docs/api_reference.md +0 -0
  22. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/docs/architecture.md +0 -0
  23. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/docs/best_practices.md +0 -0
  24. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/docs/index.md +0 -0
  25. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/docs/installation.md +0 -0
  26. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/docs/tutorials.md +0 -0
  27. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/mkdocs.yml +0 -0
  28. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/payload_variable_0.json +0 -0
  29. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/requirements.txt +0 -0
  30. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/tests/__init__.py +0 -0
  31. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/tests/test_agent.py +0 -0
  32. {gemini_agent_framework-0.2.1 → gemini_agent_framework-0.2.3}/tests/test_class_methods.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gemini-agent-framework
3
- Version: 0.2.1
3
+ Version: 0.2.3
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://m7mdony.github.io/gemini-agent-framework
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "gemini-agent-framework"
7
- version = "0.2.1"
7
+ version = "0.2.3"
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"
@@ -1,4 +1,4 @@
1
1
  from .agent import Agent
2
2
 
3
- __version__ = "0.2.1"
3
+ __version__ = "0.2.3"
4
4
  __all__ = ["Agent"]
@@ -274,26 +274,20 @@ class Agent:
274
274
  """Substitutes variable references in arguments with their actual values."""
275
275
  result = {}
276
276
  for key, value in args.items():
277
- print("substituting variables", key, value)
278
277
  if isinstance(value, str) and value.startswith("$"):
279
- print("is string and starts with $")
280
278
  # Handle $ prefixed variables
281
279
  var_name = value[1:]
282
280
  if var_name in self._stored_variables:
283
- print("substituted")
284
281
 
285
282
  result[key] = self._stored_variables[var_name]["value"]
286
283
  else:
287
284
  result[key] = value
288
285
  elif isinstance(value, dict) and "variable" in value:
289
- print("is dict and has variable")
290
286
  # Handle dictionary-style variable references
291
287
  var_name = value["variable"]
292
288
  if var_name in self._stored_variables:
293
- print("substituted")
294
289
  result[key] = self._stored_variables[var_name]["value"]
295
290
  else:
296
- print("substituted")
297
291
  result[key] = value
298
292
  else:
299
293
  result[key] = value
@@ -320,7 +314,6 @@ class Agent:
320
314
 
321
315
  def _log_json(self, json_data: Dict[str, Any], file_name: str, debug_scope: Optional[str] = None) -> None:
322
316
  """Logs the JSON data to a file."""
323
- print("in log json")
324
317
  if "json" not in debug_scope:
325
318
  return
326
319
  with open(file_name, "w") as f:
@@ -394,7 +387,6 @@ class Agent:
394
387
  self._log_json(payload, f"payload_{count}.json", debug_scope)
395
388
  count += 1
396
389
  response_data = self._call_gemini_api(payload, debug_scope)
397
- print("response data " , response_data)
398
390
  if "error" in response_data:
399
391
  self._log_text(
400
392
  f"API call failed: {response_data['error'].get('message', 'Unknown API error')}"
@@ -0,0 +1,82 @@
1
+ {
2
+ "contents": [
3
+ {
4
+ "role": "user",
5
+ "parts": [
6
+ {
7
+ "text": "How many input tags are in the home page?"
8
+ }
9
+ ]
10
+ },
11
+ {
12
+ "role": "model",
13
+ "parts": [
14
+ {
15
+ "functionCall": {
16
+ "name": "count_inputs",
17
+ "args": {
18
+ "html_content": {
19
+ "variable": "home_page"
20
+ }
21
+ }
22
+ }
23
+ }
24
+ ]
25
+ },
26
+ {
27
+ "role": "user",
28
+ "parts": [
29
+ {
30
+ "text": "the return value of the function stored in the variable result_0"
31
+ }
32
+ ]
33
+ },
34
+ {
35
+ "role": "user",
36
+ "parts": [
37
+ {
38
+ "functionResponse": {
39
+ "name": "count_inputs",
40
+ "response": {
41
+ "content": {
42
+ "count": 0,
43
+ "input_types": []
44
+ },
45
+ "key": "result_0",
46
+ "content_type": "dict"
47
+ }
48
+ }
49
+ }
50
+ ]
51
+ },
52
+ {
53
+ "role": "user",
54
+ "parts": [
55
+ {
56
+ "text": "Based on our conversation above, please format the following information according to the requested JSON structure:\n\nThere are 0 input tags in the home page."
57
+ }
58
+ ]
59
+ }
60
+ ],
61
+ "generationConfig": {
62
+ "response_mime_type": "application/json",
63
+ "response_schema": {
64
+ "type": "object",
65
+ "properties": {
66
+ "count": {
67
+ "type": "integer"
68
+ },
69
+ "input_types": {
70
+ "type": "array",
71
+ "items": {
72
+ "type": "string"
73
+ }
74
+ }
75
+ },
76
+ "required": [
77
+ "count",
78
+ "input_types"
79
+ ]
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "system_instruction": {
3
+ "parts": [
4
+ {
5
+ "text": "You are a tool that counts the number of input tags in an HTML page."
6
+ },
7
+ {
8
+ "text": "\n\n Available variables:\n - home_page: The HTML content of the home page (Type: <class 'str'>)\n \n IMPORTANT - Variable Usage:\n When you need to use a stored variable in a function call, you MUST use the following syntax:\n - For function arguments: {\"variable\": \"variable_name\"}\n - For example, if you want to use the 'current_user' variable in a function call:\n {\"user_id\": {\"variable\": \"current_user\"}}\n \n Remember:\n - Always perform one operation at a time\n - Use intermediate results from previous steps\n - If a step requires multiple tools, execute them sequentially\n - If you're unsure about the next step, explain your reasoning\n - You can use both stored variables and values from the prompt\n - When using stored variables, ALWAYS use the {\"variable\": \"variable_name\"} syntax\n "
9
+ }
10
+ ]
11
+ },
12
+ "contents": [
13
+ {
14
+ "role": "user",
15
+ "parts": [
16
+ {
17
+ "text": "How many input tags are in the home page?"
18
+ }
19
+ ]
20
+ }
21
+ ],
22
+ "tools": [
23
+ {
24
+ "functionDeclarations": [
25
+ {
26
+ "name": "count_inputs",
27
+ "description": "Count the number of input tags in an HTML page",
28
+ "parameters": {
29
+ "type": "OBJECT",
30
+ "properties": {
31
+ "html_content": {
32
+ "type": "STRING",
33
+ "description": "The HTML content to analyze"
34
+ }
35
+ },
36
+ "required": [
37
+ "html_content"
38
+ ]
39
+ }
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "toolConfig": {
45
+ "functionCallingConfig": {
46
+ "mode": "AUTO"
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,90 @@
1
+ {
2
+ "system_instruction": {
3
+ "parts": [
4
+ {
5
+ "text": "You are a tool that counts the number of input tags in an HTML page."
6
+ },
7
+ {
8
+ "text": "\n\n Available variables:\n - home_page: The HTML content of the home page (Type: <class 'str'>)\n \n IMPORTANT - Variable Usage:\n When you need to use a stored variable in a function call, you MUST use the following syntax:\n - For function arguments: {\"variable\": \"variable_name\"}\n - For example, if you want to use the 'current_user' variable in a function call:\n {\"user_id\": {\"variable\": \"current_user\"}}\n \n Remember:\n - Always perform one operation at a time\n - Use intermediate results from previous steps\n - If a step requires multiple tools, execute them sequentially\n - If you're unsure about the next step, explain your reasoning\n - You can use both stored variables and values from the prompt\n - When using stored variables, ALWAYS use the {\"variable\": \"variable_name\"} syntax\n "
9
+ }
10
+ ]
11
+ },
12
+ "contents": [
13
+ {
14
+ "role": "user",
15
+ "parts": [
16
+ {
17
+ "text": "How many input tags are in the home page?"
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "role": "model",
23
+ "parts": [
24
+ {
25
+ "functionCall": {
26
+ "name": "count_inputs",
27
+ "args": {
28
+ "html_content": {
29
+ "variable": "home_page"
30
+ }
31
+ }
32
+ }
33
+ }
34
+ ]
35
+ },
36
+ {
37
+ "role": "user",
38
+ "parts": [
39
+ {
40
+ "text": "the return value of the function stored in the variable result_0"
41
+ }
42
+ ]
43
+ },
44
+ {
45
+ "role": "user",
46
+ "parts": [
47
+ {
48
+ "functionResponse": {
49
+ "name": "count_inputs",
50
+ "response": {
51
+ "content": {
52
+ "count": 0,
53
+ "input_types": []
54
+ },
55
+ "key": "result_0",
56
+ "content_type": "dict"
57
+ }
58
+ }
59
+ }
60
+ ]
61
+ }
62
+ ],
63
+ "tools": [
64
+ {
65
+ "functionDeclarations": [
66
+ {
67
+ "name": "count_inputs",
68
+ "description": "Count the number of input tags in an HTML page",
69
+ "parameters": {
70
+ "type": "OBJECT",
71
+ "properties": {
72
+ "html_content": {
73
+ "type": "STRING",
74
+ "description": "The HTML content to analyze"
75
+ }
76
+ },
77
+ "required": [
78
+ "html_content"
79
+ ]
80
+ }
81
+ }
82
+ ]
83
+ }
84
+ ],
85
+ "toolConfig": {
86
+ "functionCallingConfig": {
87
+ "mode": "AUTO"
88
+ }
89
+ }
90
+ }
@@ -1,4 +1,4 @@
1
- from agent import Agent
1
+ from gemini_agent import Agent
2
2
  import os
3
3
  from dotenv import load_dotenv
4
4
  import json
@@ -105,7 +105,10 @@ agent.set_variable(
105
105
  # Example 1: Count inputs in home page
106
106
  print("\nExample 1: Count inputs in home page")
107
107
  response = agent.prompt(
108
- "How many input tags are in the home page?",
108
+
109
+ user_prompt="How many input tags are in the home page?",
110
+ system_prompt="You are a tool that counts the number of input tags in an HTML page.",
111
+ debug_scope=["json"],
109
112
  response_structure={
110
113
  "type": "object",
111
114
  "properties": {