cloudflare / cloudflare/agents

Support json-render in Think

Open
#1,519 2 comments 0 reactions 1 assignee Claimed by @aron-cf View on GitHub
enhancement think
Dominant language
TypeScript
Stars
5.6k
Forks
711
Avg merge
1d 20h
Merged PRs (30d)
53

Description

[JSON-render](https://json-render.dev/) allows for generative UI and I _think_ it would be a good fit for Think. I managed to get it working by overriding `_transformInferenceResult` but it's a little ugly and I'm nervous about depending on a method that seems to be internal and only used for testing. Also the types don't seem right, but it does work:

```typescript
protected _transformInferenceResult(
result: StreamableResult,
): StreamableResult {
return {
toUIMessageStream(options) {
const stream = createUIMessageStream({
execute: async ({ writer }) => {
writer.merge(pipeJsonRender(result.toUIMessageStream() as any));
},
});
return stream as unknown as AsyncIterable;
},
};
}
```

It would be great if there was better support for this, or to understand whether there's an alternative approach that might fit the Think philosophy better?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.