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

Compatibility fixes for SDK version 2.0.0 #69

Merged
merged 18 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b178105
Pagination bug
karthikscale3 Apr 4, 2024
af47e53
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 4, 2024
cc6ab77
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 4, 2024
677b1aa
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 4, 2024
f996899
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 4, 2024
0e963e2
Bug fix
karthikscale3 Apr 5, 2024
f3a8a23
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 5, 2024
3c353a5
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 5, 2024
94f0fb1
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 7, 2024
f22f397
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 8, 2024
5023d1f
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 9, 2024
4178d5c
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 11, 2024
4fe4108
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 13, 2024
784f09c
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 14, 2024
42f1128
Merge branch 'development' of github.com:Scale3-Labs/langtrace into d…
karthikscale3 Apr 19, 2024
a43231b
Merge branch 'development' of github.com:Scale3-Labs/langtrace into k…
karthikscale3 Apr 24, 2024
e81f77d
Fix for schema changes
karthikscale3 Apr 24, 2024
5d15e10
Render tool calling
karthikscale3 Apr 24, 2024
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
109 changes: 65 additions & 44 deletions app/(protected)/project/[project_id]/evaluations/[test_id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { ScaleType } from "@/components/evaluations/eval-scale-picker";
import { RangeScale } from "@/components/evaluations/range-scale";
import UserLogo from "@/components/shared/user-logo";
import { VendorLogo } from "@/components/shared/vendor-metadata";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
Expand All @@ -10,6 +11,7 @@ import {
cn,
extractSystemPromptFromLlmInputs,
formatDateTime,
safeStringify,
} from "@/lib/utils";
import { Cross1Icon, EnterIcon } from "@radix-ui/react-icons";
import { ProgressCircle } from "@tremor/react";
Expand All @@ -23,7 +25,6 @@ import {
} from "lucide-react";
import { useParams, useRouter, useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";
import Markdown from "react-markdown";
import { useQuery, useQueryClient } from "react-query";
import { toast } from "sonner";

Expand Down Expand Up @@ -315,7 +316,7 @@ export default function Page() {
size="md"
value={(page / totalPages) * 100}
>
<span className="flex items-center justify-center font-semibold w-12 h-12 rounded-full bg-blue-100 text-xs">
<span className="flex items-center justify-center font-bold w-12 h-12 rounded-full bg-blue-100 dark:bg-blue-800 text-sm">
{Math.round((page / totalPages) * 100)}%
</span>
</ProgressCircle>
Expand Down Expand Up @@ -348,8 +349,8 @@ export default function Page() {
className={cn(
"ml-2 text-xs px-1 py-[2px] rounded-md",
evaluationsData?.evaluations[0]?.id
? "bg-green-400"
: "bg-orange-400"
? "bg-green-400 dark:bg-green-800"
: "bg-orange-400 dark:bg-orange-800"
)}
>
{evaluationsData?.evaluations[0]?.id
Expand Down Expand Up @@ -474,49 +475,69 @@ function ConversationView({ span }: { span: any }) {
if (!prompts && !responses) return <p className="text-md">No data found</p>;

return (
<div className="flex flex-col gap-12 overflow-y-scroll w-1/2 pr-6">
<div className="flex flex-col gap-8 overflow-y-scroll w-1/2 pr-6">
{prompts?.length > 0 &&
JSON.parse(prompts).map((prompt: any, i: number) => (
<div key={i} className="flex flex-col gap-1">
<p className="font-semibold text-md capitalize">
{prompt?.role
? prompt?.role === "function"
? `${prompt?.role} - ${prompt?.name}`
: prompt?.role
: "Input"}
:
{prompt?.content
? " (content)"
: prompt?.function_call
? " (function call)"
: ""}
</p>{" "}
<Markdown className="text-sm">
{prompt?.content
? prompt?.content
: prompt?.function_call
? JSON.stringify(prompt?.function_call)
: "No input found"}
</Markdown>
</div>
))}
JSON.parse(prompts).map((prompt: any, i: number) => {
const role = prompt?.role ? prompt?.role?.toLowerCase() : "User";
const content = prompt?.content
? safeStringify(prompt?.content)
: prompt?.function_call
? safeStringify(prompt?.function_call)
: "No input found";
return (
<div key={i} className="flex flex-col gap-2">
<div className="flex gap-2 items-center">
{role === "user" ? (
<UserLogo />
) : (
<VendorLogo variant="circular" span={span} />
)}
<p className="font-semibold text-md capitalize">{role}</p>
{role === "system" && (
<p className="font-semibold text-xs capitalize p-1 rounded-md bg-muted">
Prompt
</p>
)}
</div>
<div
className="text-sm bg-muted rounded-md px-2 py-4"
dangerouslySetInnerHTML={{
__html: content,
}}
/>
</div>
);
})}
{responses?.length > 0 &&
JSON.parse(responses).map((response: any, i: number) => (
<div className="flex flex-col gap-1" key={i}>
<div className="flex gap-2">
<VendorLogo span={span} />
<p className="font-semibold text-md capitalize">
{response?.message?.role || "Output"}:
</p>{" "}
JSON.parse(responses).map((response: any, i: number) => {
const role =
response?.role?.toLowerCase() ||
response?.message?.role ||
"Assistant";
const content =
safeStringify(response?.content) ||
safeStringify(response?.message?.content) ||
safeStringify(response?.text) ||
"No output found";
return (
<div className="flex flex-col gap-2" key={i}>
<div className="flex gap-2 items-center">
{role === "user" ? (
<UserLogo />
) : (
<VendorLogo variant="circular" span={span} />
)}
<p className="font-semibold text-md capitalize">{role}</p>
</div>
<div
className="text-sm bg-muted rounded-md px-2 py-4"
dangerouslySetInnerHTML={{
__html: content,
}}
/>
</div>
<Markdown className="text-sm">
{response?.message?.content ||
response?.text ||
response?.content ||
"No output found"}
</Markdown>
</div>
))}
);
})}
</div>
);
}
Expand Down
14 changes: 4 additions & 10 deletions components/evaluations/evaluation-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,12 @@ export default function EvaluationRow({
</div>
<p className="text-xs font-medium">{model}</p>
<HoverCell
className="text-xs h-10 truncate overflow-y-scroll font-semibold col-span-2"
value={prompts?.length > 0 ? JSON.parse(prompts)[0]?.content : ""}
className="flex items-center text-xs h-10 truncate overflow-y-scroll font-semibold col-span-2"
values={prompts?.length > 0 ? JSON.parse(prompts) : []}
/>
<HoverCell
className="text-xs h-10 truncate overflow-y-scroll font-semibold col-span-2"
value={
responses?.length > 0
? JSON.parse(responses)[0]?.message?.content ||
JSON.parse(responses)[0]?.text ||
JSON.parse(responses)[0]?.content
: ""
}
className="flex items-center text-xs h-10 truncate overflow-y-scroll font-semibold col-span-2"
values={responses?.length > 0 ? JSON.parse(responses) : []}
/>
<p className="text-xs font-semibold">
{cost.total.toFixed(6) !== "0.000000"
Expand Down
14 changes: 4 additions & 10 deletions components/project/traces/trace-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,12 @@ export const TraceRow = ({
</div>
<p className="text-xs font-semibold">{model}</p>
<HoverCell
value={prompts?.length > 0 ? JSON.parse(prompts)[0]?.content : ""}
className="max-w-fit text-xs h-10 truncate overflow-y-scroll font-semibold col-span-2"
values={prompts?.length > 0 ? JSON.parse(prompts) : []}
className="flex items-center max-w-fit text-xs h-10 truncate overflow-y-scroll font-semibold col-span-2"
/>
<HoverCell
value={
responses?.length > 0
? JSON.parse(responses)[0]?.message?.content ||
JSON.parse(responses)[0]?.text ||
JSON.parse(responses)[0]?.content
: ""
}
className="max-w-fit text-xs h-10 truncate overflow-y-scroll font-semibold col-span-2"
values={responses?.length > 0 ? JSON.parse(responses) : []}
className="flex items-center max-w-fit text-xs h-10 truncate overflow-y-scroll font-semibold col-span-2"
/>
<p className="text-xs font-semibold">{userId}</p>
<p className="text-xs">
Expand Down
49 changes: 44 additions & 5 deletions components/shared/hover-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,61 @@ import {
HoverCardContent,
HoverCardTrigger,
} from "@/components/ui/hover-card";
import Markdown from "react-markdown";
import { safeStringify } from "@/lib/utils";

export function HoverCell({
value,
values,
className,
}: {
value: string;
values: any[];
className?: string;
}) {
const contents = values.map((value, i) => {
const role = value?.role
? value?.role?.toLowerCase()
: value?.message?.role
? value?.message?.role
: "User";
const content = value?.content
? safeStringify(value?.content)
: value?.function_call
? safeStringify(value?.function_call)
: value?.message?.content
? safeStringify(value?.message?.content)
: value?.text
? safeStringify(value?.text)
: "";
return { role, content };
});

if (contents.length === 0) {
return null;
}

return (
<HoverCard>
<HoverCardTrigger asChild>
<button className={className}>{value}</button>
<div
className={className}
dangerouslySetInnerHTML={{
__html: contents[contents.length - 1].content,
}}
/>
</HoverCardTrigger>
<HoverCardContent className="w-[40rem] max-h-[20rem] p-4 overflow-y-scroll whitespace-pre-wrap text-sm">
<Markdown className="break-all">{value}</Markdown>
<div className="flex flex-col gap-4">
{contents.map((item, i) => (
<div key={i} className="flex flex-col gap-1">
<p className="font-semibold capitalize text-xs rounded-md p-1 bg-muted w-fit">
{item.role}
</p>
<div
className="break-all text-xs"
dangerouslySetInnerHTML={{ __html: item.content }}
/>
</div>
))}
</div>
</HoverCardContent>
</HoverCard>
);
Expand Down
Loading