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

design WebSearch Block #28

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { FC, SVGProps } from "react";

export const CircleCheckIcon: FC<SVGProps<SVGSVGElement>> = (props) => (
<svg
width="20"
height="21"
viewBox="0 0 20 21"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<g clip-path="url(#clip0_6417_28902)">
<path d="M9.90909 0.5C4.43636 0.5 0 4.93636 0 10.4091C0 15.8818 4.43636 20.3182 9.90909 20.3182C15.3818 20.3182 19.8182 15.8818 19.8182 10.4091C19.8182 4.93636 15.3818 0.5 9.90909 0.5ZM14.4727 8.18182L9.05455 13.6C8.92727 13.7273 8.75455 13.8 8.57273 13.8C8.39091 13.8 8.21818 13.7273 8.09091 13.6L5.35455 10.8636C5.09091 10.6 5.09091 10.1636 5.35455 9.9C5.61818 9.63636 6.05455 9.63636 6.31818 9.9L8.57273 12.1545L13.5091 7.21818C13.7727 6.95455 14.2091 6.95455 14.4727 7.21818C14.7364 7.48182 14.7364 7.91818 14.4727 8.18182Z" />
</g>
<defs>
<clipPath id="clip0_6417_28902">
<rect width="20" height="20" transform="translate(0 0.5)" />
</clipPath>
</defs>
</svg>
);
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export async function generateWebSearchStream(
title: searchResult.title,
url: searchResult.url,
status: "pending",
relevance: searchResult.score,
})),
};

Expand Down
2 changes: 2 additions & 0 deletions app/(playground)/p/[agentId]/beta-proto/web-search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ interface PendingWebSearchItemReference {
status: Extract<WebSearchStatus, "pending">;
title: string;
url: string;
relevance: number;
}
interface CompletedWebSearchItemReference {
id: WebSearchContentId;
Expand All @@ -54,6 +55,7 @@ interface CompletedWebSearchItemReference {
title: string;
contentBlobUrl: string;
url: string;
relevance: number;
}
export type WebSearchItemReference =
| PendingWebSearchItemReference
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { CopyIcon } from "lucide-react";
import { Dialog, DialogContent, DialogTrigger } from "../components/dialog";
import { CircleCheckIcon } from "../components/icons/circle-check";
import { DocumentIcon } from "../components/icons/document";
import { SpinnerIcon } from "../components/icons/spinner";
import { Block } from "../giselle-node/components/panel/block";
import type { GiselleNode } from "../giselle-node/types";
import { type WebSearch, webSearchStatus } from "./types";
import { type WebSearch, webSearchItemStatus, webSearchStatus } from "./types";

interface WebSearchBlockProps extends Partial<WebSearch> {
node: Pick<GiselleNode, "archetype" | "name">;
Expand Down Expand Up @@ -41,27 +42,43 @@ export function WebSearchBlock(props: WebSearchBlockProps) {
</div>
<div className="border-t border-black-40" />
<div className="overflow-x-hidden overflow-y-auto flex-1">
<div className="px-[32px] py-[16px] font-rosart text-[18px] text-black-30">
<table className="min-w-full divide-y divide-black-40">
<thead className="bg-black-10">
<div className="px-[16px] py-[16px] font-rosart text-[18px] text-black-30">
<table className="w-full divide-y divide-black-40 font-avenir border-separate border-spacing-[16px] text-left text-black-70 ">
<colgroup>
<col width="0%" />
<col width="100%" />
<col width="0%" />
</colgroup>
<thead className="font-[500] text-[12px]">
<tr>
<th className="px-4 py-2 text-left text-[16px] font-bold text-black-70">
Status
</th>
<th className="px-4 py-2 text-left text-[16px] font-bold text-black-70">
Content
</th>
<th className="px-4 py-2 text-left text-[16px] font-bold text-black-70">
URL
</th>
<th>Status</th>
<th>Content</th>
<th>Relevance</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-black-40">
<tbody className="">
{items.map((item) => (
<tr key={item.id}>
<td className="px-4 py-2 text-black-70">{item.status}</td>
<td className="px-4 py-2 text-black-70">{item.title}</td>
<td className="px-4 py-2 text-black-70">{item.url}</td>
<td>
{item.status === webSearchItemStatus.completed ? (
<CircleCheckIcon className="w-[20px] h-[20px] fill-green" />
) : (
""
)}
</td>
<td className="text-black-30 max-w-[1px]">
<p className="font-rosart text-[18px] underline truncate">
{item.title}
</p>
<p className="text-[12px] truncate">{item.url}</p>
</td>
<td className="text-green font-[900]">
{item.status === webSearchStatus.completed &&
Math.min(
0.99,
Number.parseFloat(item.relevance.toFixed(2)),
)}
</td>
</tr>
))}
</tbody>
Expand Down
1 change: 1 addition & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
--black_-30: 192 73% 84%;
--black_-50: 210 58% 71%;
--black_-70: 202 52% 46%;
--green: 142 100% 68%;

--white: 30 100% 98%;
}
Expand Down
3 changes: 3 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const config = {
white: {
DEFAULT: "hsl(var(--white))",
},
green: {
DEFAULT: "hsl(var(--green))",
},
rosepine: {
base: "hsl(var(--rosepine_base))",
surface: "hsl(var(--rosepine_surface))",
Expand Down