Skip to content

Commit e70d208

Browse files
karthikscale3darshit-s3rohit-kadhedylanzuber-scale3
authored
Release (#23)
* Bug fix * signup bug fix * user invite * docs: add local setup instructions, cleanup files (#10) * Update README.md (#11) * Update README.md * Update README.md * Update README.md * Bugfix auth (#12) * Update README.md * Update favicon (#17) * Release 1.0.3 (#8) * Bug fix * signup bug fix * user invite * favicon * Adding pagination to traces (#16) * Adding pagination to traces * installing scroller * query function bug * fix * Bug fix pagination --------- Co-authored-by: Karthik Kalyanaraman <[email protected]> * Dylan/s3en 2060 adding more frontend pagination (#18) * Adding pagination to traces * installing scroller * bug fixes for trace pagination * adding delete prompt api * adding pagination to evaluate * adding pagination to evals * adding pagination to prompset, bug fixes * adding .env * fix --------- Co-authored-by: Karthik Kalyanaraman <[email protected]> * updating prompt dialog (#19) * Show API key warning message (#20) * Show API key warning message * Update instructions * Fix null dereference checks (#21) * adding check for missing table (#22) * adding check for missing table * adding docs button * Check empty table --------- Co-authored-by: Karthik Kalyanaraman <[email protected]> --------- Co-authored-by: darshit-s3 <[email protected]> Co-authored-by: Rohit Kadhe <[email protected]> Co-authored-by: dylanzuber-scale3 <[email protected]>
1 parent 51b5fb1 commit e70d208

File tree

16 files changed

+184
-81
lines changed

16 files changed

+184
-81
lines changed

app/(protected)/project/[project_id]/datasets/promptset/[promptset_id]/page.tsx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import { CreatePrompt } from "@/components/project/dataset/create-data";
44
import { EditPrompt } from "@/components/project/dataset/edit-data";
5+
import { Spinner } from "@/components/shared/spinner";
56
import { Button } from "@/components/ui/button";
67
import { Separator } from "@/components/ui/separator";
78
import { ChevronLeft } from "lucide-react";
89
import { useParams } from "next/navigation";
9-
import { useQuery } from "react-query";
1010
import { useState } from "react";
11-
import { useBottomScrollListener } from 'react-bottom-scroll-listener';
12-
import { Spinner } from '@/components/shared/spinner';
11+
import { useBottomScrollListener } from "react-bottom-scroll-listener";
12+
import { useQuery } from "react-query";
1313

1414
export default function Promptset() {
1515
const promptset_id = useParams()?.promptset_id as string;
@@ -39,19 +39,22 @@ export default function Promptset() {
3939
return result;
4040
},
4141
onSuccess: (result) => {
42-
if (totalPages !== result.metadata.total_pages) {
43-
setTotalPages(result.metadata.total_pages);
42+
if (totalPages !== result?.metadata?.total_pages) {
43+
setTotalPages(result?.metadata?.total_pages);
4444
}
4545
if (result) {
4646
if (data) {
47-
setData((prevData: any) => [...prevData, ...result.promptsets.Prompt]);
47+
setData((prevData: any) => [
48+
...prevData,
49+
...result.promptsets.Prompt,
50+
]);
4851
} else {
4952
setData(result.promptsets.Prompt);
5053
}
5154
}
5255
setPage((currentPage) => currentPage + 1);
5356
setShowLoader(false);
54-
}
57+
},
5558
});
5659

5760
if (fetchPromptset.isLoading || !fetchPromptset.data || !data) {
@@ -82,29 +85,24 @@ export default function Promptset() {
8285
</div>
8386
)}
8487
{fetchPromptset.data?.promptsets &&
85-
data.map(
86-
(prompt: any, i: number) => {
87-
return (
88-
<div className="flex flex-col" key={i}>
89-
<div className="grid grid-cols-5 items-start justify-stretch gap-3 py-3 px-4">
90-
<p className="text-xs">{prompt.createdAt}</p>
91-
<p className="text-xs">{prompt.value}</p>
92-
<p className="text-xs text-end">{prompt.note}</p>
93-
<div className="text-end">
94-
<EditPrompt
95-
prompt={prompt}
96-
promptSetId={promptset_id}
97-
/>
98-
</div>
88+
data.map((prompt: any, i: number) => {
89+
return (
90+
<div className="flex flex-col" key={i}>
91+
<div className="grid grid-cols-5 items-start justify-stretch gap-3 py-3 px-4">
92+
<p className="text-xs">{prompt.createdAt}</p>
93+
<p className="text-xs">{prompt.value}</p>
94+
<p className="text-xs text-end">{prompt.note}</p>
95+
<div className="text-end">
96+
<EditPrompt prompt={prompt} promptSetId={promptset_id} />
9997
</div>
100-
<Separator orientation="horizontal" />
10198
</div>
102-
);
103-
}
104-
)}
105-
{showLoader && (
106-
<div className='flex justify-center py-8'>
107-
<Spinner className='h-8 w-8 text-center' />
99+
<Separator orientation="horizontal" />
100+
</div>
101+
);
102+
})}
103+
{showLoader && (
104+
<div className="flex justify-center py-8">
105+
<Spinner className="h-8 w-8 text-center" />
108106
</div>
109107
)}
110108
</div>

components/apiKey/api-dialog.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export function ApiKeyDialog({
3636
<DialogContent className="sm:max-w-[580px]">
3737
<DialogHeader>
3838
<DialogTitle>Generate API Key</DialogTitle>
39-
<DialogDescription>
40-
Note: If you already have an API key, it will be replaced.
39+
<DialogDescription className="text-red-600 font-bold">
40+
Note: Click to copy this API key as it will NOT be shown again. If
41+
you already have an API key, it will be replaced.
4142
</DialogDescription>
4243
{apiKey && (
4344
<div className="flex items-center bg-muted p-2 rounded-md justify-between">

components/project/create.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export function Create({
8080
description: "Your project has been created.",
8181
});
8282
setOpen(false);
83+
CreateProjectForm.reset();
8384
} catch (error: any) {
8485
toast("Error creating your project!", {
8586
description: `There was an error creating your project: ${error.message}`,

components/project/dataset/create-data.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
FormLabel,
1818
FormMessage,
1919
} from "@/components/ui/form";
20-
import { Input } from "@/components/ui/input";
20+
import { Input, InputLarge } from "@/components/ui/input";
2121
import { zodResolver } from "@hookform/resolvers/zod";
2222
import { PlusIcon } from "@radix-ui/react-icons";
2323
import { useState } from "react";
@@ -86,6 +86,7 @@ export function CreateData({
8686
description: "Your data has been added.",
8787
});
8888
setOpen(false);
89+
CreateDataForm.reset();
8990
} catch (error: any) {
9091
toast("Error added your data!", {
9192
description: `There was an error added your data: ${error.message}`,
@@ -225,6 +226,7 @@ export function CreatePrompt({
225226
description: "Your prompt has been added.",
226227
});
227228
setOpen(false);
229+
CreatePromptsetForm.reset();
228230
} catch (error: any) {
229231
toast("Error creating your prompt!", {
230232
description: `There was an error creating your prompt: ${error.message}`,
@@ -249,8 +251,9 @@ export function CreatePrompt({
249251
/>
250252
</FormLabel>
251253
<FormControl>
252-
<Input
254+
<InputLarge
253255
placeholder="You are a documentation writer. Answer in a courteous manner."
256+
// className="w-full h-20"
254257
{...field}
255258
/>
256259
</FormControl>

components/project/dataset/create.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export function CreateDataset({
8383
description: "Your dataset has been created.",
8484
});
8585
setOpen(false);
86+
CreateDatasetForm.reset();
8687
} catch (error: any) {
8788
toast("Error creating your dataset!", {
8889
description: `There was an error creating your dataset: ${error.message}`,
@@ -210,6 +211,7 @@ export function CreatePromptset({
210211
description: "Your promptset has been created.",
211212
});
212213
setOpen(false);
214+
CreatePromptsetForm.reset();
213215
} catch (error: any) {
214216
toast("Error creating your promptset!", {
215217
description: `There was an error creating your promptset: ${error.message}`,

components/project/dataset/edit-data.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ import { useForm } from "react-hook-form";
3333
import { useQueryClient } from "react-query";
3434
import { toast } from "sonner";
3535
import { z } from "zod";
36-
import { useBottomScrollListener } from 'react-bottom-scroll-listener';
37-
import { Spinner } from '@/components/shared/spinner';
3836

3937
export function EditData({
4038
idata,
@@ -139,6 +137,7 @@ export function EditData({
139137
description: "Your data has been saved.",
140138
});
141139
setOpen(false);
140+
EditDataForm.reset();
142141
} catch (error: any) {
143142
toast("Error saving your dataset!", {
144143
description: `There was an error saving your dataset: ${error.message}`,
@@ -371,6 +370,7 @@ export function EditPrompt({
371370
description: "Your prompt has been saved.",
372371
});
373372
setOpen(false);
373+
EditPromptSetForm.reset();
374374
} catch (error: any) {
375375
toast("Error saving your prompt!", {
376376
description: `There was an error saving your prompt: ${error.message}`,

components/project/dataset/edit.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export function EditDataSet({
134134
description: "Your dataset has been saved.",
135135
});
136136
setOpen(false);
137+
EditDataSetForm.reset();
137138
} catch (error: any) {
138139
toast("Error saving your dataset!", {
139140
description: `There was an error saving your dataset: ${error.message}`,
@@ -347,6 +348,7 @@ export function EditPromptSet({
347348
description: "Your promptset has been saved.",
348349
});
349350
setOpen(false);
351+
EditPromptSetForm.reset();
350352
} catch (error: any) {
351353
toast("Error saving your promptset!", {
352354
description: `There was an error saving your promptset: ${error.message}`,

components/project/edit.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ export function Edit({
228228
<DialogContent className="sm:max-w-[620px]">
229229
<DialogHeader>
230230
<DialogTitle>Generate API Key</DialogTitle>
231-
<DialogDescription>
232-
Note: If you already have an API key, it will be replaced.
231+
<DialogDescription className="text-red-600 font-bold">
232+
Note: Click to copy this API key as it will NOT be shown again. If
233+
you already have an API key, it will be replaced.
233234
</DialogDescription>
234235
{apiKey && (
235236
<div className="flex items-center bg-muted p-2 rounded-md justify-between">

components/project/eval/eval.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import { CheckCircledIcon, DotFilledIcon } from "@radix-ui/react-icons";
1515
import { ChevronDown, ChevronRight, ThumbsDown, ThumbsUp } from "lucide-react";
1616
import { useParams } from "next/navigation";
1717
import { useState } from "react";
18+
import { useBottomScrollListener } from "react-bottom-scroll-listener";
1819
import Markdown from "react-markdown";
1920
import { useQuery, useQueryClient } from "react-query";
2021
import SetupInstructions from "../../shared/setup-instructions";
22+
import { Spinner } from "../../shared/spinner";
2123
import { Button } from "../../ui/button";
2224
import { Separator } from "../../ui/separator";
23-
import { useBottomScrollListener } from 'react-bottom-scroll-listener';
24-
import { Spinner } from '../../shared/spinner';
2525

2626
interface CheckedData {
2727
input: string;
@@ -49,14 +49,16 @@ export default function Eval({ email }: { email: string }) {
4949
const fetchPrompts = useQuery({
5050
queryKey: ["fetch-prompts-query"],
5151
queryFn: async () => {
52-
const response = await fetch(`/api/prompt?projectId=${project_id}&page=${page}&pageSize=${pageSize}`);
52+
const response = await fetch(
53+
`/api/prompt?projectId=${project_id}&page=${page}&pageSize=${pageSize}`
54+
);
5355
const result = await response.json();
5456
return result;
5557
},
5658
onSuccess: (result) => {
5759
// Only update data if result.result is not empty
58-
if (totalPages !== result.prompts.metadata.total_pages) {
59-
setTotalPages(result.prompts.metadata.total_pages);
60+
if (totalPages !== result?.prompts?.metadata?.total_pages) {
61+
setTotalPages(result?.prompts?.metadata?.total_pages);
6062
}
6163
if (result) {
6264
if (data) {
@@ -119,22 +121,20 @@ export default function Eval({ email }: { email: string }) {
119121
</div>
120122
);
121123
})}
122-
{showLoader && (
123-
<div className='flex justify-center py-8'>
124-
<Spinner className='h-8 w-8 text-center' />
125-
</div>
126-
)}
127-
{!fetchPrompts.isLoading &&
128-
fetchPrompts.data &&
129-
!fetchPrompts.data?.prompts?.result && (
130-
<div className="flex flex-col gap-3 items-center justify-center p-4">
131-
<p className="text-muted-foreground text-sm mb-3">
132-
No prompts available. Get started by setting up Langtrace in
133-
your application.
134-
</p>
135-
<SetupInstructions project_id={project_id} />
136-
</div>
137-
)}
124+
{showLoader && (
125+
<div className="flex justify-center py-8">
126+
<Spinner className="h-8 w-8 text-center" />
127+
</div>
128+
)}
129+
{!fetchPrompts.isLoading && fetchPrompts.data && data.length === 0 && (
130+
<div className="flex flex-col gap-3 items-center justify-center p-4">
131+
<p className="text-muted-foreground text-sm mb-3">
132+
No prompts available. Get started by setting up Langtrace in your
133+
application.
134+
</p>
135+
<SetupInstructions project_id={project_id} />
136+
</div>
137+
)}
138138
</div>
139139
</div>
140140
);

components/project/eval/prompts.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { CheckCircledIcon } from "@radix-ui/react-icons";
77
import { ChevronDown, ChevronRight } from "lucide-react";
88
import { useParams } from "next/navigation";
99
import { useState } from "react";
10+
import { useBottomScrollListener } from "react-bottom-scroll-listener";
1011
import Markdown from "react-markdown";
1112
import { useQuery } from "react-query";
13+
import { Spinner } from "../../shared/spinner";
1214
import { Button } from "../../ui/button";
1315
import { Separator } from "../../ui/separator";
14-
import { useBottomScrollListener } from 'react-bottom-scroll-listener';
15-
import { Spinner } from '../../shared/spinner';
1616

1717
interface CheckedData {
1818
value: string;
@@ -39,14 +39,16 @@ export default function Prompts({ email }: { email: string }) {
3939
const fetchPrompts = useQuery({
4040
queryKey: ["fetch-prompts-query"],
4141
queryFn: async () => {
42-
const response = await fetch(`/api/prompt?projectId=${project_id}&page=${page}&pageSize=${pageSize}`);
42+
const response = await fetch(
43+
`/api/prompt?projectId=${project_id}&page=${page}&pageSize=${pageSize}`
44+
);
4345
const result = await response.json();
4446
return result;
4547
},
4648
onSuccess: (result) => {
4749
// Only update data if result.result is not empty
48-
if (totalPages !== result.prompts.metadata.total_pages) {
49-
setTotalPages(result.prompts.metadata.total_pages);
50+
if (totalPages !== result?.prompts?.metadata?.total_pages) {
51+
setTotalPages(result?.prompts?.metadata?.total_pages);
5052
}
5153
if (result) {
5254
if (data) {
@@ -122,8 +124,8 @@ export default function Prompts({ email }: { email: string }) {
122124
);
123125
})}
124126
{showLoader && (
125-
<div className='flex justify-center py-8'>
126-
<Spinner className='h-8 w-8 text-center' />
127+
<div className="flex justify-center py-8">
128+
<Spinner className="h-8 w-8 text-center" />
127129
</div>
128130
)}
129131
{dedupedPrompts?.length === 0 && (

0 commit comments

Comments
 (0)