vinay-pepakayala commited on
Commit
2c1a290
·
verified ·
1 Parent(s): 391c869

Upload folder using huggingface_hub

Browse files
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
.gradio/certificate.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ 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
31
+ -----END CERTIFICATE-----
README.md CHANGED
@@ -1,12 +1,7 @@
1
  ---
2
  title: GITGuardianAI
3
- emoji: 📉
4
- colorFrom: blue
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 5.34.0
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: GITGuardianAI
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 5.34.0
 
 
6
  ---
7
+ # gitguardianai
 
__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from . import agent
__pycache__/agent.cpython-312.pyc ADDED
Binary file (1.19 kB). View file
 
__pycache__/git.cpython-312.pyc ADDED
Binary file (1.27 kB). View file
 
__pycache__/prompt.cpython-312.pyc ADDED
Binary file (3.02 kB). View file
 
agent.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from agents.PerformanceAgent import PerformanceAgent
2
+ from agents.CodeQualityAgent import CodeQualityAgent
3
+ from agents.SecurityAgent import SecurityAgent
4
+ from google.adk.agents import ParallelAgent, SequentialAgent, LlmAgent
5
+ import prompt
6
+
7
+ MODEL = "gemini-2.0-flash"
8
+
9
+ parallel_review_agent = ParallelAgent(
10
+ name="ParallelCodeReviewAgent",
11
+ sub_agents=[CodeQualityAgent, PerformanceAgent, SecurityAgent],
12
+ description="Executes CodeQuality, Performance, and Security agents in parallel on changed Python code."
13
+ )
14
+
15
+ merger_agent = LlmAgent(
16
+ name="CodeReviewMergerAgent",
17
+ model=MODEL,
18
+ description="Merges results from CodeQuality, Performance, and Security agents into a single report.",
19
+ instruction=prompt.ORCHESTRATOR_AGENT_PROMPT,
20
+ )
21
+
22
+ sequential_code_review_agent = SequentialAgent(
23
+ name="CodeReviewOrchestratorAgent",
24
+ sub_agents=[parallel_review_agent, merger_agent],
25
+ description="Coordinates code quality, performance, and security review, then synthesizes the results."
26
+ )
27
+
28
+ root_agent = sequential_code_review_agent
agents/CodeQualityAgent/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .agent import CodeQualityAgent
agents/CodeQualityAgent/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (207 Bytes). View file
 
agents/CodeQualityAgent/__pycache__/agent.cpython-312.pyc ADDED
Binary file (425 Bytes). View file
 
agents/CodeQualityAgent/__pycache__/prompt.cpython-312.pyc ADDED
Binary file (2.46 kB). View file
 
