Skip to content

Commit 94eeef3

Browse files
committed
chore: remove unused initial report suggestions
1 parent b027990 commit 94eeef3

File tree

2 files changed

+1
-134
lines changed

2 files changed

+1
-134
lines changed

apps/postgres-new/components/chat.tsx

+1-72
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Button } from '~/components/ui/button'
2121
import { Skeleton } from '~/components/ui/skeleton'
2222
import { TablesData } from '~/data/tables/tables-query'
2323
import { saveFile } from '~/lib/files'
24-
import { useAutoScroll, useReportSuggestions } from '~/lib/hooks'
24+
import { useAutoScroll } from '~/lib/hooks'
2525
import { cn } from '~/lib/utils'
2626
import { AiIconAnimation } from './ai-icon-animation'
2727
import ChatMessage from './chat-message'
@@ -189,9 +189,6 @@ export default function Chat() {
189189
stopReply,
190190
} = useWorkspace()
191191

192-
const [brainstormIdeas] = useState(false) // temporarily turn off for now
193-
const { reports } = useReportSuggestions({ enabled: brainstormIdeas })
194-
195192
const { input, setInput, handleInputChange, isLoading } = useChat({
196193
id: databaseId,
197194
api: '/api/chat',
@@ -406,74 +403,6 @@ export default function Chat() {
406403
>
407404
What would you like to create?
408405
</m.h3>
409-
<div>
410-
{brainstormIdeas && (
411-
<>
412-
{reports ? (
413-
<m.div
414-
className="flex flex-row gap-6 flex-wrap justify-center items-start"
415-
variants={{
416-
show: {
417-
transition: {
418-
staggerChildren: 0.05,
419-
},
420-
},
421-
}}
422-
initial="hidden"
423-
animate="show"
424-
>
425-
{reports.map((report) => (
426-
<m.div
427-
key={report.name}
428-
layoutId={`report-suggestion-${report.name}`}
429-
className="w-64 h-32 flex flex-col overflow-ellipsis rounded-md cursor-pointer"
430-
onMouseDown={() =>
431-
appendMessage({ role: 'user', content: report.description })
432-
}
433-
variants={{
434-
hidden: { scale: 0 },
435-
show: { scale: 1 },
436-
}}
437-
>
438-
<div className="p-4 bg-neutral-200 text-sm rounded-t-md text-neutral-600 font-bold text-center">
439-
{report.name}
440-
</div>
441-
<div className="flex-1 p-4 flex flex-col justify-center border border-neutral-200 text-neutral-500 text-xs font-normal italic rounded-b-md text-center overflow-hidden">
442-
{report.description}
443-
</div>
444-
</m.div>
445-
))}
446-
</m.div>
447-
) : (
448-
<m.div
449-
className="flex flex-row gap-4 justify-center items-center"
450-
variants={{
451-
hidden: {
452-
opacity: 0,
453-
y: -10,
454-
},
455-
show: {
456-
opacity: 1,
457-
y: 0,
458-
transition: {
459-
delay: 0.5,
460-
},
461-
},
462-
}}
463-
initial="hidden"
464-
animate="show"
465-
>
466-
<m.div layoutId="ai-loading-icon">
467-
<AiIconAnimation loading />
468-
</m.div>
469-
<h3 className="text-lg italic font-light text-neutral-500">
470-
Brainstorming some ideas
471-
</h3>
472-
</m.div>
473-
)}
474-
</>
475-
)}
476-
</div>
477406
</div>
478407
)}
479408
<AnimatePresence>

apps/postgres-new/lib/hooks.ts

-62
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,16 @@
33
import { useQuery, useQueryClient } from '@tanstack/react-query'
44
import { FeatureExtractionPipelineOptions, pipeline } from '@xenova/transformers'
55
import { generateId } from 'ai'
6-
import { useChat } from 'ai/react'
76
import { Chart } from 'chart.js'
87
import { codeBlock } from 'common-tags'
98
import { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useRef, useState } from 'react'
10-
import { useWorkspace } from '~/components/workspace'
119
import { useDatabaseUpdateMutation } from '~/data/databases/database-update-mutation'
1210
import { useTablesQuery } from '~/data/tables/tables-query'
13-
import { Report } from '~/lib/schema'
1411
import { getDb } from './db'
1512
import { loadFile, saveFile } from './files'
1613
import { SmoothScroller } from './smooth-scroller'
1714
import { OnToolCall } from './tools'
1815

19-
export type UseReportSuggestionsOptions = {
20-
enabled?: boolean
21-
}
22-
23-
export function useReportSuggestions({ enabled = true }: UseReportSuggestionsOptions) {
24-
const { databaseId, appendMessage } = useWorkspace()
25-
const { data: tables } = useTablesQuery({ databaseId, schemas: ['public'] })
26-
const [reports, setReports] = useState<Report[]>()
27-
28-
const { setMessages } = useChat({
29-
id: databaseId,
30-
api: '/api/chat',
31-
async onToolCall({ toolCall }) {
32-
switch (toolCall.toolName) {
33-
case 'brainstormReports': {
34-
const { reports } = toolCall.args as any
35-
setReports(reports)
36-
}
37-
}
38-
},
39-
})
40-
41-
useEffect(() => {
42-
if (enabled && tables) {
43-
// Provide the LLM with the current schema before invoking the tool call
44-
setMessages([
45-
{
46-
id: generateId(),
47-
role: 'assistant',
48-
content: '',
49-
toolInvocations: [
50-
{
51-
state: 'result',
52-
toolCallId: generateId(),
53-
toolName: 'getDatabaseSchema',
54-
args: {},
55-
result: tables,
56-
},
57-
],
58-
},
59-
])
60-
61-
appendMessage({
62-
role: 'user',
63-
content: codeBlock`
64-
Brainstorm 5 interesting charts that can be generated based on tables and their columns in the database.
65-
66-
Keep descriptions short and concise. Don't say "eg.". Descriptions should mention charting or visualizing.
67-
68-
Titles should be 4 words or less.
69-
`,
70-
})
71-
}
72-
// eslint-disable-next-line react-hooks/exhaustive-deps
73-
}, [enabled, tables])
74-
75-
return { reports }
76-
}
77-
7816
/**
7917
* Hook to load/store values from local storage with an API similar
8018
* to `useState()`.

0 commit comments

Comments
 (0)