43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from core.agent.agent import create_agent_graph
|
|
from langchain_core.messages import HumanMessage, AIMessage
|
|
from rich.console import Console
|
|
from rich.prompt import Prompt
|
|
from rich.panel import Panel
|
|
|
|
AGENT_NAME = "oss-agent"
|
|
console = Console()
|
|
|
|
def main():
|
|
console.print(Panel.fit(f"[bold cyan]Hello from {AGENT_NAME}![/bold cyan]", border_style="cyan"))
|
|
graph = create_agent_graph()
|
|
|
|
# A checkpointer requires a thread ID to track the conversation
|
|
config = {"configurable": {"thread_id": "1"}}
|
|
|
|
user_input = "summarize current directory for me, tell me what does this project do and save summary to summary.txt"
|
|
console.print(f"\n[bold green]👤 User:[/bold green] {user_input}")
|
|
state_input = {"messages": [HumanMessage(content=user_input)]}
|
|
|
|
while True:
|
|
for event in graph.stream(state_input, config, stream_mode="updates"):
|
|
pass
|
|
|
|
state = graph.get_state(config)
|
|
if not state.next:
|
|
break
|
|
|
|
if "get_human_feedback" in state.next:
|
|
feedback = Prompt.ask("\n[bold yellow]👉 Your response[/bold yellow]")
|
|
state_input = {"messages": [HumanMessage(content=feedback)]}
|
|
else:
|
|
state_input = None
|
|
|
|
|
|
def print_message(message):
|
|
if message.type == "ai":
|
|
console.print(f"[bold blue]{AGENT_NAME}:[/bold blue] {message.content}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|