Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination
from autogen_agentchat.messages import HandoffMessage
from autogen_agentchat.teams import SelectorGroupChat
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
from dotenv import load_dotenv

from prompts._istio_crd import get_istio_crd_prompt
from prompts.models import IstioCrdType
from tools.istio import proxy_config
from tools.k8s import k8s_get_pods
from tools.k8s import k8s_get_pods, k8s_get_services, k8s_get_pod, k8s_apply_manifest, k8s_get_resources

from dotenv import load_dotenv
load_dotenv()


Expand All @@ -26,8 +27,9 @@
You are a planning agent.
Your job is to break down complex tasks into smaller, manageable subtasks.
Your team members are:
K8s agent: Run information gathering tasks related to Kubernetes.
Istio Agent: Run information gathering tasks related to Istio
k8s_agent: Run information gathering tasks related to Kubernetes and any resources in the cluster.
k8s_resource_creator: Apply manifests to the Kubernetes cluster.
istio_authpolicy_crd_agent: Run any Istio AuthorizationPolicy resource creation tasks

You only plan and delegate tasks - you do not execute them yourself.

Expand All @@ -42,31 +44,44 @@
k8s_agent = AssistantAgent(
"k8s_agent",
model_client=model_client,
tools=[k8s_get_pods],
tools=[k8s_get_pods, k8s_get_pod, k8s_get_services, k8s_apply_manifest, k8s_get_resources],
system_message="""You are an agent specialized in Kubernetes.
You have access to the get_pods tool which allows you to get information about one or more pods.
You have access to tools that allow you to interact with the Kubernetes cluster.
""",
)

istio_agent = AssistantAgent(
name="istio_agent",
k8s_resource_creator = AssistantAgent(
"k8s_resource_creator",
model_client=model_client,
tools=[k8s_apply_manifest],
system_message="You are an agent specialized in applying manfiests to Kubernetes.",)

# istio_agent = AssistantAgent(
# name="istio_agent",
# model_client=model_client,
# tools=[proxy_config],
# system_message="""You are an agent specialized in Istio.
# You have access to the proxy_config tool which allows you to get the proxy configuration for a pod.
# """,
# )

istio_authpolicy_crd_agent = AssistantAgent(
name="istio_authpolicy_crd_agent",
model_client=model_client,
tools=[proxy_config],
system_message="""You are an agent specialized in Istio.
You have access to the proxy_config tool which allows you to get the proxy configuration for a pod.
"""
system_message=get_istio_crd_prompt(IstioCrdType.AUTHORIZATION_POLICY),
)

text_mention_termination = TextMentionTermination("TERMINATE")
max_messages_termination = MaxMessageTermination(max_messages=25)
termination = text_mention_termination | max_messages_termination

team = SelectorGroupChat(
[planning_agent, k8s_agent, istio_agent],
[planning_agent, k8s_agent, k8s_resource_creator, istio_authpolicy_crd_agent],
model_client=OpenAIChatCompletionClient(model="gpt-4o-mini"),
termination_condition=termination,
)

task = "Get the proxy configuration for all pods in the default namespace"
task = "I want to deny requests from the productpage to the POST method on the reviews."

asyncio.run(Console(team.run_stream(task=task)))
3 changes: 3 additions & 0 deletions python/prompts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ._istio_crd import get_istio_crd_prompt

__all__ = ["get_istio_crd_prompt"]
Loading