Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dylan/s3en 2301 render images in trace for image generation #122

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 53 additions & 10 deletions components/shared/llm-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export const LLMView = ({
: prompt?.function_call
? prompt?.function_call
: "";

// will add once edit image wrapper has been added in sdks
// const url = prompt?.content?.url;
// const b64Json = prompt?.content?.b64_json;
// const revisedPrompt = prompt?.content?.revised_prompt;
return (
<div
key={i}
Expand Down Expand Up @@ -72,6 +77,10 @@ export const LLMView = ({
response?.text ||
"";

const url = response?.content?.url;
const b64Json = response?.content?.b64_json;
const revisedPrompt = response?.content?.revised_prompt;

return (
<div
key={i}
Expand All @@ -80,16 +89,50 @@ export const LLMView = ({
<span className="font-semibold dark:text-red-400 text-red-600 capitalize">
{role}
</span>
<div
className={cn(
doPiiDetection &&
typeof content === "string" &&
content !== "" &&
detectPII(content).length > 0 &&
"underline decoration-red-600 decoration-[3px]"
)}
dangerouslySetInnerHTML={{ __html: safeStringify(content) }}
/>
{!url && !b64Json && (
<div
className={cn(
doPiiDetection &&
typeof content === "string" &&
content !== "" &&
detectPII(content).length > 0 &&
"underline decoration-red-600 decoration-[3px]"
)}
dangerouslySetInnerHTML={{ __html: safeStringify(content) }}
/>
)}
{url && (
<div>
<a
href={url}
target="_blank"
rel="noopener noreferrer"
className="text-blue-500 underline"
>
View Image
</a>
<img
src={url}
alt="Generated Image"
className="mt-2 rounded"
/>
{revisedPrompt && (
<p className="mt-2 text-gray-700">{revisedPrompt}</p>
)}
</div>
)}
{b64Json && (
<div>
<img
src={`data:image/png;base64,${b64Json}`}
alt="Generated Image"
className="mt-2 rounded"
/>
{revisedPrompt && (
<p className="mt-2 text-gray-700">{revisedPrompt}</p>
)}
</div>
)}
{Evaluate && <Evaluate />}
</div>
);
Expand Down