Skip to content
Snippets Groups Projects
Unverified Commit a0b04be2 authored by Marcus Schiesser's avatar Marcus Schiesser Committed by GitHub
Browse files

fix: hide events per default and optimize python messaging (#64)

parent 94a2809e
No related branches found
No related tags found
No related merge requests found
...@@ -79,14 +79,8 @@ class EventCallbackHandler(BaseCallbackHandler): ...@@ -79,14 +79,8 @@ class EventCallbackHandler(BaseCallbackHandler):
"""No-op.""" """No-op."""
async def async_event_gen(self) -> AsyncGenerator[CallbackEvent, None]: async def async_event_gen(self) -> AsyncGenerator[CallbackEvent, None]:
while True: while not self._aqueue.empty() or not self.is_done:
if not self._aqueue.empty() or not self.is_done: try:
try: yield await asyncio.wait_for(self._aqueue.get(), timeout=0.1)
event = await asyncio.wait_for(self._aqueue.get(), timeout=0.1) except asyncio.TimeoutError:
except asyncio.TimeoutError: pass
if self.is_done:
break
continue
yield event
else:
break
import { ChevronDown, ChevronRight, Loader2 } from "lucide-react"; import { ChevronDown, ChevronRight, Loader2 } from "lucide-react";
import { useEffect, useState } from "react"; import { useState } from "react";
import { Button } from "../button"; import { Button } from "../button";
import { import {
Collapsible, Collapsible,
...@@ -15,24 +15,11 @@ export function ChatEvents({ ...@@ -15,24 +15,11 @@ export function ChatEvents({
data: EventData[]; data: EventData[];
isLoading: boolean; isLoading: boolean;
}) { }) {
const [isOpen, setIsOpen] = useState(true); const [isOpen, setIsOpen] = useState(false);
useEffect(() => { const buttonLabel = isOpen ? "Hide events" : "Show events";
// Collapse the events when finished streaming
if (!isLoading) {
setIsOpen(false);
}
}, [isLoading]);
const buttonLabel = isLoading const EventIcon = isOpen ? (
? "In progress"
: isOpen
? "Hide events"
: "Show events";
const EventIcon = isLoading ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : isOpen ? (
<ChevronDown className="h-4 w-4" /> <ChevronDown className="h-4 w-4" />
) : ( ) : (
<ChevronRight className="h-4 w-4" /> <ChevronRight className="h-4 w-4" />
...@@ -43,6 +30,7 @@ export function ChatEvents({ ...@@ -43,6 +30,7 @@ export function ChatEvents({
<Collapsible open={isOpen} onOpenChange={setIsOpen}> <Collapsible open={isOpen} onOpenChange={setIsOpen}>
<CollapsibleTrigger asChild> <CollapsibleTrigger asChild>
<Button variant="secondary" className="space-x-2"> <Button variant="secondary" className="space-x-2">
{isLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : null}
<span>{buttonLabel}</span> <span>{buttonLabel}</span>
{EventIcon} {EventIcon}
</Button> </Button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment