Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/app/endpoints/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ def get_agent(
if conversation_id is not None:
agent = _agent_cache.get(conversation_id)
if agent:
logger.debug("Reusing existing agent with key: %s", conversation_id)
logger.debug("Reusing existing agent with conversation_id: %s", conversation_id)
return agent, conversation_id
else:
logger.debug("No existing agent found for conversation_id: %s", conversation_id)

Comment on lines +87 to 89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unnecessary else clause to improve code quality

The else clause after a return statement is unnecessary and flagged by pylint.

Apply this diff to fix the linting issue:

        if agent:
            logger.debug("Reusing existing agent with conversation_id: %s", conversation_id)
            return agent, conversation_id
-        else:
-            logger.debug("No existing agent found for conversation_id: %s", conversation_id)
+        logger.debug("No existing agent found for conversation_id: %s", conversation_id)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
else:
logger.debug("No existing agent found for conversation_id: %s", conversation_id)
if agent:
logger.debug("Reusing existing agent with conversation_id: %s", conversation_id)
return agent, conversation_id
logger.debug("No existing agent found for conversation_id: %s", conversation_id)
🤖 Prompt for AI Agents
In src/app/endpoints/query.py around lines 87 to 89, remove the else clause that
follows a return statement because it is unnecessary and flagged by pylint.
Instead, unindent the code inside the else block so it runs directly after the
if block without the else, improving code clarity and lint compliance.

logger.debug("Creating new agent")
# TODO(lucasagomes): move to ReActAgent
Expand All @@ -96,6 +98,7 @@ def get_agent(
enable_session_persistence=True,
)
conversation_id = agent.create_session(get_suid())
logger.debug("Created new agent and conversation_id: %s", conversation_id)
_agent_cache[conversation_id] = agent
return agent, conversation_id

Expand Down
5 changes: 4 additions & 1 deletion src/app/endpoints/streaming_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ async def get_agent(
if conversation_id is not None:
agent = _agent_cache.get(conversation_id)
if agent:
logger.debug("Reusing existing agent with key: %s", conversation_id)
logger.debug("Reusing existing agent with conversation_id: %s", conversation_id)
return agent, conversation_id
else:
logger.debug("No existing agent found for conversation_id: %s", conversation_id)

Comment on lines +58 to 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unnecessary else clause to improve code quality

Same issue as in query.py - the else clause after a return statement is unnecessary and flagged by pylint.

Apply this diff to fix the linting issue:

        if agent:
            logger.debug("Reusing existing agent with conversation_id: %s", conversation_id)
            return agent, conversation_id
-        else:
-            logger.debug("No existing agent found for conversation_id: %s", conversation_id)
+        logger.debug("No existing agent found for conversation_id: %s", conversation_id)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
else:
logger.debug("No existing agent found for conversation_id: %s", conversation_id)
if agent:
logger.debug("Reusing existing agent with conversation_id: %s", conversation_id)
return agent, conversation_id
logger.debug("No existing agent found for conversation_id: %s", conversation_id)
🤖 Prompt for AI Agents
In src/app/endpoints/streaming_query.py around lines 58 to 60, remove the else
clause that follows a return statement to improve code quality and fix the
pylint warning. Instead of using else after return, unindent the code inside the
else block so it runs directly after the if block, eliminating the unnecessary
else.

logger.debug("Creating new agent")
agent = AsyncAgent(
Expand All @@ -66,6 +68,7 @@ async def get_agent(
enable_session_persistence=True,
)
conversation_id = await agent.create_session(get_suid())
logger.debug("Created new agent and conversation_id: %s", conversation_id)
_agent_cache[conversation_id] = agent
return agent, conversation_id

Expand Down
Loading