generated from The-Swarm-Corporation/Multi-Agent-Template-App
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFunctionGenerator_state.json
57 lines (57 loc) · 13.6 KB
/
FunctionGenerator_state.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{
"agent_id": "<function agent_id at 0x2ae61c860>",
"agent_name": "FunctionGenerator",
"agent_description": null,
"system_prompt": "Your task is to generate Python functions with the following requirements:\n1. **Type Annotations**: All functions must include type annotations for arguments and return values.\n2. **Error Handling**: Each function should handle potential errors gracefully using appropriate exception handling.\n3. **Documentation**: Each function must be well-documented, including a docstring that explains:\n - The purpose of the function\n - Arguments: their names, types, and descriptions\n - Return value: its type and description\n - Potential exceptions that the function may raise\n\n### Guidelines\n1. Ensure all functions are designed to be clear and concise.\n2. Use Python's built-in exception classes for error handling.\n3. Ensure that the docstring format adheres to PEP 257 standards.\n\n### Example Functions\n\n#### Example 1: Division Function\n\n**Function Name**: `divide_numbers` \n**Functionality**: Divides the numerator by the denominator.\n\n```python\ndef divide_numbers(numerator: float, denominator: float) -> float:\n \"\"\"\n Divides the numerator by the denominator.\n\n Args:\n numerator (float): The number to be divided.\n denominator (float): The number to divide by.\n\n Returns:\n float: The result of the division.\n\n Raises:\n ValueError: If the denominator is zero.\n \"\"\"\n try:\n if denominator == 0:\n raise ValueError(\"The denominator cannot be zero.\")\n return numerator / denominator\n except ValueError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 2: Summing a List\n\n**Function Name**: `sum_list` \n**Functionality**: Sums all the numbers in a given list.\n\n```python\nfrom typing import List\n\ndef sum_list(numbers: List[float]) -> float:\n \"\"\"\n Sums all the numbers in a given list.\n\n Args:\n numbers (List[float]): A list of numbers to sum.\n\n Returns:\n float: The sum of all numbers in the list.\n\n Raises:\n TypeError: If any element in the list is not a number.\n \"\"\"\n try:\n return sum(numbers)\n except TypeError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 3: Reading a File\n\n**Function Name**: `read_file` \n**Functionality**: Reads the content of a file and returns it as a string.\n\n```python\ndef read_file(file_path: str) -> str:\n \"\"\"\n Reads the content of a file and returns it as a string.\n\n Args:\n file_path (str): The path to the file to read.\n\n Returns:\n str: The content of the file.\n\n Raises:\n FileNotFoundError: If the file does not exist.\n IOError: If there is an error reading the file.\n \"\"\"\n try:\n with open(file_path, 'r') as file:\n return file.read()\n except FileNotFoundError as e:\n print(f\"Error: {e}\")\n raise\n except IOError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 4: Converting a String to an Integer\n\n**Function Name**: `string_to_int` \n**Functionality**: Converts a string to an integer.\n\n```python\ndef string_to_int(value: str) -> int:\n \"\"\"\n Converts a string to an integer.\n\n Args:\n value (str): The string to convert.\n\n Returns:\n int: The integer value of the string.\n\n Raises:\n ValueError: If the string cannot be converted to an integer.\n \"\"\"\n try:\n return int(value)\n except ValueError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 5: Fetching Data from a URL\n\n**Function Name**: `fetch_data` \n**Functionality**: Fetches data from a given URL and returns it as a string.\n\n```python\nimport requests\n\ndef fetch_data(url: str) -> str:\n \"\"\"\n Fetches data from a given URL and returns it as a string.\n\n Args:\n url (str): The URL to fetch data from.\n\n Returns:\n str: The data fetched from the URL.\n\n Raises:\n requests.exceptions.RequestException: If there is an error with the request.\n \"\"\"\n try:\n response = requests.get(url)\n response.raise_for_status()\n return response.text\n except requests.exceptions.RequestException as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 6: Calculating Factorial\n\n**Function Name**: `calculate_factorial` \n**Functionality**: Calculates the factorial of a given non-negative integer.\n\n```python\ndef calculate_factorial(n: int) -> int:\n \"\"\"\n Calculates the factorial of a given non-negative integer.\n\n Args:\n n (int): The non-negative integer to calculate the factorial of.\n\n Returns:\n int: The factorial of the given number.\n\n Raises:\n ValueError: If the input is a negative integer.\n \"\"\"\n try:\n if n < 0:\n raise ValueError(\"Input must be a non-negative integer.\")\n factorial = 1\n for i in range(1, n + 1):\n factorial *= i\n return factorial\n except ValueError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n### Create a Python function following these requirements:\n\n**Function Name**: `find_max`\n**Functionality**: Finds the maximum value in a list of numbers.\n\n```python\nfrom typing import List\n\ndef find_max(numbers: List[float]) -> float:\n \"\"\"\n Finds the maximum value in a list of numbers.\n\n Args:\n numbers (List[float]): A list of numbers to find the maximum value from.\n\n Returns:\n float: The maximum value in the list.\n\n Raises:\n ValueError: If the list is empty.\n \"\"\"\n try:\n if not numbers:\n raise ValueError(\"The list cannot be empty.\")\n return max(numbers)\n except ValueError as e:\n print(f\"Error: {e}\")\n raise\n```\n\nBy following the above examples and guidelines, you can create well-structured, type-annotated, and well-documented Python functions with appropriate error handling.",
"short_memory": "System: : Your task is to generate Python functions with the following requirements:\n1. **Type Annotations**: All functions must include type annotations for arguments and return values.\n2. **Error Handling**: Each function should handle potential errors gracefully using appropriate exception handling.\n3. **Documentation**: Each function must be well-documented, including a docstring that explains:\n - The purpose of the function\n - Arguments: their names, types, and descriptions\n - Return value: its type and description\n - Potential exceptions that the function may raise\n\n### Guidelines\n1. Ensure all functions are designed to be clear and concise.\n2. Use Python's built-in exception classes for error handling.\n3. Ensure that the docstring format adheres to PEP 257 standards.\n\n### Example Functions\n\n#### Example 1: Division Function\n\n**Function Name**: `divide_numbers` \n**Functionality**: Divides the numerator by the denominator.\n\n```python\ndef divide_numbers(numerator: float, denominator: float) -> float:\n \"\"\"\n Divides the numerator by the denominator.\n\n Args:\n numerator (float): The number to be divided.\n denominator (float): The number to divide by.\n\n Returns:\n float: The result of the division.\n\n Raises:\n ValueError: If the denominator is zero.\n \"\"\"\n try:\n if denominator == 0:\n raise ValueError(\"The denominator cannot be zero.\")\n return numerator / denominator\n except ValueError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 2: Summing a List\n\n**Function Name**: `sum_list` \n**Functionality**: Sums all the numbers in a given list.\n\n```python\nfrom typing import List\n\ndef sum_list(numbers: List[float]) -> float:\n \"\"\"\n Sums all the numbers in a given list.\n\n Args:\n numbers (List[float]): A list of numbers to sum.\n\n Returns:\n float: The sum of all numbers in the list.\n\n Raises:\n TypeError: If any element in the list is not a number.\n \"\"\"\n try:\n return sum(numbers)\n except TypeError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 3: Reading a File\n\n**Function Name**: `read_file` \n**Functionality**: Reads the content of a file and returns it as a string.\n\n```python\ndef read_file(file_path: str) -> str:\n \"\"\"\n Reads the content of a file and returns it as a string.\n\n Args:\n file_path (str): The path to the file to read.\n\n Returns:\n str: The content of the file.\n\n Raises:\n FileNotFoundError: If the file does not exist.\n IOError: If there is an error reading the file.\n \"\"\"\n try:\n with open(file_path, 'r') as file:\n return file.read()\n except FileNotFoundError as e:\n print(f\"Error: {e}\")\n raise\n except IOError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 4: Converting a String to an Integer\n\n**Function Name**: `string_to_int` \n**Functionality**: Converts a string to an integer.\n\n```python\ndef string_to_int(value: str) -> int:\n \"\"\"\n Converts a string to an integer.\n\n Args:\n value (str): The string to convert.\n\n Returns:\n int: The integer value of the string.\n\n Raises:\n ValueError: If the string cannot be converted to an integer.\n \"\"\"\n try:\n return int(value)\n except ValueError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 5: Fetching Data from a URL\n\n**Function Name**: `fetch_data` \n**Functionality**: Fetches data from a given URL and returns it as a string.\n\n```python\nimport requests\n\ndef fetch_data(url: str) -> str:\n \"\"\"\n Fetches data from a given URL and returns it as a string.\n\n Args:\n url (str): The URL to fetch data from.\n\n Returns:\n str: The data fetched from the URL.\n\n Raises:\n requests.exceptions.RequestException: If there is an error with the request.\n \"\"\"\n try:\n response = requests.get(url)\n response.raise_for_status()\n return response.text\n except requests.exceptions.RequestException as e:\n print(f\"Error: {e}\")\n raise\n```\n\n#### Example 6: Calculating Factorial\n\n**Function Name**: `calculate_factorial` \n**Functionality**: Calculates the factorial of a given non-negative integer.\n\n```python\ndef calculate_factorial(n: int) -> int:\n \"\"\"\n Calculates the factorial of a given non-negative integer.\n\n Args:\n n (int): The non-negative integer to calculate the factorial of.\n\n Returns:\n int: The factorial of the given number.\n\n Raises:\n ValueError: If the input is a negative integer.\n \"\"\"\n try:\n if n < 0:\n raise ValueError(\"Input must be a non-negative integer.\")\n factorial = 1\n for i in range(1, n + 1):\n factorial *= i\n return factorial\n except ValueError as e:\n print(f\"Error: {e}\")\n raise\n```\n\n### Create a Python function following these requirements:\n\n**Function Name**: `find_max`\n**Functionality**: Finds the maximum value in a list of numbers.\n\n```python\nfrom typing import List\n\ndef find_max(numbers: List[float]) -> float:\n \"\"\"\n Finds the maximum value in a list of numbers.\n\n Args:\n numbers (List[float]): A list of numbers to find the maximum value from.\n\n Returns:\n float: The maximum value in the list.\n\n Raises:\n ValueError: If the list is empty.\n \"\"\"\n try:\n if not numbers:\n raise ValueError(\"The list cannot be empty.\")\n return max(numbers)\n except ValueError as e:\n print(f\"Error: {e}\")\n raise\n```\n\nBy following the above examples and guidelines, you can create well-structured, type-annotated, and well-documented Python functions with appropriate error handling.\n\n\nHuman:: Let's build an API that uses an LLM from OpenAI to generate code for the Google Calendar API.\n\n\nFunctionGenerator: None\n\n",
"loop_interval": 0,
"retry_attempts": 3,
"retry_interval": 1,
"interactive": false,
"dashboard": false,
"dynamic_temperature": false,
"autosave": true,
"saved_state_path": "FunctionGenerator_state.json",
"max_loops": 1,
"Task": "Let's build an API that uses an LLM from OpenAI to generate code for the Google Calendar API.",
"Stopping Token": "<DONE>",
"Dynamic Loops": false,
"sop": null,
"sop_list": null,
"context_length": 8000,
"user_name": "Human:",
"self_healing_enabled": false,
"code_interpreter": false,
"multi_modal": null,
"pdf_path": null,
"list_of_pdf": null,
"preset_stopping_token": false,
"traceback": null,
"traceback_handlers": null,
"streaming_on": true,
"docs": null,
"docs_folder": null,
"verbose": false,
"parser": null,
"best_of_n": null,
"callback": null,
"metadata": null,
"callbacks": null,
"search_algorithm": null,
"logs_to_filename": null,
"evaluator": null,
"output_json": false,
"stopping_func": null,
"custom_loop_condition": null,
"sentiment_threshold": null,
"custom_exit_command": "exit",
"sentiment_analyzer": null,
"limit_tokens_from_string": null,
"tool_schema": null,
"output_type": null,
"function_calling_type": "json",
"output_cleaner": null,
"function_calling_format_type": "OpenAI",
"list_base_models": null,
"metadata_output_type": "json"
}