gemini-agent-framework 0.1.3__tar.gz → 0.1.4__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.3
3
+ Version: 0.1.4
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.3"
7
+ version = "0.1.4"
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.4"
4
+ __all__ = ["Agent"]
@@ -213,6 +213,7 @@ class Agent:
213
213
  - If a step requires multiple tools, execute them sequentially
214
214
  - If you're unsure about the next step, explain your reasoning
215
215
  - 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
216
217
  - When using stored variables, ALWAYS use the {{"variable": "variable_name"}} syntax
217
218
  """.format(
218
219
  tools_list="\n".join([f"- {name}: {desc}" for name, desc in
@@ -323,6 +324,7 @@ class Agent:
323
324
  final_response_schema = response_structure
324
325
 
325
326
  while True:
327
+
326
328
  response_data = self._call_gemini_api(payload)
327
329
  if "error" in response_data:
328
330
  print(f"API call failed: {response_data['error'].get('message', 'Unknown API error')}")
@@ -468,8 +470,8 @@ class Agent:
468
470
  print(f"Warning: Failed to parse structured output after formatting call: {e}. Returning intermediate text.")
469
471
  return final_text
470
472
  return final_text
471
-
472
473
  continue
474
+
473
475
 
474
476
  except (KeyError, IndexError) as e:
475
477
  print(f"Error parsing API response structure: {e}. Response: {response_data}")
@@ -1,4 +0,0 @@
1
- from .agent import Agent
2
-
3
- __version__ = "0.1.1"
4
- __all__ = ["Agent"]
@@ -1,3 +0,0 @@
1
- """
2
- Test package for the Gemini Agent Framework.
3
- """
@@ -1,67 +0,0 @@
1
- import os
2
- from dotenv import load_dotenv
3
- from gemini_agent import Agent
4
-
5
- load_dotenv()
6
-
7
- class Calculator:
8
- def __init__(self):
9
- self.memory = 0
10
-
11
- @Agent.description("Multiplies a number by the stored memory value.")
12
- @Agent.parameters({
13
- 'number': {'type': int, 'description': 'The number to multiply with memory'}
14
- })
15
- def multiply_with_memory(self, number: int) -> int:
16
- result = self.memory * number
17
- self.memory = result
18
- return result
19
-
20
- @Agent.description("Adds a number to the stored memory value.")
21
- @Agent.parameters({
22
- 'number': {'type': int, 'description': 'The number to add to memory'}
23
- })
24
- def add_to_memory(self, number: int) -> int:
25
- result = self.memory + number
26
- self.memory = result
27
- return result
28
-
29
- def test_class_methods():
30
- # Create a calculator instance
31
- calculator = Calculator()
32
-
33
- # Create an agent with the calculator methods
34
- agent = Agent(
35
- api_key=os.getenv("GEMINI_API_KEY"),
36
- tools=[calculator.multiply_with_memory, calculator.add_to_memory]
37
- )
38
-
39
- # Test using class methods
40
- response = agent.prompt(
41
- "Multiply 5 with memory (starting at 0), then add 10 to the result",
42
- response_structure={
43
- "type": "object",
44
- "properties": {
45
- "used_functions": {
46
- "type": "array",
47
- "items": {
48
- "type": "object",
49
- "properties": {
50
- "function_name": {"type": "string"},
51
- "parameters": {
52
- "type": "object",
53
- "properties": {
54
- "number": {"type": "integer"}
55
- }
56
- }
57
- }
58
- }
59
- },
60
- "answer": {"type": "string"}
61
- }
62
- }
63
- )
64
- print(response)
65
-
66
- if __name__ == "__main__":
67
- test_class_methods()
@@ -1,133 +0,0 @@
1
- from agent import Agent
2
- import os
3
- from dotenv import load_dotenv
4
- import json
5
- from bs4 import BeautifulSoup
6
-
7
- load_dotenv()
8
-
9
- class HTMLAnalyzer:
10
- @Agent.description("Count the number of input tags in an HTML page")
11
- @Agent.parameters({
12
- 'html_content': {'type': str, 'description': 'The HTML content to analyze'}
13
- })
14
- def count_inputs(self, html_content: str) -> dict:
15
- soup = BeautifulSoup(html_content, 'html.parser')
16
- input_tags = soup.find_all('input')
17
- return {
18
- "count": len(input_tags),
19
- "input_types": [tag.get('type', 'unknown') for tag in input_tags]
20
- }
21
-
22
- # Create HTML pages
23
- home_page = """
24
- <!DOCTYPE html>
25
- <html>
26
- <head>
27
- <title>Home Page</title>
28
- </head>
29
- <body>
30
- <header>
31
- <nav>
32
- <a href="/">Home</a>
33
- <a href="/about">About</a>
34
- <a href="/contact">Contact</a>
35
- </nav>
36
- </header>
37
- <main>
38
- <h1>Welcome to Our Website</h1>
39
- <p>This is a simple home page with no input fields.</p>
40
- </main>
41
- <footer>
42
- <p>&copy; 2024 Our Website</p>
43
- </footer>
44
- </body>
45
- </html>
46
- """
47
-
48
- login_page = """
49
- <!DOCTYPE html>
50
- <html>
51
- <head>
52
- <title>Login Page</title>
53
- </head>
54
- <body>
55
- <header>
56
- <nav>
57
- <a href="/">Home</a>
58
- <a href="/login">Login</a>
59
- </nav>
60
- </header>
61
- <main>
62
- <h1>Login</h1>
63
- <form action="/login" method="POST">
64
- <div>
65
- <label for="username">Username:</label>
66
- <input type="text" id="username" name="username" required>
67
- </div>
68
- <div>
69
- <label for="password">Password:</label>
70
- <input type="password" id="password" name="password" required>
71
- </div>
72
- <div>
73
- <input type="checkbox" id="remember" name="remember">
74
- <label for="remember">Remember me</label>
75
- </div>
76
- <button type="submit">Login</button>
77
- </form>
78
- </main>
79
- <footer>
80
- <p>&copy; 2024 Our Website</p>
81
- </footer>
82
- </body>
83
- </html>
84
- """
85
-
86
- # Create the analyzer instance
87
- html_analyzer = HTMLAnalyzer()
88
-
89
- # Create the agent with our tool
90
- agent = Agent(
91
- api_key=os.getenv("GEMINI_API_KEY"),
92
- tools=[html_analyzer.count_inputs]
93
- )
94
-
95
- # Store the HTML pages as variables
96
- agent.set_variable(
97
- name="home_page",
98
- value=home_page,
99
- description="The HTML content of the home page",
100
- type_hint=str
101
- )
102
-
103
-
104
-
105
- # Example 1: Count inputs in home page
106
- print("\nExample 1: Count inputs in home page")
107
- response = agent.prompt(
108
- "How many input tags are in the home page?",
109
- response_structure={
110
- "type": "object",
111
- "properties": {
112
- "count": {"type": "integer"},
113
- "input_types": {"type": "array", "items": {"type": "string"}}
114
- },
115
- "required": ["count", "input_types"]
116
- }
117
- )
118
- print(json.dumps(response, indent=2))
119
-
120
- # Example 2: Count inputs in login page
121
- print("\nExample 2: Count inputs in login page")
122
- response = agent.prompt(
123
- "How many input tags are in this page "+ login_page,
124
- response_structure={
125
- "type": "object",
126
- "properties": {
127
- "count": {"type": "integer"},
128
- "input_types": {"type": "array", "items": {"type": "string"}}
129
- },
130
- "required": ["count", "input_types"]
131
- }
132
- )
133
- print(json.dumps(response, indent=2))