gemini-agent-framework 0.1.12__tar.gz → 0.1.13__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.
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/PKG-INFO +3 -3
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/README.md +2 -2
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/pyproject.toml +1 -1
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/src/gemini_agent/__init__.py +1 -1
- gemini_agent_framework-0.1.13/tests/__init__.py +3 -0
- gemini_agent_framework-0.1.13/tests/test_class_methods.py +67 -0
- gemini_agent_framework-0.1.13/tests/test_variables.py +133 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/.flake8 +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/.github/workflows/ci.yml +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/.github/workflows/docs.yml +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/.github/workflows/python-publish.yml +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/.github/workflows/tests.yml +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/.gitignore +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/CHANGELOG.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/CODE_OF_CONDUCT.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/CONTRIBUTING.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/LICENSE +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/docs/api_reference.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/docs/architecture.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/docs/best_practices.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/docs/index.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/docs/installation.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/docs/tutorials.md +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/mkdocs.yml +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/payload_variable_0.json +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/requirements.txt +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/src/gemini_agent/agent.py +0 -0
- {gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/tests/test_agent.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: gemini-agent-framework
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.13
|
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/wiki
|
@@ -118,11 +118,11 @@ response = agent.prompt(
|
|
118
118
|
|
119
119
|
## Documentation
|
120
120
|
|
121
|
-
For detailed documentation, please visit our [documentation site](https://github.com/m7mdony/gemini-agent-framework
|
121
|
+
For detailed documentation, please visit our [documentation site](https://github.com/m7mdony/gemini-agent-framework).
|
122
122
|
|
123
123
|
### Key Topics
|
124
124
|
|
125
|
-
- [API Reference](https://m7mdony.github.io/gemini-agent-framework/
|
125
|
+
- [API Reference](https://m7mdony.github.io/gemini-agent-framework/api_reference/)
|
126
126
|
- [Tutorials](https://m7mdony.github.io/gemini-agent-framework/tutorials/)
|
127
127
|
- [Best Practices](https://m7mdony.github.io/gemini-agent-framework/best_practices/)
|
128
128
|
- [Architecture Overview](https://m7mdony.github.io/gemini-agent-framework/architecture/)
|
@@ -86,11 +86,11 @@ response = agent.prompt(
|
|
86
86
|
|
87
87
|
## Documentation
|
88
88
|
|
89
|
-
For detailed documentation, please visit our [documentation site](https://github.com/m7mdony/gemini-agent-framework
|
89
|
+
For detailed documentation, please visit our [documentation site](https://github.com/m7mdony/gemini-agent-framework).
|
90
90
|
|
91
91
|
### Key Topics
|
92
92
|
|
93
|
-
- [API Reference](https://m7mdony.github.io/gemini-agent-framework/
|
93
|
+
- [API Reference](https://m7mdony.github.io/gemini-agent-framework/api_reference/)
|
94
94
|
- [Tutorials](https://m7mdony.github.io/gemini-agent-framework/tutorials/)
|
95
95
|
- [Best Practices](https://m7mdony.github.io/gemini-agent-framework/best_practices/)
|
96
96
|
- [Architecture Overview](https://m7mdony.github.io/gemini-agent-framework/architecture/)
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "gemini-agent-framework"
|
7
|
-
version = "0.1.
|
7
|
+
version = "0.1.13"
|
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,67 @@
|
|
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()
|
@@ -0,0 +1,133 @@
|
|
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>© 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>© 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))
|
File without changes
|
File without changes
|
File without changes
|
{gemini_agent_framework-0.1.12 → gemini_agent_framework-0.1.13}/.github/workflows/python-publish.yml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|