Skip to content

Commit

Permalink
Clear search on close
Browse files Browse the repository at this point in the history
  • Loading branch information
itaismith committed Dec 21, 2024
1 parent 133032e commit e4a29f6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
30 changes: 15 additions & 15 deletions docs/docs.trychroma.com/app/api/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ import { ChromaClient } from "chromadb";
// @ts-ignore
import { Collection } from "chromadb/src/Collection";

const chromaClient = new ChromaClient({
path: "https://api.trychroma.com:8000",
auth: {
provider: "token",
credentials: process.env.CHROMA_CLOUD_API_KEY,
tokenHeaderType: "X_CHROMA_TOKEN",
},
tenant: process.env.CHROMA_CLOUD_TENANT,
database: "docs",
});

const collection: Collection = await chromaClient.getOrCreateCollection({
name: "docs-content",
});

export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
Expand All @@ -15,21 +30,6 @@ export async function GET(request: Request) {
);
}

const chromaClient = new ChromaClient({
path: "https://api.trychroma.com:8000",
auth: {
provider: "token",
credentials: process.env.CHROMA_CLOUD_API_KEY,
tokenHeaderType: "X_CHROMA_TOKEN",
},
tenant: process.env.CHROMA_CLOUD_TENANT,
database: "docs",
});

const collection: Collection = await chromaClient.getOrCreateCollection({
name: "docs-content",
});

let results: {
distance: number;
title: string;
Expand Down
22 changes: 17 additions & 5 deletions docs/docs.trychroma.com/components/header/search-docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ const SearchDocs: React.FC = () => {
}, [query]);

return (
<Dialog>
<Dialog
onOpenChange={(open) => {
if (!open) {
setQuery("");
}
}}
>
<DialogTrigger asChild>
<UIButton className="lex items-center gap-2 p-[0.35rem] px-3 text-xs">
<MagnifyingGlassIcon className="w-4 h-4" />
Expand Down Expand Up @@ -132,10 +138,16 @@ const SearchDocs: React.FC = () => {
)}
</div>
<div className="flex justify-end py-2 px-4 border-t border-black">
<div className="flex items-center gap-2">
<ChromaIcon className="h-7 w-7" />
<p className="text-xs font-semibold">Powered by Chroma Cloud</p>
</div>
<Link
href="https://airtable.com/appG6DhLoDUnTawwh/shrOAiDUtS2ILy5vZ"
target="_blank"
rel="noopener noreferrer"
>
<div className="flex items-center gap-2">
<ChromaIcon className="h-7 w-7" />
<p className="text-xs font-semibold">Powered by Chroma Cloud</p>
</div>
</Link>
</div>
</DialogContent>
</Dialog>
Expand Down

0 comments on commit e4a29f6

Please sign in to comment.