From fe3c8913c952b40b46d0d14aeb6adf7b5e173697 Mon Sep 17 00:00:00 2001 From: goulustis Date: Wed, 15 Oct 2025 20:47:22 +0800 Subject: [PATCH] add debugging tool --- lang_agent/pipeline.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lang_agent/pipeline.py b/lang_agent/pipeline.py index aa55484..c6e84d1 100644 --- a/lang_agent/pipeline.py +++ b/lang_agent/pipeline.py @@ -106,15 +106,26 @@ class Pipeline: def get_ws_url(self): return f"ws://{self.config.host}:{self.config.port}" - def chat(self, inp:str): + def chat(self, inp:str, as_stream:bool=False): + """ + as_stream (bool): for debug only, gets the agent to print its thoughts + """ inp = {"messages":[HumanMessage(inp)]}, {"configurable": {"thread_id": 3}} + if as_stream: + for step in self.agent.stream(*inp, stream_mode="values"): + step["messages"][-1].pretty_print() + + return + out = self.invoke(*inp) return out['messages'][-1].content -if __name__ == "__main__": - pipeline:Pipeline = PipelineConfig().setup() +# if __name__ == "__main__": +# pipeline:Pipeline = PipelineConfig().setup() - print(pipeline.chat("I'm steve")) - print(pipeline.chat("what is my name?")) \ No newline at end of file + # print(pipeline.chat("I'm steve")) + # print(pipeline.chat("what is my name?")) + + # pipeline.chat("use the calculator tool to calculate what is 900 * 321", as_stream=True) \ No newline at end of file