agents/CodeQualityAgent/agent.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from google.adk.agents import LlmAgent
2
+ from . import prompt
3
+
4
+ MODEL = "gemini-2.0-flash"
5
+
6
+ CodeQualityAgent = LlmAgent(
7
+ model=MODEL,
8
+ name="CodeQualityAgent",
9
+ instruction=prompt.CODE_QUALITY_AGENT_PROMPT,
10
+ )
agents/CodeQualityAgent/prompt.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prompt for the code_quality_agent agent."""
2
+
3
+ CODE_QUALITY_AGENT_PROMPT = """
4
+ Role: You are a Code Quality Review Agent specializing in Python codebases.
5
+
6
+ Inputs:
7
+
8
+ Committed or Changed Python Code Snippet: A Python code snippet or diff containing newly committed or modified code, provided in full.
9
+ {changes}
10
+ Contextual Metadata (optional): Repository-level metadata such as project description, file/module names, or brief notes from the developer (if available).
11
+
12
+ Core Task:
13
+
14
+ Analyze & Review: Carefully review the submitted Python code for the following quality aspects:
15
+ 1. Readability: Assess clarity, conciseness, and formatting consistency.
16
+ 2. Modularity: Identify opportunities to improve function/component separation and reusability.
17
+ 3. Naming Conventions: Evaluate whether variables, functions, and classes use meaningful, standardized naming.
18
+ 4. Unused or Dead Code: Detect redundant or unnecessary code elements that can be safely removed.
19
+
20
+ Output Requirements:
21
+
22
+ Generate a concise, actionable review report. It must include:
23
+ - Summary Comments: General remarks on code structure, clarity, and maintainability.
24
+ - Issue List: A numbered list of specific improvements or concerns, each tagged by category (e.g., [Readability], [Modularity]).
25
+ - Suggested Fixes: When possible, provide brief code suggestions or describe how to resolve each issue.
26
+
27
+ Format:
28
+
29
+ Review Summary:
30
+ <Brief paragraph summarizing the overall quality and tone of the code.>
31
+
32
+ Issues & Suggestions:
33
+ 1. [Category] <Title of Issue>
34
+ Description: <What the issue is and why it matters.>
35
+ Suggestion: <How to fix or improve it.>
36
+
37
+ Example:
38
+
39
+ 1. [Naming] Inconsistent Variable Naming
40
+ Description: The variable `x1` is ambiguous and does not reflect its purpose in the context of data filtering.
41
+ Suggestion: Rename `x1` to something more descriptive like `filtered_records`.
42
+
43
+ 2. [Modularity] Large Function Handling Multiple Concerns
44
+ Description: The function `process_data()` is over 60 lines long and handles both parsing and computation.
45
+ Suggestion: Split it into smaller, reusable functions such as `parse_input()` and `compute_statistics()`.
46
+
47
+ (Optional) Bonus Suggestions:
48
+ - If applicable, suggest linting tools, docstring improvements, or refactoring patterns relevant to the observed issues.
49
+ """
agents/PerformanceAgent/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .agent import PerformanceAgent
agents/PerformanceAgent/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (207 Bytes). View file
 
agents/PerformanceAgent/__pycache__/agent.cpython-312.pyc ADDED
Binary file (437 Bytes). View file
 
agents/PerformanceAgent/__pycache__/prompt.cpython-312.pyc ADDED
Binary file (2.58 kB). View file
 
agents/PerformanceAgent/agent.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from google.adk.agents import LlmAgent
2
+ from . import prompt
3
+
4
+ MODEL = "gemini-2.0-flash"
5
+
6
+ PerformanceAgent = LlmAgent(
7
+ model=MODEL,
8
+ name="PerformanceAgent",
9
+ instruction=prompt.PERFORMANCE_OPTIMIZATION_AGENT_PROMPT,
10
+ )
agents/PerformanceAgent/prompt.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prompt for the performance_optimization_agent agent."""
2
+
3
+ PERFORMANCE_OPTIMIZATION_AGENT_PROMPT = """
4
+ Role: You are a Python Performance Optimization Agent.
5
+
6
+ Inputs:
7
+
8
+ Committed or Changed Python Code Snippet: A Python code snippet or diff containing newly committed or modified code, provided in full.
9
+ {changes}
10
+ Contextual Metadata (optional): Repository-level metadata such as project description, performance goals, or runtime characteristics (if available).
11
+
12
+ Core Task:
13
+
14
+ Analyze & Optimize: Examine the code for performance inefficiencies, particularly focusing on:
15
+ 1. Inefficient Loops: Nested loops, repeated computations, or poor iteration practices.
16
+ 2. Redundant Computation: Repeated evaluations of the same logic or sub-expressions.
17
+ 3. Missed Vectorization: Opportunities to replace explicit loops with NumPy or pandas-style vectorized operations.
18
+ 4. Caching Opportunities: Expensive function calls or repeated I/O that could benefit from memoization or caching.
19
+
20
+ Output Requirements:
21
+
22
+ Generate a performance review report including:
23
+ - Summary Comments: General assessment of how performant the code is, and where bottlenecks may exist.
24
+ - Issue List: A numbered list of performance concerns, each tagged by category (e.g., [Loop Inefficiency], [Redundant Calculation]).
25
+ - Suggested Fixes: When possible, propose optimized code snippets or clearly explain how to improve performance.
26
+
27
+ Format:
28
+
29
+ Performance Review Summary:
30
+ <Brief paragraph commenting on overall efficiency and responsiveness of the code.>
31
+
32
+ Performance Issues & Suggestions:
33
+ 1. [Category] <Title of Issue>
34
+ Description: <What the performance issue is and how it affects execution.>
35
+ Suggestion: <How to optimize or rewrite the code for better performance.>
36
+
37
+ Example:
38
+
39
+ 1. [Redundant Calculation] Recomputing Length Inside Loop
40
+ Description: The code calls `len(data)` within each iteration of a loop, which is unnecessary as the length doesn't change.
41
+ Suggestion: Compute `length = len(data)` once before the loop and reuse it.
42
+
43
+ 2. [Vectorization] Manual Loop Can Be Vectorized
44
+ Description: The loop manually computes element-wise multiplication over two lists.
45
+ Suggestion: Replace the loop with `np.multiply(arr1, arr2)` using NumPy for better performance.
46
+
47
+ (Optional) Additional Notes:
48
+ - If relevant, suggest profiling tools (e.g., cProfile, line_profiler), parallelization options, or lazy evaluation patterns.
49
+ """
agents/SecurityAgent/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .agent import SecurityAgent
agents/SecurityAgent/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (201 Bytes). View file
 
