MCPcopy Create free account
hub / github.com/chenfei-wu/TaskMatrix / run_text

Method run_text

visual_chatgpt.py:1518–1526  ·  view source on GitHub ↗
(self, text, state)

Source from the content-addressed store, hash-verified

1516 return gr.update(visible = True), gr.update(visible = False), gr.update(placeholder=place), gr.update(value=label_clear)
1517
1518 def run_text(self, text, state):
1519 self.agent.memory.buffer = cut_dialogue_history(self.agent.memory.buffer, keep_last_n_words=500)
1520 res = self.agent({"input": text.strip()})
1521 res['output'] = res['output'].replace("\\", "/")
1522 response = re.sub('(image/[-\w]*.png)', lambda m: f'![](file={m.group(0)})*{m.group(0)}*', res['output'])
1523 state = state + [(text, response)]
1524 print(f"\nProcessed run_text, Input text: {text}\nCurrent state: {state}\n"
1525 f"Current Memory: {self.agent.memory.buffer}")
1526 return state, state
1527
1528 def run_image(self, image, state, txt, lang):
1529 image_filename = os.path.join('image', f"{str(uuid.uuid4())[:8]}.png")

Callers

nothing calls this directly

Calls 1

cut_dialogue_historyFunction · 0.85

Tested by

no test coverage detected