Skip to content
Merged
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
12 changes: 9 additions & 3 deletions devops_agent/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ def run_interactive_mode(provider: str, output: str = None, format: str = 'text'

# Process the query
console.print(Panel.fit(
"[bold cyan]DevOps Agent[/bold cyan] [dim]Thinking...[/dim]",
"[bold cyan]DevOps Team[/bold cyan] [dim]Thinking...[/dim]",
border_style="cyan"
))

try:
response = execute_master_agent(provider=provider, user_query=user_input)
console.print(f"\n[bold cyan]Assistant:[/bold cyan]\n{response}")
console.print(Panel.fit(
f"[bold yellow]Assistant:[/bold yellow] [dim]{response}[/dim]",
border_style="yellow"
))

# Save to output file if specified
if output:
Expand Down Expand Up @@ -119,7 +122,10 @@ def process_query(provider: str, query: str, output: str = None, format: str = '

try:
response = execute_master_agent(provider=provider, user_query=query)
console.print(f"\n[bold cyan]Assistant:[/bold cyan]\n{response}")
console.print(Panel.fit(
f"[bold yellow]Assistant:[/bold yellow] [dim]{response}[/dim]",
border_style="yellow"
))

if output:
save_to_file(output, query, response, format)
Expand Down
4 changes: 2 additions & 2 deletions devops_agent/core/devops_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

def execute_devops_agent(provider: str, user_query: str = None) -> Agent:
console.print(Panel.fit(
"[bold cyan]DevOps Agent Executing...[/bold cyan]",
"[bold cyan]DevOps Agent Invoking...[/bold cyan]",
border_style="cyan"
))
llm_provider = provider.lower().strip()
Expand All @@ -51,7 +51,7 @@ def execute_devops_agent(provider: str, user_query: str = None) -> Agent:
description="You help answer questions about the devops domain.",
instructions=devops_prompt,
# knowledge=knowledge,
# stream_intermediate_steps=True,
stream_intermediate_steps=True,
# add_knowledge_to_context=True,
# add_datetime_to_context=True,
# add_session_summary_to_context=True,
Expand Down
4 changes: 2 additions & 2 deletions devops_agent/core/kubernetes_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
def execute_k8s_agent(provider: str, user_query: str = None) -> Agent:

console.print(Panel.fit(
"[bold cyan]Kubernetes Agent Executing...[/bold cyan]",
"[bold cyan]Kubernetes Agent Invoking...[/bold cyan]",
border_style="cyan"
))

Expand All @@ -54,7 +54,7 @@ def execute_k8s_agent(provider: str, user_query: str = None) -> Agent:
description="You help answer questions about the kubernetes domain of any infrastructure like Azure(AKS), AWS(EKS), and GCP(GKS)",
instructions=k8s_prompt,
# knowledge=knowledge,
# stream_intermediate_steps=True,
stream_intermediate_steps=True,
# add_knowledge_to_context=True,
# add_datetime_to_context=True,
# add_session_summary_to_context=True,
Expand Down
30 changes: 26 additions & 4 deletions devops_agent/core/master_agent.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import asyncio
import os
from typing import Any

from agno.knowledge import Knowledge
from agno.models.openai import OpenAIChat
from agno.models.anthropic import Claude
from agno.models.google.gemini import Gemini
from agno.team import Team
from agno.tools.reasoning import ReasoningTools
from agno.vectordb.qdrant import Qdrant
from agno.db.in_memory import InMemoryDb
from agno.knowledge.embedder.fastembed import FastEmbedEmbedder
from qdrant_client import QdrantClient
from qdrant_client.http.models import VectorParams, Distance

from devops_agent.core.devops_agent import execute_devops_agent
from devops_agent.core.kubernetes_agent import execute_k8s_agent

from rich.console import Console
from rich.panel import Panel
from rich.live import Live
from rich.markdown import Markdown
from rich.console import Group

from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

console = Console()

qclient = QdrantClient(url=os.environ.get('QDRANT_URL'), api_key=os.environ.get('QDRANT_API_KEY'))
if not qclient.collection_exists("devops-memory"):
qclient.create_collection(collection_name="devops-memory",
Expand Down Expand Up @@ -41,34 +56,41 @@ def execute_master_agent(provider: str, user_query: str) -> str:
devops_team = Team(
name="Multi Cloud and Devops Team",
model=model,
respond_directly=True,
members=[
execute_devops_agent(provider=provider),
execute_k8s_agent(provider=provider),
],
markdown=True,
instructions=[
"You are a intelligent router that directs questions to the appropriate agent.",
"If the user asks in a non devops or k8s question whose agent is not a team member, respond in English with:",
"'I can only answer in the following technologies: Devops & Kubernetes Architecture on Multiple clouds. Please ask your question in one of these technologies.'",
"Always check the technology or domain of the user's input before routing to an agent.",
"For unsupported technologies like coding, flowcharts, analytics etc respond in English with the above message.",
],
tools=[ReasoningTools()], # Enable reasoning capabilities
knowledge=knowledge,
determine_input_for_members=True,
db=InMemoryDb(),
respond_directly=False, # if set to true the member response if directly given to user
determine_input_for_members=False,
delegate_task_to_all_members=False,
stream_intermediate_steps=True,
add_knowledge_to_context=True,
add_datetime_to_context=True,
add_session_summary_to_context=True,
show_members_responses=True,
share_member_interactions=True,
enable_agentic_memory=True,
markdown=True
)

response = devops_team.run(user_query, stream_intermediate_steps=True, retry=3)

# saved the response to knowledge in async mode
asyncio.run(
knowledge.add_content_async(text_content=f"question: {user_query}, Assistant: {response.content}",
metadata={"agent_id": response.team_id, "session_id": response.session_id})
skip_if_exists=False,
metadata={"agent_id": response.team_id, "session_id": response.session_id,
"run_id": response.run_id})
)

return response.content
7 changes: 7 additions & 0 deletions devops_agent/playground.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from devops_agent.core.master_agent import execute_master_agent
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

if __name__ == '__main__':
execute_master_agent(provider="openai", user_query="Analyze distributed tracing data to identify performance bottleneck in microservices architecture")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "devops-agent"
version = "0.1.0"
version = "0.0.1"
description = "AI-powered DevOps CLI assistant"
readme = "README.md"
requires-python = ">=3.8"
Expand Down