gemini-agent-framework 0.2.2__tar.gz → 0.2.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.
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/PKG-INFO +1 -1
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/docs/api_reference.md +2 -7
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/docs/best_practices.md +2 -6
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/docs/tutorials.md +3 -7
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/pyproject.toml +1 -1
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/src/gemini_agent/__init__.py +1 -1
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/src/gemini_agent/agent.py +32 -93
- gemini_agent_framework-0.2.4/tests/formatting_payload_2.json +82 -0
- gemini_agent_framework-0.2.4/tests/payload_0.json +49 -0
- gemini_agent_framework-0.2.4/tests/payload_1.json +90 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/tests/test_agent.py +1 -19
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/tests/test_class_methods.py +0 -21
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/tests/test_variables.py +19 -18
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.flake8 +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.github/workflows/ci.yml +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.github/workflows/deploy-docs.yml +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.github/workflows/docs.yml +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.github/workflows/python-publish.yml +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.github/workflows/tests.yml +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.gitignore +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/CHANGELOG.md +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/CODE_OF_CONDUCT.md +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/CONTRIBUTING.md +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/LICENSE +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/README.md +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/docs/architecture.md +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/docs/index.md +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/docs/installation.md +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/mkdocs.yml +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/payload_variable_0.json +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/requirements.txt +0 -0
- {gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: gemini-agent-framework
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.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://m7mdony.github.io/gemini-agent-framework
|
@@ -120,15 +120,10 @@ The framework automatically maps Python types to Gemini JSON schema types:
|
|
120
120
|
|
121
121
|
## Response Structure
|
122
122
|
|
123
|
-
The `
|
123
|
+
The `json_format` parameter in the `prompt` method allows you to define the expected structure with in the prompt:
|
124
124
|
|
125
125
|
```python
|
126
|
-
|
127
|
-
"field_name": {
|
128
|
-
"type": "string|number|boolean|array|object",
|
129
|
-
"description": "Optional description"
|
130
|
-
}
|
131
|
-
}
|
126
|
+
Json_format = True
|
132
127
|
```
|
133
128
|
|
134
129
|
## Error Handling
|
@@ -120,14 +120,10 @@ agent.set_variable('count', 5, 'Counter')
|
|
120
120
|
|
121
121
|
### 1. Structured Responses
|
122
122
|
|
123
|
-
Define clear response structures:
|
123
|
+
Define clear response structures within the prompt then apply them:
|
124
124
|
|
125
125
|
```python
|
126
|
-
|
127
|
-
'result': {'type': 'number', 'description': 'The calculation result'},
|
128
|
-
'steps': {'type': 'array', 'description': 'List of calculation steps'},
|
129
|
-
'explanation': {'type': 'string', 'description': 'Explanation of the calculation'}
|
130
|
-
}
|
126
|
+
json_format = True
|
131
127
|
```
|
132
128
|
|
133
129
|
### 2. Error Responses
|
@@ -136,15 +136,11 @@ def safe_divide(a: float, b: float) -> float:
|
|
136
136
|
### 2. Using Response Structures
|
137
137
|
|
138
138
|
```python
|
139
|
-
|
140
|
-
'result': {'type': 'number', 'description': 'The calculation result'},
|
141
|
-
'steps': {'type': 'array', 'description': 'List of calculation steps'},
|
142
|
-
'explanation': {'type': 'string', 'description': 'Explanation of the calculation'}
|
143
|
-
}
|
139
|
+
|
144
140
|
|
145
141
|
response = agent.prompt(
|
146
|
-
"Calculate 15 * 7 and show your work",
|
147
|
-
|
142
|
+
"""Calculate 15 * 7 and show your work respond with {"answer": number}""",
|
143
|
+
json_format=True
|
148
144
|
)
|
149
145
|
```
|
150
146
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "gemini-agent-framework"
|
7
|
-
version = "0.2.
|
7
|
+
version = "0.2.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"
|
@@ -314,7 +314,6 @@ class Agent:
|
|
314
314
|
|
315
315
|
def _log_json(self, json_data: Dict[str, Any], file_name: str, debug_scope: Optional[str] = None) -> None:
|
316
316
|
"""Logs the JSON data to a file."""
|
317
|
-
print("in log json")
|
318
317
|
if "json" not in debug_scope:
|
319
318
|
return
|
320
319
|
with open(file_name, "w") as f:
|
@@ -329,7 +328,7 @@ class Agent:
|
|
329
328
|
self,
|
330
329
|
user_prompt: str,
|
331
330
|
system_prompt: Optional[str] = None,
|
332
|
-
|
331
|
+
json_format: bool = False,
|
333
332
|
conversation_history: Optional[List[Dict[str, Any]]] = None,
|
334
333
|
debug_scope: Optional[str] = [],
|
335
334
|
) -> Any:
|
@@ -339,15 +338,14 @@ class Agent:
|
|
339
338
|
Args:
|
340
339
|
user_prompt: The user's input prompt
|
341
340
|
system_prompt: Optional system prompt to override the default
|
342
|
-
|
341
|
+
json_format: If True, response will be formatted as JSON. Default is False (plain text)
|
343
342
|
conversation_history: Optional list of previous conversation turns
|
344
343
|
|
345
344
|
Returns:
|
346
|
-
The model's response,
|
345
|
+
The model's response, formatted as JSON if json_format is True, otherwise plain text
|
347
346
|
"""
|
348
347
|
self._intermediate_results = {}
|
349
348
|
|
350
|
-
|
351
349
|
current_contents = conversation_history if conversation_history else []
|
352
350
|
|
353
351
|
# Add system instruction to payload
|
@@ -365,30 +363,15 @@ class Agent:
|
|
365
363
|
payload["tools"] = [{"functionDeclarations": self._registered_tools_json}]
|
366
364
|
payload["toolConfig"] = {"functionCallingConfig": {"mode": "AUTO"}}
|
367
365
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
if response_structure and not self._registered_tools_json:
|
373
|
-
apply_structure_later = False
|
374
|
-
# If response_structure is a string type, make it more flexible
|
375
|
-
if response_structure.get("type") == "string":
|
376
|
-
response_structure = {
|
377
|
-
"type": ["string", "object"],
|
378
|
-
"properties": {"value": {"type": "string"}},
|
379
|
-
}
|
380
|
-
payload["generationConfig"] = {
|
381
|
-
"response_mime_type": "application/json",
|
382
|
-
"response_schema": response_structure,
|
383
|
-
}
|
384
|
-
final_mime_type = "application/json"
|
385
|
-
final_response_schema = response_structure
|
366
|
+
# Don't set JSON formatting initially if tools are available
|
367
|
+
# We'll apply it later after tool calls are completed
|
368
|
+
apply_json_format_later = json_format and bool(self._registered_tools_json)
|
369
|
+
|
386
370
|
count = 0
|
387
371
|
while True:
|
388
372
|
self._log_json(payload, f"payload_{count}.json", debug_scope)
|
389
373
|
count += 1
|
390
374
|
response_data = self._call_gemini_api(payload, debug_scope)
|
391
|
-
print("response data " , response_data)
|
392
375
|
if "error" in response_data:
|
393
376
|
self._log_text(
|
394
377
|
f"API call failed: {response_data['error'].get('message', 'Unknown API error')}"
|
@@ -412,8 +395,6 @@ class Agent:
|
|
412
395
|
content = candidate["content"]
|
413
396
|
|
414
397
|
for part in content["parts"]:
|
415
|
-
|
416
|
-
|
417
398
|
if "functionCall" in part:
|
418
399
|
payload["contents"].append({"role": "model", "parts": [part]})
|
419
400
|
fc = part["functionCall"]
|
@@ -502,41 +483,32 @@ class Agent:
|
|
502
483
|
elif "text" in part:
|
503
484
|
final_text = part["text"]
|
504
485
|
|
505
|
-
if
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
self._log_text(
|
515
|
-
f"Warning: Failed to parse initially structured output: {e}. Continuing with raw text.",
|
516
|
-
debug_scope
|
517
|
-
)
|
518
|
-
|
519
|
-
elif apply_structure_later:
|
520
|
-
if not any(
|
521
|
-
"functionCall" in p
|
522
|
-
for p in content["parts"][content["parts"].index(part) + 1 :]
|
523
|
-
):
|
524
|
-
self._log_text("--- Attempting final structuring call ---", debug_scope)
|
525
|
-
# Include the full conversation history in the formatting payload
|
486
|
+
# Check if there are more function calls coming
|
487
|
+
has_more_function_calls = any(
|
488
|
+
"functionCall" in p
|
489
|
+
for p in content["parts"][content["parts"].index(part) + 1 :]
|
490
|
+
)
|
491
|
+
|
492
|
+
if not has_more_function_calls:
|
493
|
+
# If JSON format is requested and we have tools, make a final formatting call
|
494
|
+
if apply_json_format_later:
|
495
|
+
self._log_text("--- Making final JSON formatting call ---", debug_scope)
|
526
496
|
formatting_payload = {
|
497
|
+
"system_instruction": {
|
498
|
+
"parts": [{"text": system_prompt if system_prompt else ""},{"text": self._get_system_prompt()}]
|
499
|
+
},
|
527
500
|
"contents": payload["contents"] + [
|
528
501
|
{
|
529
502
|
"role": "user",
|
530
503
|
"parts": [
|
531
504
|
{
|
532
|
-
"text": f"Based on our conversation above, please format
|
505
|
+
"text": f"Based on our conversation above, please format your response as JSON. Here is the current response: {final_text}"
|
533
506
|
}
|
534
507
|
],
|
535
508
|
}
|
536
509
|
],
|
537
510
|
"generationConfig": {
|
538
|
-
"response_mime_type": "application/json"
|
539
|
-
"response_schema": response_structure,
|
511
|
+
"response_mime_type": "application/json"
|
540
512
|
},
|
541
513
|
}
|
542
514
|
self._log_json(formatting_payload, f"formatting_payload_{count}.json", debug_scope)
|
@@ -545,7 +517,7 @@ class Agent:
|
|
545
517
|
|
546
518
|
if "error" in structured_response_data:
|
547
519
|
self._log_text(
|
548
|
-
f"
|
520
|
+
f"JSON formatting call failed: {structured_response_data['error']}. Returning raw text.",
|
549
521
|
debug_scope
|
550
522
|
)
|
551
523
|
return final_text
|
@@ -558,57 +530,24 @@ class Agent:
|
|
558
530
|
return structured_output
|
559
531
|
except (KeyError, IndexError, json.JSONDecodeError) as e:
|
560
532
|
self._log_text(
|
561
|
-
f"Warning: Failed to parse
|
533
|
+
f"Warning: Failed to parse JSON response after formatting call: {e}. Returning raw text.",
|
562
534
|
debug_scope
|
563
535
|
)
|
564
536
|
return final_text
|
565
|
-
|
566
|
-
|
567
|
-
"functionCall" in p
|
568
|
-
for p in content["parts"][content["parts"].index(part) + 1 :]
|
569
|
-
):
|
570
|
-
if response_structure and not apply_structure_later:
|
571
|
-
self._log_text("--- Attempting final structuring call ---", debug_scope)
|
572
|
-
formatting_payload = {
|
573
|
-
"contents": [
|
574
|
-
{
|
575
|
-
"role": "user",
|
576
|
-
"parts": [
|
577
|
-
{
|
578
|
-
"text": f"Please format the following information according to the requested JSON structure:\n\n{final_text}"
|
579
|
-
}
|
580
|
-
],
|
581
|
-
}
|
582
|
-
],
|
583
|
-
"generationConfig": {
|
584
|
-
"response_mime_type": "application/json",
|
585
|
-
"response_schema": response_structure,
|
586
|
-
},
|
587
|
-
}
|
588
|
-
self._log_json(formatting_payload, f"formatting_payload_{count}.json", debug_scope)
|
589
|
-
count += 1
|
590
|
-
structured_response_data = self._call_gemini_api(formatting_payload, debug_scope)
|
591
|
-
|
592
|
-
if "error" in structured_response_data:
|
593
|
-
self._log_text(
|
594
|
-
f"Structuring call failed: {structured_response_data['error']}. Returning intermediate text."
|
595
|
-
, debug_scope
|
596
|
-
)
|
597
|
-
return final_text
|
598
|
-
|
537
|
+
elif json_format:
|
538
|
+
# Direct JSON formatting (no tools involved)
|
599
539
|
try:
|
600
|
-
|
601
|
-
"content"
|
602
|
-
]["parts"][0]["text"]
|
603
|
-
structured_output = json.loads(structured_text)
|
540
|
+
structured_output = json.loads(final_text)
|
604
541
|
return structured_output
|
605
|
-
except
|
542
|
+
except json.JSONDecodeError as e:
|
606
543
|
self._log_text(
|
607
|
-
f"Warning: Failed to parse
|
544
|
+
f"Warning: Failed to parse JSON response: {e}. Returning raw text.",
|
608
545
|
debug_scope
|
609
546
|
)
|
610
547
|
return final_text
|
611
|
-
|
548
|
+
else:
|
549
|
+
# Return plain text response
|
550
|
+
return final_text
|
612
551
|
continue
|
613
552
|
|
614
553
|
except (KeyError, IndexError) as e:
|
@@ -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
|
+
}
|
@@ -64,25 +64,7 @@ response = agent_prompt_with_key_rotation(
|
|
64
64
|
agent,
|
65
65
|
user_prompt="multiply 3 and 7 then add 5 to the result",
|
66
66
|
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.",
|
67
|
-
|
68
|
-
"type": "object",
|
69
|
-
"properties": {
|
70
|
-
"used_functions": {
|
71
|
-
"type": "array",
|
72
|
-
"items": {
|
73
|
-
"type": "object",
|
74
|
-
"properties": {
|
75
|
-
"function_name": {"type": "string"},
|
76
|
-
"parameters": {
|
77
|
-
"type": "object",
|
78
|
-
"properties": {"a": {"type": "integer"}, "b": {"type": "integer"}},
|
79
|
-
},
|
80
|
-
},
|
81
|
-
},
|
82
|
-
},
|
83
|
-
"answer": {"type": "string"},
|
84
|
-
},
|
85
|
-
},
|
67
|
+
|
86
68
|
)
|
87
69
|
|
88
70
|
print(response)
|
@@ -39,27 +39,6 @@ def test_class_methods():
|
|
39
39
|
# Test using class methods
|
40
40
|
response = agent.prompt(
|
41
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
42
|
)
|
64
43
|
print(response)
|
65
44
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from
|
1
|
+
from gemini_agent import Agent
|
2
2
|
import os
|
3
3
|
from dotenv import load_dotenv
|
4
4
|
import json
|
@@ -105,15 +105,16 @@ 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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
}
|
115
|
-
|
116
|
-
|
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
|
+
make the response in this format
|
112
|
+
{
|
113
|
+
"count": number,
|
114
|
+
"input_types": [input1,input2 ..... ] }
|
115
|
+
|
116
|
+
""",
|
117
|
+
json_format= True
|
117
118
|
)
|
118
119
|
print(json.dumps(response, indent=2))
|
119
120
|
|
@@ -121,13 +122,13 @@ print(json.dumps(response, indent=2))
|
|
121
122
|
print("\nExample 2: Count inputs in login page")
|
122
123
|
response = agent.prompt(
|
123
124
|
"How many input tags are in this page "+ login_page,
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
"
|
131
|
-
|
125
|
+
system_prompt="""
|
126
|
+
make the response in this format
|
127
|
+
{
|
128
|
+
"count": number,
|
129
|
+
"input_types": [input1,input2 ..... ] }
|
130
|
+
|
131
|
+
""",
|
132
|
+
json_format= True
|
132
133
|
)
|
133
134
|
print(json.dumps(response, indent=2))
|
File without changes
|
File without changes
|
{gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.github/workflows/deploy-docs.yml
RENAMED
File without changes
|
File without changes
|
{gemini_agent_framework-0.2.2 → gemini_agent_framework-0.2.4}/.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
|