Skip to content

Commit

Permalink
related prompts and image skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
rashadphz committed Jun 1, 2024
1 parent b6e80ab commit a186917
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/backend/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{context}
</context>
Your 3 follow-up questions:
Your EXACTLY 3 (three) follow-up questions:
"""

HISTORY_QUERY_REPHRASE = """
Expand Down
4 changes: 2 additions & 2 deletions src/backend/related_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ async def generate_related_queries(
query: str, search_results: list[SearchResult], model: ChatModel
) -> list[str]:
context = "\n\n".join([f"{str(result)}" for result in search_results])
# Truncate the context to 5000 characters (mainly for smaller models)
context = context[:5000]
# Truncate the context to 4000 characters (mainly for smaller models)
context = context[:4000]

client = instructor_client(model)
model_name = model_mappings[model]
Expand Down
22 changes: 5 additions & 17 deletions src/frontend/src/components/assistant-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SearchResultsSkeleton, SearchResults } from "./search-results";
import { Section } from "./section";
import { AlertCircle } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { ImageSection, ImageSectionSkeleton } from "./image-section";

export function ErrorMessage({ content }: { content: string }) {
return (
Expand Down Expand Up @@ -73,23 +74,10 @@ export const AssistantMessageContent = ({
)}
</Section>
<Section title="Images" animate={isStreaming}>
{images && images.length > 0 && (
<div className="my-4 grid grid-cols-1 gap-2 lg:grid-cols-2">
{images.map((image) => (
<a
key={image}
href={image}
target="_blank"
rel="noopener noreferrer"
className="aspect-video w-full h-full overflow-hidden hover:scale-[1.03] duration-150 rounded-lg transition-all shadow-md"
>
<img
src={image}
className="w-full object-cover object-top h-full max-h-[80vh]"
/>
</a>
))}
</div>
{images && images.length > 0 ? (
<ImageSection images={images} />
) : (
<ImageSectionSkeleton />
)}
</Section>
{relatedQuestions && relatedQuestions.length > 0 && (
Expand Down
41 changes: 41 additions & 0 deletions src/frontend/src/components/image-section.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable @next/next/no-img-element */
"use client";
import { Skeleton } from "./ui/skeleton";

export const ImageSectionSkeleton = () => {
return (
<>
<div className="my-4 grid grid-cols-1 gap-2 lg:grid-cols-2 w-full">
{[...Array(4)].map((_, index) => (
<div className="w-full h-full" key={`image-skeleton-${index}`}>
<Skeleton className="rounded-md object-cover shadow-none border-none w-full bg-card h-[160px] " />
</div>
))}
</div>
</>
);
};

export function ImageSection({ images }: { images: string[] }) {
if (images && images.length > 0) {
return (
<div className="my-4 grid grid-cols-1 gap-2 lg:grid-cols-2">
{images.map((image) => (
<a
key={image}
href={image}
target="_blank"
rel="noopener noreferrer"
className="aspect-video w-full h-full overflow-hidden hover:scale-[1.03] duration-150 rounded-lg transition-all shadow-md"
>
<img
src={image}
className="w-full object-cover object-top h-full max-h-[80vh]"
/>
</a>
))}
</div>
);
}
return null;
}

0 comments on commit a186917

Please sign in to comment.