gemini-agent-framework 0.1.5__tar.gz → 0.1.6__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.5
3
+ Version: 0.1.6
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.5"
7
+ version = "0.1.6"
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.6"
4
+ __all__ = ["Agent"]
@@ -213,7 +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
+ - You don't have the ability to set new varaibles during the conversation. and if you need to use them thhen you will need to use its actual value.
217
217
  - When using stored variables, ALWAYS use the {{"variable": "variable_name"}} syntax
218
218
  """.format(
219
219
  tools_list="\n".join([f"- {name}: {desc}" for name, desc in
@@ -0,0 +1,76 @@
1
+ from gemini_agent import Agent
2
+ from dotenv import load_dotenv
3
+ import os
4
+
5
+ load_dotenv()
6
+
7
+ # Load multiple API keys
8
+ api_keys = os.getenv("GEMINI_APIs").split(",")
9
+ current_key_idx = 0
10
+
11
+ def get_current_api_key():
12
+ return api_keys[current_key_idx]
13
+
14
+ def switch_to_next_api_key():
15
+ global current_key_idx
16
+ current_key_idx = (current_key_idx + 1) % len(api_keys)
17
+ print(f"🔄 [DEBUG] Switching to API key index {current_key_idx}: {api_keys[current_key_idx][:10]}...")
18
+
19
+ # Define your tools
20
+ @Agent.description("Multiplies two numbers.")
21
+ @Agent.parameters({
22
+ 'a': {'type': int, 'description': 'The first number'},
23
+ 'b': {'type': int, 'description': 'The second number'}
24
+ })
25
+ def multiply(a: int, b: int) -> int:
26
+ return a * b
27
+
28
+ @Agent.description("Adds two numbers.")
29
+ @Agent.parameters({
30
+ 'a': {'type': int, 'description': 'The first number'},
31
+ 'b': {'type': int, 'description': 'The second number'}
32
+ })
33
+ def add(a: int, b: int) -> int:
34
+ return a + b
35
+
36
+ # Create agent with the first API key
37
+ agent = Agent(api_key=get_current_api_key(), tools=[multiply, add])
38
+
39
+ # Define a wrapper to rotate API key AFTER the call
40
+ def agent_prompt_with_key_rotation(agent,*args, **kwargs):
41
+ # global agent
42
+ print(f"🚀 [DEBUG] Using API key index {current_key_idx}: {agent.api_key[:10]}...")
43
+ response = agent.prompt(*args, **kwargs)
44
+ switch_to_next_api_key()
45
+ agent.api_key = get_current_api_key()
46
+ return response
47
+
48
+ # Use the agent
49
+ response = agent_prompt_with_key_rotation(agent,
50
+ user_prompt="multiply 3 and 7 then add 5 to the result",
51
+ system_prompt="You are a helpful assistant. Give your response always with ❤️ at the start of the line. In your response you should mention the function you used.",
52
+ response_structure={
53
+ "type": "object",
54
+ "properties": {
55
+ "used_functions": {
56
+ "type": "array",
57
+ "items": {
58
+ "type": "object",
59
+ "properties": {
60
+ "function_name": {"type": "string"},
61
+ "parameters": {
62
+ "type": "object",
63
+ "properties": {
64
+ "a": {"type": "integer"},
65
+ "b": {"type": "integer"}
66
+ }
67
+ }
68
+ }
69
+ }
70
+ },
71
+ "answer": {"type": "string"}
72
+ }
73
+ }
74
+ )
75
+
76
+ print(response)
@@ -1,4 +0,0 @@
1
- from .agent import Agent
2
-
3
- __version__ = "0.1.5"
4
- __all__ = ["Agent"]
@@ -1,66 +0,0 @@
1
- import os
2
- from dotenv import load_dotenv
3
- from framework_agent import Agent
4
-
5
- load_dotenv()
6
-
7
- def test_basic_operations():
8
- # Define some basic math operations
9
- @Agent.description("Multiplies two numbers.")
10
- @Agent.parameters({
11
- 'a': {'type': int, 'description': 'The first number'},
12
- 'b': {'type': int, 'description': 'The second number'}
13
- })
14
- def multiply(a: int, b: int) -> int:
15
- return a * b
16
-
17
- @Agent.description("Adds two numbers.")
18
- @Agent.parameters({
19
- 'a': {'type': int, 'description': 'The first number'},
20
- 'b': {'type': int, 'description': 'The second number'}
21
- })
22
- def add(a: int, b: int) -> int:
23
- return a + b
24
-
25
- # Create an agent with the math tools
26
- agent = Agent(
27
- api_key=os.getenv("GEMINI_API_KEY"),
28
- tools=[multiply, add]
29
- )
30
-
31
- # Test a simple multiplication
32
- response = agent.prompt("Multiply 3 and 7")
33
- print(f"Multiplication result: {response}") # Should be 21
34
-
35
- # Use the agent
36
- response = agent.prompt(user_prompt="multiply 3 and 7 then add 5 to the result" ,
37
- system_prompt="You are a helpful assistant give your response always with ❤️ at the start of the line. in your response you should mention the function you used." ,
38
- response_structure=
39
- {
40
- "type": "object",
41
- "properties": {
42
- "used_functions": {
43
- "type": "array",
44
- "items": {
45
- "type": "object",
46
- "properties": {
47
- "function_name": {"type": "string"},
48
- "parameters": {
49
- "type": "object",
50
- "properties": {
51
- "a": {"type": "integer"},
52
- "b": {"type": "integer"}
53
- }
54
- }
55
- }
56
- }
57
- },
58
- "answer": {"type": "string"}
59
-
60
- }
61
- }
62
- )
63
- print(response) # Should output 21
64
-
65
- if __name__ == "__main__":
66
- test_basic_operations()