Fix:The OpenAI-Compatible Agent API returns an incorrect message (#8177)

### What problem does this PR solve?

https://github.com/infiniflow/ragflow/issues/8175

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Stephen Hu
2025-06-12 19:17:15 +08:00
committed by GitHub
parent 24ca4cc6b7
commit 1ab0f52832
4 changed files with 28 additions and 5 deletions

View File

@ -169,6 +169,7 @@ class Canvas:
def run(self, running_hint_text = "is running...🕞", **kwargs):
if not running_hint_text or not isinstance(running_hint_text, str):
running_hint_text = "is running...🕞"
bypass_begin = bool(kwargs.get("bypass_begin", False))
if self.answer:
cpn_id = self.answer[0]
@ -188,6 +189,12 @@ class Canvas:
if not self.path:
self.components["begin"]["obj"].run(self.history, **kwargs)
self.path.append(["begin"])
if bypass_begin:
cpn = self.get_component("begin")
downstream = cpn["downstream"]
self.path.append(downstream)
self.path.append([])

View File

@ -64,14 +64,17 @@ class Answer(ComponentBase, ABC):
for ii, row in stream.iterrows():
answer += row.to_dict()["content"]
yield {"content": answer}
else:
elif stream is not None:
for st in stream():
res = st
yield st
if self._param.post_answers:
if self._param.post_answers and res:
res["content"] += random.choice(self._param.post_answers)
yield res
if res is None:
res = {"content": ""}
self.set_output(res)
def set_exception(self, e):

View File

@ -442,7 +442,6 @@ class ComponentBase(ABC):
elif q.get("value"):
outs.append(pd.DataFrame([{"content": q["value"]}]))
return outs
def get_input(self):
if self._param.debug_inputs:
return pd.DataFrame([{"content": v["value"]} for v in self._param.debug_inputs if v.get("value")])