From bde4a634d752206b063e0ba0300608fd19a8c689 Mon Sep 17 00:00:00 2001 From: wnqqnw19 Date: Thu, 4 Dec 2025 10:36:48 -0800 Subject: [PATCH 1/8] fix: correct typos, grammar errors, and formatting issues across project --- python/README.md | 2 +- python/agents/antom-payment/README.md | 6 +++--- .../agents/antom-payment/antom-payemnt-agent/agent.py | 10 +++++----- python/agents/antom-payment/pyproject.toml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/python/README.md b/python/README.md index 2bd3d54cb..41aeda0cc 100644 --- a/python/README.md +++ b/python/README.md @@ -129,5 +129,5 @@ This is not an officially supported Google product. This project is not eligible for the [Google Open Source Software Vulnerability Rewards Program](https://bughunters.google.com/open-source-security). -The agents in this project are intended for demonstration purposes only. They is +The agents in this project are intended for demonstration purposes only. They are not intended for use in a production environment. diff --git a/python/agents/antom-payment/README.md b/python/agents/antom-payment/README.md index 860f71bdb..102abaddc 100644 --- a/python/agents/antom-payment/README.md +++ b/python/agents/antom-payment/README.md @@ -1,12 +1,12 @@ # Antom Payment Agent -This project implements an AI-powered payment service agent that integrates Ant International's Antom payment MCP. The agent is designed to ensure secure and smooth handling of payemnts and refunds through AI interactions. +This project implements an AI-powered payment service agent that integrates Ant International's Antom payment MCP. The agent is designed to ensure secure and smooth handling of payments and refunds through AI interactions. ## Overview Ant International's Antom payment MCP wraps Ant International's Antom payment APIs into standardized MCP tools, allowing AI assistants to securely process payment-related operations during conversations. With this MCP server, you can create payment sessions, query transaction status, handle refunds, and more directly through AI interactions. -The Antom Payment Agent aims to provide customers with a convenient and seamless dialogue-based payment process. it enhances the overall shopping and payment experience by flexibly organizing the payment flow according to consumer's intent using Ant International's Antom payment MCP, like initiating order checkout and cancel payment. +The Antom Payment Agent aims to provide customers with a convenient and seamless dialogue-based payment process. It enhances the overall shopping and payment experience by flexibly organizing the payment flow according to consumer's intent using Ant International's Antom payment MCP, like initiating order checkout and cancel payment. ## Features @@ -56,7 +56,7 @@ Before using the Antom Payment Agent, ensure you have: 3. **Configuration** - You may set the following environment variables in your shell, or in a `python/agents/antom-payment/antom-payemnt-agent/.env` file instead. + You may set the following environment variables in your shell, or in a `python/agents/antom-payment/antom-payment-agent/.env` file instead. * Set up Google Cloud credentials. GOOGLE_GENAI_USE_VERTEXAI diff --git a/python/agents/antom-payment/antom-payemnt-agent/agent.py b/python/agents/antom-payment/antom-payemnt-agent/agent.py index 6ac6454d9..cfce39767 100644 --- a/python/agents/antom-payment/antom-payemnt-agent/agent.py +++ b/python/agents/antom-payment/antom-payemnt-agent/agent.py @@ -8,13 +8,13 @@ name="antom_payment_agent", model="gemini-2.0-flash", description=( - "Agent creates payment links for merchants, queries payment result details。" + "Agent creates payment links for merchants, queries payment result details." ), instruction=( - "You are an Antom payment agent who can help users create payment links and query payment result details." - "Regarding RequestId, you generate it randomly" - "And you can describe the description of the user creating the order in one sentence" - "when refund get the order details and paymentId based on the paymentRequest ID used when creating " + "You are an Antom payment agent who can help users create payment links and query payment result details. " + "Regarding RequestId, you generate it randomly. " + "And you can describe the description of the user creating the order in one sentence. " + "When refund get the order details and paymentId based on the paymentRequest ID used when creating " "the payment method by the payment agent. " "If the merchant specifies a refund amount, a full refund will be made in the order currency by default." ), diff --git a/python/agents/antom-payment/pyproject.toml b/python/agents/antom-payment/pyproject.toml index 4749a2eba..73f2d1273 100644 --- a/python/agents/antom-payment/pyproject.toml +++ b/python/agents/antom-payment/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "antom-payment" version = "0.1.0" -description = "That integrates Ant International's Antom payment APIs, enabling AI assistants to handle payment and refund operations seamlessly." +description = "An agent that integrates Ant International's Antom payment APIs, enabling AI assistants to handle payment and refund operations seamlessly." authors = [ { name = "Steven", email = "duanmuci@ant-intl.com" }, { name = "Zunjiao Wang", email = "wangzunjiao.wzj@digital-engine.com" } From 8101dfb4657f46fc73ac05380a793fbab49c1055 Mon Sep 17 00:00:00 2001 From: wnqqnw19 Date: Thu, 4 Dec 2025 11:06:30 -0800 Subject: [PATCH 2/8] fix: correct typos and grammar errors in multiple files --- python/agents/personalized-shopping/deployment/deploy.py | 4 ++-- .../swe-benchmark-agent/swe_benchmark_agent/orchestrator.py | 2 +- python/agents/travel-concierge/README.md | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/agents/personalized-shopping/deployment/deploy.py b/python/agents/personalized-shopping/deployment/deploy.py index 069a4350d..633e17ce4 100644 --- a/python/agents/personalized-shopping/deployment/deploy.py +++ b/python/agents/personalized-shopping/deployment/deploy.py @@ -58,7 +58,7 @@ print("Deploying agent to agent engine finished.") print("-" * 50) -print("Testing deployemnt:") +print("Testing deployment:") session = remote_app.create_session(user_id="123") for event in remote_app.stream_query( user_id="123", @@ -66,5 +66,5 @@ message="Hello!", ): print(event) -print("Testing deployemnt finished!") +print("Testing deployment finished!") print("-" * 50) diff --git a/python/agents/swe-benchmark-agent/swe_benchmark_agent/orchestrator.py b/python/agents/swe-benchmark-agent/swe_benchmark_agent/orchestrator.py index 5aba0e107..38c320c23 100644 --- a/python/agents/swe-benchmark-agent/swe_benchmark_agent/orchestrator.py +++ b/python/agents/swe-benchmark-agent/swe_benchmark_agent/orchestrator.py @@ -555,7 +555,7 @@ def submit(self) -> str: f""" You are trying to submit your work, but before that, please carefully verify that you have performed the following steps as described in your instructions: - 1. You have **thoroughly** tested your solution by creating two comprehensive tests covering different edge cases. If you only tested the main functionality so far, you should create another test with more comprehensive test cases. Do **NOT** split existing tests into two seperate tests to satisfy this requirement. You have to create new tests from scratch if needed. + 1. You have **thoroughly** tested your solution by creating two comprehensive tests covering different edge cases. If you only tested the main functionality so far, you should create another test with more comprehensive test cases. Do **NOT** split existing tests into two separate tests to satisfy this requirement. You have to create new tests from scratch if needed. 2. Regression tests: You have run any **existing** related tests in the repository besides your newly created tests to make sure your changes do not regress or break anything. - **Very important:** Make sure you also run a broader set of existing tests, not just the ones in the same test files you edited. diff --git a/python/agents/travel-concierge/README.md b/python/agents/travel-concierge/README.md index 0b3089373..a7a9cc78e 100644 --- a/python/agents/travel-concierge/README.md +++ b/python/agents/travel-concierge/README.md @@ -517,12 +517,12 @@ The following are just the starting ideas: ## Troubleshoot -The following occasionally happens while interaction with the agent: +The following occasionally happens during interaction with the agent: - "Malformed" function call or response, or pydantic errors - when this happens simply tell the agent to "try again". -- If the agents tries to call a tool that doesn't exist, tell the agent that it is the "wrong tool, try again", the agent is often able to self correct. +- If the agent tries to call a tool that doesn't exist, tell the agent that it is the "wrong tool, try again", the agent is often able to self correct. - Similarly, if you have waited for a while and the agent has stopped in the middle of executing a series of actions, ask the agent "what's next" to nudge it forward. -These happens occasionally, it is likely due to variations in JSON responses that requires more rigorous experimentation on prompts and generation parameters to attain more stable results. Within an application, these retries can also be built into the application as part of exception handling. +This happens occasionally, it is likely due to variations in JSON responses that requires more rigorous experimentation on prompts and generation parameters to attain more stable results. Within an application, these retries can also be built into the application as part of exception handling. ## Disclaimer From 6f71302713329c3bc74886a18fc44ca1c42875d3 Mon Sep 17 00:00:00 2001 From: wnqqnw19 Date: Thu, 4 Dec 2025 11:09:35 -0800 Subject: [PATCH 3/8] fix: correct typos and grammar errors across multiple files --- .../data-science/data_science/sub_agents/analytics/prompts.py | 2 +- .../agents/llm-auditor/llm_auditor/sub_agents/critic/prompt.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/agents/data-science/data_science/sub_agents/analytics/prompts.py b/python/agents/data-science/data_science/sub_agents/analytics/prompts.py index 9b332a3f4..98b414ed0 100644 --- a/python/agents/data-science/data_science/sub_agents/analytics/prompts.py +++ b/python/agents/data-science/data_science/sub_agents/analytics/prompts.py @@ -103,7 +103,7 @@ def return_instructions_analytics() -> str: TASK: You need to assist the user with their queries by looking at the data and the context in the conversation. Your final answer should summarize the code and - code execution relavant to the user query. + code execution relevant to the user query. You should include all pieces of data to answer the user query, such as the table from code execution results. If you cannot answer the question directly, diff --git a/python/agents/llm-auditor/llm_auditor/sub_agents/critic/prompt.py b/python/agents/llm-auditor/llm_auditor/sub_agents/critic/prompt.py index 268f4edd5..8fa4d55d2 100644 --- a/python/agents/llm-auditor/llm_auditor/sub_agents/critic/prompt.py +++ b/python/agents/llm-auditor/llm_auditor/sub_agents/critic/prompt.py @@ -54,7 +54,7 @@ * You may search the web to find information that supports or contradicts the claim. * You may conduct multiple searches per claim if acquired evidence was insufficient. * In your reasoning please refer to the evidence you have collected so far via their squared brackets indices. - * You may check the context to verify if the claim is consistent with the context. Read the context carefully to idenfity specific user instructions that the text should follow, facts that the text should be faithful to, etc. + * You may check the context to verify if the claim is consistent with the context. Read the context carefully to identify specific user instructions that the text should follow, facts that the text should be faithful to, etc. * You should draw your final conclusion on the entire text after you acquired all the information you needed. # Output format From 49ee337bf8f26c8d35dec8d9774b9aee73c22b83 Mon Sep 17 00:00:00 2001 From: wnqqnw19 Date: Thu, 4 Dec 2025 11:11:18 -0800 Subject: [PATCH 4/8] fix: correct typos and grammar errors across Python and Go files --- go/agents/llm-auditor/critic/critic.go | 2 +- .../data-science/data_science/sub_agents/analytics/prompts.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go/agents/llm-auditor/critic/critic.go b/go/agents/llm-auditor/critic/critic.go index c9286019d..350c9638a 100644 --- a/go/agents/llm-auditor/critic/critic.go +++ b/go/agents/llm-auditor/critic/critic.go @@ -66,7 +66,7 @@ There are various actions you can take to help you with the verification: * You may search the web to find information that supports or contradicts the claim. * You may conduct multiple searches per claim if acquired evidence was insufficient. * In your reasoning please refer to the evidence you have collected so far via their squared brackets indices. - * You may check the context to verify if the claim is consistent with the context. Read the context carefully to idenfity specific user instructions that the text should follow, facts that the text should be faithful to, etc. + * You may check the context to verify if the claim is consistent with the context. Read the context carefully to identify specific user instructions that the text should follow, facts that the text should be faithful to, etc. * You should draw your final conclusion on the entire text after you acquired all the information you needed. # Output format diff --git a/python/agents/data-science/data_science/sub_agents/analytics/prompts.py b/python/agents/data-science/data_science/sub_agents/analytics/prompts.py index 98b414ed0..577e6b141 100644 --- a/python/agents/data-science/data_science/sub_agents/analytics/prompts.py +++ b/python/agents/data-science/data_science/sub_agents/analytics/prompts.py @@ -109,7 +109,7 @@ def return_instructions_analytics() -> str: table from code execution results. If you cannot answer the question directly, you should follow the guidelines above to generate the next step. If the question can be answered directly with writing any code, you should do that. - If you doesn't have enough data to answer the question, you should ask for + If you don't have enough data to answer the question, you should ask for clarification from the user. You should NEVER install any package on your own like `pip install ...`. From 9f815d74641aeb011ba025a387b311c83434f8b8 Mon Sep 17 00:00:00 2001 From: wnqqnw19 Date: Thu, 4 Dec 2025 11:12:06 -0800 Subject: [PATCH 5/8] fix: add connection timeout and improve error handling for bidi-demo WebSocket --- python/agents/bidi-demo/app/static/js/app.js | 79 ++++++++++++++------ 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/python/agents/bidi-demo/app/static/js/app.js b/python/agents/bidi-demo/app/static/js/app.js index c8460d5b5..d86f4b110 100644 --- a/python/agents/bidi-demo/app/static/js/app.js +++ b/python/agents/bidi-demo/app/static/js/app.js @@ -275,8 +275,28 @@ function connectWebsocket() { const ws_url = getWebSocketUrl(); websocket = new WebSocket(ws_url); + // Set connection timeout (10 seconds) + const connectionTimeout = setTimeout(() => { + if (websocket && websocket.readyState === WebSocket.CONNECTING) { + console.error("WebSocket connection timeout"); + updateConnectionStatus(false); + statusText.textContent = "Connection timeout"; + addSystemMessage("Connection timeout. Please check if the server is running."); + + // Log to console + addConsoleEntry('error', 'WebSocket Connection Timeout', { + url: ws_url, + message: 'Connection attempt timed out after 10 seconds' + }, '⏱️', 'system'); + + // Close the connection + websocket.close(); + } + }, 10000); + // Handle connection open websocket.onopen = function () { + clearTimeout(connectionTimeout); console.log("WebSocket connection opened."); updateConnectionStatus(true); addSystemMessage("Connected to ADK streaming server"); @@ -576,41 +596,52 @@ function connectWebsocket() { }; // Handle connection close - websocket.onclose = function () { - console.log("WebSocket connection closed."); + websocket.onclose = function (event) { + clearTimeout(connectionTimeout); + console.log("WebSocket connection closed.", event); updateConnectionStatus(false); document.getElementById("sendButton").disabled = true; - addSystemMessage("Connection closed. Reconnecting in 5 seconds..."); - - // Log to console - addConsoleEntry('error', 'WebSocket Disconnected', { - status: 'Connection closed', - reconnecting: true, - reconnectDelay: '5 seconds' - }, '🔌', 'system'); - - setTimeout(function () { - console.log("Reconnecting..."); - - // Log reconnection attempt to console - addConsoleEntry('outgoing', 'Reconnecting to ADK server...', { - userId: userId, - sessionId: sessionId - }, '🔄', 'system'); + + // Only show reconnecting message if it was a normal close (not a timeout) + if (event.code !== 1006 || statusText.textContent !== "Connection timeout") { + addSystemMessage("Connection closed. Reconnecting in 5 seconds..."); - connectWebsocket(); - }, 5000); + // Log to console + addConsoleEntry('error', 'WebSocket Disconnected', { + status: 'Connection closed', + code: event.code, + reason: event.reason || 'No reason provided', + reconnecting: true, + reconnectDelay: '5 seconds' + }, '🔌', 'system'); + + setTimeout(function () { + console.log("Reconnecting..."); + + // Log reconnection attempt to console + addConsoleEntry('outgoing', 'Reconnecting to ADK server...', { + userId: userId, + sessionId: sessionId + }, '🔄', 'system'); + + connectWebsocket(); + }, 5000); + } }; websocket.onerror = function (e) { - console.log("WebSocket error: ", e); + clearTimeout(connectionTimeout); + console.error("WebSocket error: ", e); updateConnectionStatus(false); + statusText.textContent = "Connection error"; // Log to console addConsoleEntry('error', 'WebSocket Error', { - error: e.type, - message: 'Connection error occurred' + error: e.type || 'Unknown error', + message: 'Connection error occurred. Please check server status and network connection.' }, '⚠️', 'system'); + + addSystemMessage("Connection error. Please check if the server is running."); }; } connectWebsocket(); From 0ca7c91d4ce2479e9e27532de04adc673981e4a1 Mon Sep 17 00:00:00 2001 From: wnqqnw19 Date: Thu, 4 Dec 2025 11:16:46 -0800 Subject: [PATCH 6/8] fix: add defensive check to ensure call_analytics_agent is always in tools list --- python/agents/data-science/data_science/agent.py | 12 ++++++++++++ python/agents/data-science/data_science/tools.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/python/agents/data-science/data_science/agent.py b/python/agents/data-science/data_science/agent.py index f93d8f187..483d2ffca 100644 --- a/python/agents/data-science/data_science/agent.py +++ b/python/agents/data-science/data_science/agent.py @@ -183,6 +183,18 @@ def get_root_agent() -> LlmAgent: elif dataset["type"] == "alloydb": tools.append(call_alloydb_agent) + # Ensure call_analytics_agent is always in the tools list + # This is a defensive check to prevent the tool from being missing + if call_analytics_agent not in tools: + _logger.warning( + "call_analytics_agent was not in tools list, adding it now" + ) + tools.insert(0, call_analytics_agent) + + # Log the tools being registered for debugging + tool_names = [getattr(tool, "__name__", str(tool)) for tool in tools] + _logger.debug(f"Registering tools: {tool_names}") + agent = LlmAgent( model=os.getenv("ROOT_AGENT_MODEL", "gemini-2.5-flash"), name="data_science_root_agent", diff --git a/python/agents/data-science/data_science/tools.py b/python/agents/data-science/data_science/tools.py index a551cd979..c564eda24 100644 --- a/python/agents/data-science/data_science/tools.py +++ b/python/agents/data-science/data_science/tools.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Tools for the ADK Sampmles Data Science Agent.""" +"""Tools for the ADK Samples Data Science Agent.""" import logging From d17c553be02eb1b0f556179725c232c88d0da01c Mon Sep 17 00:00:00 2001 From: wnqqnw19 Date: Thu, 4 Dec 2025 11:25:39 -0800 Subject: [PATCH 7/8] fix: auto-select native audio model name based on API platform --- .../server/example_agent/agent.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/python/agents/realtime-conversational-agent/server/example_agent/agent.py b/python/agents/realtime-conversational-agent/server/example_agent/agent.py index 49c0bcd6c..eb515d3e8 100644 --- a/python/agents/realtime-conversational-agent/server/example_agent/agent.py +++ b/python/agents/realtime-conversational-agent/server/example_agent/agent.py @@ -1,3 +1,5 @@ +import os + from google.adk.agents import Agent from google.genai.types import ( GenerateContentConfig, @@ -8,13 +10,25 @@ from .prompts import AGENT_INSTRUCTION +# Determine model name based on API choice +# Check if Vertex AI is being used +use_vertex = os.getenv("GOOGLE_GENAI_USE_VERTEXAI", "FALSE").upper() == "TRUE" + +if use_vertex: + # Vertex AI Live API model name format + model_name = "gemini-live-2.5-flash-preview-native-audio-09-2025" +else: + # Gemini Live API model name format + model_name = "gemini-2.5-flash-native-audio-preview-09-2025" + genai_config = GenerateContentConfig( temperature=0.5 ) root_agent = Agent( name="example_agent", - model="gemini-live-2.5-flash-preview-native-audio", + model=model_name, description="A helpful AI assistant.", - instruction=AGENT_INSTRUCTION + instruction=AGENT_INSTRUCTION, + generate_content_config=genai_config, ) \ No newline at end of file From d83f9137a15a58ff72df9e0d4dedeb9eeb77cfff Mon Sep 17 00:00:00 2001 From: wnqqnw19 Date: Thu, 4 Dec 2025 11:38:17 -0800 Subject: [PATCH 8/8] fix: resolve TypeScript compilation errors in deep-search frontend --- .../agents/deep-search/frontend/package.json | 4 +- .../agents/deep-search/frontend/src/App.tsx | 78 +++++++------------ .../deep-search/frontend/src/vite-env.d.ts | 2 + .../agents/deep-search/frontend/tsconfig.json | 7 +- .../deep-search/frontend/vite.config.ts | 15 ++-- 5 files changed, 47 insertions(+), 59 deletions(-) diff --git a/python/agents/deep-search/frontend/package.json b/python/agents/deep-search/frontend/package.json index ae59cf1fb..7358dc2da 100644 --- a/python/agents/deep-search/frontend/package.json +++ b/python/agents/deep-search/frontend/package.json @@ -27,13 +27,15 @@ "react-router-dom": "^7.5.3", "remark-gfm": "^4.0.1", "tailwind-merge": "^3.2.0", - "tailwindcss": "^4.1.5" + "tailwindcss": "^4.1.5", + "uuid": "^11.0.3" }, "devDependencies": { "@eslint/js": "^9.22.0", "@types/node": "^22.15.17", "@types/react": "^19.1.2", "@types/react-dom": "^19.1.3", + "@types/uuid": "^10.0.0", "@vitejs/plugin-react-swc": "^3.9.0", "eslint": "^9.22.0", "eslint-plugin-react-hooks": "^5.2.0", diff --git a/python/agents/deep-search/frontend/src/App.tsx b/python/agents/deep-search/frontend/src/App.tsx index ab24e2cb6..c931823d4 100644 --- a/python/agents/deep-search/frontend/src/App.tsx +++ b/python/agents/deep-search/frontend/src/App.tsx @@ -13,32 +13,21 @@ interface MessageWithAgent { finalReportWithCitations?: boolean; } -interface AgentMessage { - parts: { text: string }[]; - role: string; -} - -interface AgentResponse { - content: AgentMessage; - usageMetadata: { - candidatesTokenCount: number; - promptTokenCount: number; - totalTokenCount: number; - }; - author: string; - actions: { - stateDelta: { - research_plan?: string; - final_report_with_citations?: boolean; - }; - }; -} - interface ProcessedEvent { title: string; data: any; } +interface ExtractedSSEData { + textParts: string[]; + agent: string; + finalReportWithCitations?: string; + functionCall: any; + functionResponse: any; + sourceCount: number; + sources: any; +} + export default function App() { const [userId, setUserId] = useState(null); const [sessionId, setSessionId] = useState(null); @@ -118,7 +107,7 @@ export default function App() { }; // Function to extract text and metadata from SSE data - const extractDataFromSSE = (data: string) => { + const extractDataFromSSE = useCallback((data: string): ExtractedSSEData => { try { const parsed = JSON.parse(data); console.log('[SSE PARSED EVENT]:', JSON.stringify(parsed, null, 2)); // DEBUG: Log parsed event @@ -190,10 +179,10 @@ export default function App() { console.error('Error parsing SSE data. Raw data (truncated): "', truncatedData, '". Error details:', error); return { textParts: [], agent: '', finalReportWithCitations: undefined, functionCall: null, functionResponse: null, sourceCount: 0, sources: null }; } - }; + }, []); // Define getEventTitle here or ensure it's in scope from where it's used - const getEventTitle = (agentName: string): string => { + const getEventTitle = useCallback((agentName: string): string => { switch (agentName) { case "plan_generator": return "Planning Research Strategy"; @@ -217,14 +206,14 @@ export default function App() { default: return `Processing (${agentName || 'Unknown Agent'})`; } - }; + }, []); - const processSseEventData = (jsonData: string, aiMessageId: string) => { + const processSseEventData = useCallback((jsonData: string, aiMessageId: string) => { const { textParts, agent, finalReportWithCitations, functionCall, functionResponse, sourceCount, sources } = extractDataFromSSE(jsonData); if (sourceCount > 0) { console.log('[SSE HANDLER] Updating websiteCount. Current sourceCount:', sourceCount); - setWebsiteCount(prev => Math.max(prev, sourceCount)); + setWebsiteCount((prev: number) => Math.max(prev, sourceCount)); } if (agent && agent !== currentAgentRef.current) { @@ -234,7 +223,7 @@ export default function App() { if (functionCall) { const functionCallTitle = `Function Call: ${functionCall.name}`; console.log('[SSE HANDLER] Adding Function Call timeline event:', functionCallTitle); - setMessageEvents(prev => new Map(prev).set(aiMessageId, [...(prev.get(aiMessageId) || []), { + setMessageEvents((prev: Map) => new Map(prev).set(aiMessageId, [...(prev.get(aiMessageId) || []), { title: functionCallTitle, data: { type: 'functionCall', name: functionCall.name, args: functionCall.args, id: functionCall.id } }])); @@ -243,7 +232,7 @@ export default function App() { if (functionResponse) { const functionResponseTitle = `Function Response: ${functionResponse.name}`; console.log('[SSE HANDLER] Adding Function Response timeline event:', functionResponseTitle); - setMessageEvents(prev => new Map(prev).set(aiMessageId, [...(prev.get(aiMessageId) || []), { + setMessageEvents((prev: Map) => new Map(prev).set(aiMessageId, [...(prev.get(aiMessageId) || []), { title: functionResponseTitle, data: { type: 'functionResponse', name: functionResponse.name, response: functionResponse.response, id: functionResponse.id } }])); @@ -253,14 +242,14 @@ export default function App() { if (agent !== "interactive_planner_agent") { const eventTitle = getEventTitle(agent); console.log('[SSE HANDLER] Adding Text timeline event for agent:', agent, 'Title:', eventTitle, 'Data:', textParts.join(" ")); - setMessageEvents(prev => new Map(prev).set(aiMessageId, [...(prev.get(aiMessageId) || []), { + setMessageEvents((prev: Map) => new Map(prev).set(aiMessageId, [...(prev.get(aiMessageId) || []), { title: eventTitle, data: { type: 'text', content: textParts.join(" ") } }])); } else { // interactive_planner_agent text updates the main AI message for (const text of textParts) { accumulatedTextRef.current += text + " "; - setMessages(prev => prev.map(msg => + setMessages((prev: MessageWithAgent[]) => prev.map((msg: MessageWithAgent) => msg.id === aiMessageId ? { ...msg, content: accumulatedTextRef.current.trim(), agent: currentAgentRef.current || msg.agent } : msg )); setDisplayData(accumulatedTextRef.current.trim()); @@ -270,19 +259,19 @@ export default function App() { if (sources) { console.log('[SSE HANDLER] Adding Retrieved Sources timeline event:', sources); - setMessageEvents(prev => new Map(prev).set(aiMessageId, [...(prev.get(aiMessageId) || []), { + setMessageEvents((prev: Map) => new Map(prev).set(aiMessageId, [...(prev.get(aiMessageId) || []), { title: "Retrieved Sources", data: { type: 'sources', content: sources } }])); } if (agent === "report_composer_with_citations" && finalReportWithCitations) { const finalReportMessageId = Date.now().toString() + "_final"; - setMessages(prev => [...prev, { type: "ai", content: finalReportWithCitations as string, id: finalReportMessageId, agent: currentAgentRef.current, finalReportWithCitations: true }]); + setMessages((prev: MessageWithAgent[]) => [...prev, { type: "ai", content: finalReportWithCitations as string, id: finalReportMessageId, agent: currentAgentRef.current, finalReportWithCitations: true }]); setDisplayData(finalReportWithCitations as string); } - }; + }, [extractDataFromSSE, getEventTitle]); - const handleSubmit = useCallback(async (query: string, model: string, effort: string) => { + const handleSubmit = useCallback(async (query: string) => { if (!query.trim()) return; setIsLoading(true); @@ -307,14 +296,14 @@ export default function App() { // Add user message to chat const userMessageId = Date.now().toString(); - setMessages(prev => [...prev, { type: "human", content: query, id: userMessageId }]); + setMessages((prev: MessageWithAgent[]) => [...prev, { type: "human", content: query, id: userMessageId }]); // Create AI message placeholder const aiMessageId = Date.now().toString() + "_ai"; currentAgentRef.current = ''; // Reset current agent accumulatedTextRef.current = ''; // Reset accumulated text - setMessages(prev => [...prev, { + setMessages((prev: MessageWithAgent[]) => [...prev, { type: "ai", content: "", id: aiMessageId, @@ -411,14 +400,14 @@ export default function App() { console.error("Error:", error); // Update the AI message placeholder with an error message const aiMessageId = Date.now().toString() + "_ai_error"; - setMessages(prev => [...prev, { + setMessages((prev: MessageWithAgent[]) => [...prev, { type: "ai", content: `Sorry, there was an error processing your request: ${error instanceof Error ? error.message : 'Unknown error'}`, id: aiMessageId }]); setIsLoading(false); } - }, [processSseEventData]); + }, [userId, sessionId, appName, processSseEventData]); useEffect(() => { if (scrollAreaRef.current) { @@ -467,17 +456,6 @@ export default function App() { window.location.reload(); }, []); - // Scroll to bottom when messages update - const scrollToBottom = useCallback(() => { - if (scrollAreaRef.current) { - const scrollViewport = scrollAreaRef.current.querySelector( - "[data-radix-scroll-area-viewport]" - ); - if (scrollViewport) { - scrollViewport.scrollTop = scrollViewport.scrollHeight; - } - } - }, []); const BackendLoadingScreen = () => (
diff --git a/python/agents/deep-search/frontend/src/vite-env.d.ts b/python/agents/deep-search/frontend/src/vite-env.d.ts index 11f02fe2a..bbc9a7974 100644 --- a/python/agents/deep-search/frontend/src/vite-env.d.ts +++ b/python/agents/deep-search/frontend/src/vite-env.d.ts @@ -1 +1,3 @@ /// +/// +/// diff --git a/python/agents/deep-search/frontend/tsconfig.json b/python/agents/deep-search/frontend/tsconfig.json index faba395cf..cccba6006 100644 --- a/python/agents/deep-search/frontend/tsconfig.json +++ b/python/agents/deep-search/frontend/tsconfig.json @@ -3,7 +3,7 @@ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", "target": "ES2020", "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable","dom"], + "lib": ["ES2020", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, "baseUrl": ".", @@ -17,6 +17,9 @@ "moduleDetection": "force", "noEmit": true, "jsx": "react-jsx", + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true, /* Linting */ "strict": true, "noUnusedLocals": true, @@ -24,5 +27,5 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["src","vite.config.ts"] + "include": ["src"] } diff --git a/python/agents/deep-search/frontend/vite.config.ts b/python/agents/deep-search/frontend/vite.config.ts index ff14422fa..f549175cc 100644 --- a/python/agents/deep-search/frontend/vite.config.ts +++ b/python/agents/deep-search/frontend/vite.config.ts @@ -1,15 +1,18 @@ import path from "node:path"; +import { fileURLToPath } from "node:url"; import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; import tailwindcss from "@tailwindcss/vite"; // https://vitejs.dev/config/ +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + export default defineConfig({ plugins: [react(), tailwindcss()], base: "/app/", resolve: { alias: { - "@": path.resolve(new URL(".", import.meta.url).pathname, "./src"), + "@": path.resolve(__dirname, "./src"), }, }, server: { @@ -23,15 +26,15 @@ export default defineConfig({ target: "http://127.0.0.1:8000", // Default backend address changeOrigin: true, secure: false, - rewrite: (path) => path.replace(/^\/api/, ''), - configure: (proxy, options) => { - proxy.on('error', (err, req, res) => { + rewrite: (path: string) => path.replace(/^\/api/, ''), + configure: (proxy: any, _options: any) => { + proxy.on('error', (err: any, _req: any, _res: any) => { console.log('proxy error', err); }); - proxy.on('proxyReq', (proxyReq, req, res) => { + proxy.on('proxyReq', (_proxyReq: any, req: any, _res: any) => { console.log('Sending Request to the Target:', req.method, req.url); }); - proxy.on('proxyRes', (proxyRes, req, res) => { + proxy.on('proxyRes', (proxyRes: any, req: any, _res: any) => { console.log('Received Response from the Target:', proxyRes.statusCode, req.url); }); },