thinking indicator, role column
This commit is contained in:
@@ -76,6 +76,7 @@ def create_tables():
|
|||||||
"""
|
"""
|
||||||
CREATE TABLE IF NOT EXISTS embeddings (
|
CREATE TABLE IF NOT EXISTS embeddings (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
|
role TEXT,
|
||||||
bucket TEXT,
|
bucket TEXT,
|
||||||
key TEXT,
|
key TEXT,
|
||||||
content TEXT,
|
content TEXT,
|
||||||
@@ -144,7 +145,7 @@ def split_files():
|
|||||||
Key=f'{key}/page-{i + 1}.pdf',
|
Key=f'{key}/page-{i + 1}.pdf',
|
||||||
Body=bs.getvalue()
|
Body=bs.getvalue()
|
||||||
)
|
)
|
||||||
cur.execute('INSERT INTO embeddings (bucket, key) VALUES (%s, %s);', (BUCKET_PAGES, f'{key}/page-{i + 1}.pdf'))
|
cur.execute('INSERT INTO embeddings (bucket, key, role) VALUES (%s, %s, %s);', (BUCKET_PAGES, f'{key}/page-{i + 1}.pdf', key.split('/')[0]))
|
||||||
cur.execute('UPDATE metadata SET SPLIT = true WHERE id = %s', (row['id'],));
|
cur.execute('UPDATE metadata SET SPLIT = true WHERE id = %s', (row['id'],));
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,29 @@ import LoginButton from "@/components/LoginButton";
|
|||||||
import LogoutButton from "@/components/LogoutButton";
|
import LogoutButton from "@/components/LogoutButton";
|
||||||
import Profile from "@/components/Profile";
|
import Profile from "@/components/Profile";
|
||||||
|
|
||||||
|
// Separate component to safely use useCopilotChat hook
|
||||||
|
function ThinkingIndicator() {
|
||||||
|
try {
|
||||||
|
const { isLoading } = useCopilotChat();
|
||||||
|
if (!isLoading) return null;
|
||||||
|
return (
|
||||||
|
<div className="absolute bottom-24 left-1/2 transform -translate-x-1/2 bg-white shadow-lg rounded-full px-4 py-2 flex items-center gap-2 z-50">
|
||||||
|
<div className="flex gap-1">
|
||||||
|
<span className="w-2 h-2 bg-indigo-500 rounded-full animate-bounce" style={{ animationDelay: "0ms" }}></span>
|
||||||
|
<span className="w-2 h-2 bg-indigo-500 rounded-full animate-bounce" style={{ animationDelay: "150ms" }}></span>
|
||||||
|
<span className="w-2 h-2 bg-indigo-500 rounded-full animate-bounce" style={{ animationDelay: "300ms" }}></span>
|
||||||
|
</div>
|
||||||
|
<span className="text-sm text-gray-600">Thinking...</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function CopilotKitPage() {
|
export default function CopilotKitPage() {
|
||||||
const [themeColor, setThemeColor] = useState("#6366f1");
|
const [themeColor, setThemeColor] = useState("#6366f1");
|
||||||
const { user, isLoading: authLoading } = useUser();
|
const { user, isLoading: authLoading } = useUser();
|
||||||
const { isLoading: chatLoading } = useCopilotChat();
|
|
||||||
|
|
||||||
useCopilotAction({
|
useCopilotAction({
|
||||||
name: "setThemeColor",
|
name: "setThemeColor",
|
||||||
@@ -104,17 +123,7 @@ export default function CopilotKitPage() {
|
|||||||
className="h-full w-full"
|
className="h-full w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/* Loading overlay */}
|
<ThinkingIndicator />
|
||||||
{chatLoading && (
|
|
||||||
<div className="absolute bottom-24 left-1/2 transform -translate-x-1/2 bg-white shadow-lg rounded-full px-4 py-2 flex items-center gap-2 z-50">
|
|
||||||
<div className="flex gap-1">
|
|
||||||
<span className="w-2 h-2 bg-indigo-500 rounded-full animate-bounce" style={{ animationDelay: "0ms" }}></span>
|
|
||||||
<span className="w-2 h-2 bg-indigo-500 rounded-full animate-bounce" style={{ animationDelay: "150ms" }}></span>
|
|
||||||
<span className="w-2 h-2 bg-indigo-500 rounded-full animate-bounce" style={{ animationDelay: "300ms" }}></span>
|
|
||||||
</div>
|
|
||||||
<span className="text-sm text-gray-600">Thinking...</span>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user