MCPcopy Create free account
hub / github.com/coleam00/ottomator-agents / chat

Method chat

pydantic-github-agent/cli.py:26–64  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

24 )
25
26 async def chat(self):
27 print("GitHub Agent CLI (type 'quit' to exit)")
28 print("Enter your message:")
29
30 try:
31 while True:
32 user_input = input("> ").strip()
33 if user_input.lower() == 'quit':
34 break
35
36 # Run the agent with streaming
37 result = await github_agent.run(
38 user_input,
39 deps=self.deps,
40 message_history=self.messages
41 )
42
43 # Store the user message
44 self.messages.append(
45 ModelRequest(parts=[UserPromptPart(content=user_input)])
46 )
47
48 # Store itermediatry messages like tool calls and responses
49 filtered_messages = [msg for msg in result.new_messages()
50 if not (hasattr(msg, 'parts') and
51 any(part.part_kind == 'user-prompt' or part.part_kind == 'text' for part in msg.parts))]
52 self.messages.extend(filtered_messages)
53
54 # Optional if you want to print out tool calls and responses
55 # print(filtered_messages + "\n\n")
56
57 print(result.data)
58
59 # Add the final response from the agent
60 self.messages.append(
61 ModelResponse(parts=[TextPart(content=result.data)])
62 )
63 finally:
64 await self.deps.client.aclose()
65
66async def main():
67 cli = CLI()

Callers 2

mainFunction · 0.95
queryMethod · 0.45

Calls 1

runMethod · 0.45

Tested by

no test coverage detected