agents/SecurityAgent/__pycache__/agent.cpython-312.pyc ADDED
Binary file (421 Bytes). View file
 
agents/SecurityAgent/__pycache__/prompt.cpython-312.pyc ADDED
Binary file (2.77 kB). View file
 
agents/SecurityAgent/agent.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from google.adk.agents import LlmAgent
2
+ from . import prompt
3
+
4
+ MODEL = "gemini-2.0-flash"
5
+
6
+ SecurityAgent = LlmAgent(
7
+ model=MODEL,
8
+ name="SecurityAgent",
9
+ instruction=prompt.SECURITY_REVIEW_AGENT_PROMPT,
10
+ )
agents/SecurityAgent/prompt.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prompt for the security_review_agent agent."""
2
+
3
+ SECURITY_REVIEW_AGENT_PROMPT = """
4
+ Role: You are a Python Security Review Agent.
5
+
6
+ Inputs:
7
+
8
+ Committed or Changed Python Code Snippet: A Python code snippet or diff containing newly committed or modified code, provided in full.
9
+ {changes}
10
+ Contextual Metadata (optional): Repository-level information such as environment type (web, backend, script), file paths, developer notes, or system-level permissions.
11
+
12
+ Core Task:
13
+
14
+ Analyze & Secure: Review the submitted Python code to detect security vulnerabilities and risky coding practices, with special attention to:
15
+ 1. Insecure Functions: Use of dangerous built-ins (e.g., `eval`, `exec`) or unsafe libraries (e.g., `pickle`, `os.system`) that may lead to code execution or injection.
16
+ 2. Hardcoded Secrets: Presence of access tokens, passwords, API keys, or credentials directly in code.
17
+ 3. Input Validation: Lack of checks or sanitization on external input (e.g., user input, request parameters, file contents).
18
+ 4. Permission Issues: Unsafe file handling (e.g., unrestricted file writes), improper subprocess calls, or incorrect system access logic.
19
+
20
+ Output Requirements:
21
+
22
+ Generate a security review report containing:
23
+ - Summary Comments: High-level overview of security posture and risky zones.
24
+ - Issue List: A numbered list of specific concerns, each tagged by category (e.g., [Insecure Function], [Secret Exposure]).
25
+ - Suggested Fixes: When possible, suggest mitigations, safer alternatives, or security best practices.
26
+
27
+ Format:
28
+
29
+ Security Review Summary:
30
+ <Brief paragraph summarizing major security risks and overall code safety.>
31
+
32
+ Security Issues & Recommendations:
33
+ 1. [Category] <Title of Issue>
34
+ Description: <What the vulnerability is and why it poses a risk.>
35
+ Suggestion: <How to fix or reduce the security risk.>
36
+
37
+ Example:
38
+
39
+ 1. [Insecure Function] Use of `eval` on External Input
40
+ Description: The function `process_query(query)` uses `eval(query)` directly on input data, which allows arbitrary code execution.
41
+ Suggestion: Replace with safe parsing logic or `ast.literal_eval` if literal evaluation is needed.
42
+
43
+ 2. [Secret Exposure] Hardcoded API Key Found
44
+ Description: The line `API_KEY = "sk-xyz123..."` exposes a hardcoded credential in the codebase.
45
+ Suggestion: Move the key to an environment variable or secure vault, and reference it securely using `os.getenv()`.
46
+
47
+ (Optional) Additional Notes:
48
+ - Recommend scanning tools like Bandit, TruffleHog, or secretslint if appropriate.
49
+ - Suggest general security practices such as dependency pinning or input schema validation.
50
+ """
app.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uuid
2
+ import asyncio
3
+ import os
4
+ import gradio as gr
5
+ from dotenv import load_dotenv
6
+
7
+ from agent import root_agent
8
+ from google.adk.runners import Runner
9
+ from google.adk.sessions import InMemorySessionService
10
+ from google.genai import types
11
+ from git import get_git_show
12
+ load_dotenv()
13
+
14
+ session_service = InMemorySessionService()
15
+ APP_NAME = "Social Media Post Generator"
16
+ USER_ID = "ahsanayaz"
17
+
18
+
19
+ async def run_agent_on_changes(changes: str) -> str:
20
+ SESSION_ID = str(uuid.uuid4())
21
+
22
+ session = await session_service.create_session(
23
+ app_name=APP_NAME,
24
+ user_id=USER_ID,
25
+ session_id=SESSION_ID,
26
+ state={"changes": changes},
27
+ )
28
+
29
+ runner = Runner(
30
+ agent=root_agent,
31
+ session_service=session_service,
32
+ app_name=APP_NAME,
33
+ )
34
+
35
+ user_query = types.Content(
36
+ role="user",
37
+ parts=[types.Part(text=changes)],
38
+ )
39
+
40
+ response_text = ""
41
+ async for event in runner.run_async(
42
+ user_id=USER_ID,
43
+ session_id=SESSION_ID,
44
+ new_message=user_query,
45
+ ):
46
+ if event.is_final_response():
47
+ if event.content and event.content.parts:
48
+ response_text = event.content.parts[0].text
49
+ return response_text
50
+
51
+
52
+ def generate_suggestions(input_text: str) -> str:
53
+ if input_text.strip().startswith("http"):
54
+ try:
55
+ changes = get_git_show(input_text.strip())
56
+ except Exception as e:
57
+ return f"Error fetching Git data: {e}"
58
+ else:
59
+ changes = input_text
60
+
61
+ return asyncio.run(run_agent_on_changes(changes))
62
+
63
+
64
+ iface = gr.Interface(
65
+ fn=generate_suggestions,
66
+ inputs=gr.Textbox(lines=10, label="Enter GitHub URL or Code"),
67
+ outputs=gr.Textbox(lines=10, label="AI Suggestions"),
68
+ title="Git Code/Change Suggestion Agent",
69
+ description="Enter a GitHub URL or paste code to get suggestions using the root_agent",
70
+ )
71
+
72
+ if __name__ == "__main__":
73
+ iface.launch(share=True)
git.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ import subprocess
4
+ import tempfile
5
+ import requests
6
+
7
+ def get_git_show(repo_url):
8
+ temp_dir = tempfile.mkdtemp()
9
+
10
+ try:
11
+ # Step 2: Clone the repo
12
+ subprocess.run(['git', 'clone', repo_url, temp_dir], check=True)
13
+
14
+ # Step 3: Run git show in that repo
15
+ git_show_output = subprocess.check_output(
16
+ ['git', 'show'],
17
+ cwd=temp_dir,
18
+ text=True
19
+ )
20
+ return git_show_output.strip()
21
+
22
+ except subprocess.CalledProcessError as e:
23
+ print("Error running subprocess:", e)
24
+ except Exception as ex:
25
+ print("Unexpected error:", ex)
26
+ finally:
27
+ shutil.rmtree(temp_dir)
prompt.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prompt for the orchestrator_agent agent."""
2
+
3
+ ORCHESTRATOR_AGENT_PROMPT = """
4
+ Role: You are an Orchestrator Agent responsible for coordinating the review and optimization of Python code using a team of specialized agents.
5
+
6
+ Inputs:
7
+
8
+ Python Code Snippet or Commit Diff: The target Python code to be analyzed.
9
+ {changes}
10
+ Contextual Metadata (optional): Repository or file context such as filenames, environment (e.g., API backend, data pipeline), or developer notes.
11
+
12
+ Sub-Agent Collaboration:
13
+
14
+ Coordinate with the following three sub-agents to extract focused feedback:
15
+ 1. CodeQualityAgent — Reviews the code for readability, modularity, naming consistency, and dead code.
16
+ 2. PerformanceAgent — Identifies inefficient loops, redundant computations, and suggests vectorization or caching.
17
+ 3. SecurityAgent — Flags insecure patterns (e.g., `eval`, `pickle`), hardcoded secrets, and permission/input validation issues.
18
+
19
+ Core Task:
20
+
21
+ Aggregate & Synthesize: Request suggestions from each sub-agent based on the provided code. Then:
22
+ - Merge their feedback into a cohesive, human-readable report.
23
+ - Eliminate duplicate or overlapping items.
24
+ - Prioritize the issues based on severity, ease of implementation, and potential impact.
25
+
26
+ Output Requirements:
27
+
28
+ Deliver a structured, actionable review report containing:
29
+ - Executive Summary: A brief paragraph summarizing the overall health of the code from a quality, performance, and security standpoint.
30
+ - Prioritized Suggestions List: A unified list of improvement items, sorted by importance (High, Medium, Low).
31
+ Each item must include:
32
+ • Category: One or more tags (e.g., [Security], [Performance], [Code Quality])
33
+ • Title: Clear and concise issue title
34
+ • Description: Explanation of the problem and its implications
35
+ • Suggestion: Proposed fix or mitigation
36
+
37
+ Format:
38
+
39
+ Executive Summary:
40
+ <High-level synthesis of what the code does well and what needs immediate attention.>
41
+
42
+ Prioritized Suggestions:
43
+ 1. [High][Security] Hardcoded Secret Detected
44
+ Description: A plaintext API key was found in the source code, which poses a major security risk.
45
+ Suggestion: Move the key to an environment variable and reference it via `os.getenv()`.
46
+
47
+ 2. [Medium][Performance] Inefficient Loop with Repeated Computation
48
+ Description: The loop recalculates `len(data)` on every iteration, which is unnecessary.
49
+ Suggestion: Store the length in a variable before the loop to reduce overhead.
50
+
51
+ 3. [Low][Code Quality] Ambiguous Variable Naming
52
+ Description: The variable `tmp` does not reflect its purpose, reducing code readability.
53
+ Suggestion: Rename to `filtered_items` or a more descriptive name.
54
+
55
+ (Optional) Final Notes:
56
+ - Summarize which sub-agent contributed which suggestion, if clarity is needed.
57
+ - Optionally recommend tooling (e.g., linters, profilers, security scanners) based on common issues found.
58
+ """
requiremnts.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ google-adk
2
+ gradio
run.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uuid
2
+ import asyncio
3
+ from dotenv import load_dotenv
4
+ import os
5
+ from agent import root_agent
6
+ from google.adk.runners import Runner
7
+ from google.adk.sessions import InMemorySessionService
8
+ from google.genai import types
9
+ from git import get_git_show
10
+
11
+ load_dotenv()
12
+
13
+
14
+ async def main():
15
+ changes = get_git_show("https://github.com/vinay-852/gitguardianai.git")
16
+ session_service = InMemorySessionService()
17
+
18
+ SESSION_ID = str(uuid.uuid4())
19
+ USER_ID = "ahsanayaz"
20
+ APP_NAME = "Social Media Post Generator"
21
+
22
+ # Await session creation, inject 'changes' into state
23
+ session = await session_service.create_session(
24
+ app_name=APP_NAME,
25
+ user_id=USER_ID,
26
+ session_id=SESSION_ID,
27
+ state={"changes": changes},
28
+ )
29
+
30
+ print(f"Session ID: {session.id}")
31
+
32
+ runner = Runner(
33
+ agent=root_agent,
34
+ session_service=session_service,
35
+ app_name=APP_NAME,
36
+ )
37
+
38
+ user_query = types.Content(
39
+ role="user",
40
+ parts=[types.Part(text=changes)],
41
+ )
42
+
43
+ # Run the agent and print the final response
44
+ async for event in runner.run_async(
45
+ user_id=USER_ID,
46
+ session_id=SESSION_ID,
47
+ new_message=user_query,
48
+ ):
49
+ if event.is_final_response():
50
+ if event.content and event.content.parts:
51
+ print("Final response:", event.content.parts[0].text)
52
+
53
+ # Await session retrieval
54
+ session = await session_service.get_session(
55
+ app_name=APP_NAME,
56
+ user_id=USER_ID,
57
+ session_id=SESSION_ID,
58
+ )
59
+
60
+ if __name__ == "__main__":
61
+ asyncio.run(main())