Skip to content

Commit 6efccf7

Browse files
authored
Merge pull request #109 from google-gemini/fixes
Fixes app state and returns
2 parents e44ee7e + 9380323 commit 6efccf7

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

backend/src/agent/configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ class Configuration(BaseModel):
1616
)
1717

1818
reflection_model: str = Field(
19-
default="gemini-2.5-flash-preview-04-17",
19+
default="gemini-2.5-flash",
2020
metadata={
2121
"description": "The name of the language model to use for the agent's reflection."
2222
},
2323
)
2424

2525
answer_model: str = Field(
26-
default="gemini-2.5-pro-preview-05-06",
26+
default="gemini-2.5-pro",
2727
metadata={
2828
"description": "The name of the language model to use for the agent's answer."
2929
},

backend/src/agent/graph.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def generate_query(state: OverallState, config: RunnableConfig) -> QueryGenerati
7878
)
7979
# Generate the search queries
8080
result = structured_llm.invoke(formatted_prompt)
81-
return {"query_list": result.query}
81+
return {"search_query": result.query}
8282

8383

8484
def continue_to_web_research(state: QueryGenerationState):
@@ -88,7 +88,7 @@ def continue_to_web_research(state: QueryGenerationState):
8888
"""
8989
return [
9090
Send("web_research", {"search_query": search_query, "id": int(idx)})
91-
for idx, search_query in enumerate(state["query_list"])
91+
for idx, search_query in enumerate(state["search_query"])
9292
]
9393

9494

@@ -153,7 +153,7 @@ def reflection(state: OverallState, config: RunnableConfig) -> ReflectionState:
153153
configurable = Configuration.from_runnable_config(config)
154154
# Increment the research loop count and get the reasoning model
155155
state["research_loop_count"] = state.get("research_loop_count", 0) + 1
156-
reasoning_model = state.get("reasoning_model") or configurable.reasoning_model
156+
reasoning_model = state.get("reasoning_model", configurable.reflection_model)
157157

158158
# Format the prompt
159159
current_date = get_current_date()
@@ -231,7 +231,7 @@ def finalize_answer(state: OverallState, config: RunnableConfig):
231231
Dictionary with state update, including running_summary key containing the formatted final summary with sources
232232
"""
233233
configurable = Configuration.from_runnable_config(config)
234-
reasoning_model = state.get("reasoning_model") or configurable.reasoning_model
234+
reasoning_model = state.get("reasoning_model") or configurable.answer_model
235235

236236
# Format the prompt
237237
current_date = get_current_date()

backend/src/agent/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Query(TypedDict):
3737

3838

3939
class QueryGenerationState(TypedDict):
40-
query_list: list[Query]
40+
search_query: list[Query]
4141

4242

4343
class WebSearchState(TypedDict):

frontend/src/App.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useState, useEffect, useRef, useCallback } from "react";
44
import { ProcessedEvent } from "@/components/ActivityTimeline";
55
import { WelcomeScreen } from "@/components/WelcomeScreen";
66
import { ChatMessagesView } from "@/components/ChatMessagesView";
7+
import { Button } from "@/components/ui/button";
78

89
export default function App() {
910
const [processedEventsTimeline, setProcessedEventsTimeline] = useState<
@@ -14,7 +15,7 @@ export default function App() {
1415
>({});
1516
const scrollAreaRef = useRef<HTMLDivElement>(null);
1617
const hasFinalizeEventOccurredRef = useRef(false);
17-
18+
const [error, setError] = useState<string | null>(null);
1819
const thread = useStream<{
1920
messages: Message[];
2021
initial_search_query_count: number;
@@ -26,15 +27,12 @@ export default function App() {
2627
: "http://localhost:8123",
2728
assistantId: "agent",
2829
messagesKey: "messages",
29-
onFinish: (event: any) => {
30-
console.log(event);
31-
},
3230
onUpdateEvent: (event: any) => {
3331
let processedEvent: ProcessedEvent | null = null;
3432
if (event.generate_query) {
3533
processedEvent = {
3634
title: "Generating Search Queries",
37-
data: event.generate_query.query_list.join(", "),
35+
data: event.generate_query?.search_query?.join(", ") || "",
3836
};
3937
} else if (event.web_research) {
4038
const sources = event.web_research.sources_gathered || [];
@@ -52,11 +50,7 @@ export default function App() {
5250
} else if (event.reflection) {
5351
processedEvent = {
5452
title: "Reflection",
55-
data: event.reflection.is_sufficient
56-
? "Search successful, generating final answer."
57-
: `Need more information, searching for ${event.reflection.follow_up_queries?.join(
58-
", "
59-
) || "additional information"}`,
53+
data: "Analysing Web Research Results",
6054
};
6155
} else if (event.finalize_answer) {
6256
processedEvent = {
@@ -72,6 +66,9 @@ export default function App() {
7266
]);
7367
}
7468
},
69+
onError: (error: any) => {
70+
setError(error.message);
71+
},
7572
});
7673

7774
useEffect(() => {
@@ -166,6 +163,20 @@ export default function App() {
166163
isLoading={thread.isLoading}
167164
onCancel={handleCancel}
168165
/>
166+
) : error ? (
167+
<div className="flex flex-col items-center justify-center h-full">
168+
<div className="flex flex-col items-center justify-center gap-4">
169+
<h1 className="text-2xl text-red-400 font-bold">Error</h1>
170+
<p className="text-red-400">{JSON.stringify(error)}</p>
171+
172+
<Button
173+
variant="destructive"
174+
onClick={() => window.location.reload()}
175+
>
176+
Retry
177+
</Button>
178+
</div>
179+
</div>
169180
) : (
170181
<ChatMessagesView
171182
messages={thread.messages}

frontend/src/components/ChatMessagesView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ const AiMessageBubble: React.FC<AiMessageBubbleProps> = ({
203203
</ReactMarkdown>
204204
<Button
205205
variant="default"
206-
className="cursor-pointer bg-neutral-700 border-neutral-600 text-neutral-300 self-end"
206+
className={`cursor-pointer bg-neutral-700 border-neutral-600 text-neutral-300 self-end ${
207+
message.content.length > 0 ? "visible" : "hidden"
208+
}`}
207209
onClick={() =>
208210
handleCopy(
209211
typeof message.content === "string"
@@ -250,7 +252,6 @@ export function ChatMessagesView({
250252
console.error("Failed to copy text: ", err);
251253
}
252254
};
253-
254255
return (
255256
<div className="flex flex-col h-full overflow-hidden">
256257
<ScrollArea className="flex-1 min-h-0" ref={scrollAreaRef}>

0 commit comments

Comments
 (0)