add cr reporter

This commit is contained in:
shenchucheng 2024-05-11 19:47:33 +08:00
parent 5c416a1f31
commit d0486f8e11
3 changed files with 18 additions and 8 deletions

View file

@ -131,7 +131,11 @@ class ResourceReporter(BaseModel):
def _format_data(self, value, name):
data = self.model_dump(mode="json", exclude=("callback_url", "llm_stream"))
data["value"] = str(value) if isinstance(value, Path) else value
if isinstance(value, BaseModel):
value = value.model_dump(mode="json")
elif isinstance(value, Path):
value = str(value)
data["value"] = value
data["name"] = name
role = CURRENT_ROLE.get(None)
if role:
@ -263,7 +267,7 @@ class FileReporter(ResourceReporter):
"""Report file resource synchronously."""
return super().report(value, name)
async def async_report(self, value: Path, name: Literal["path", "meta", "content"] = "path"):
async def async_report(self, value: Path, name: Literal["path", "meta", "content", "document"] = "path"):
"""Report file resource asynchronously."""
return await super().async_report(value, name)