Skip to content

Conversation

@IngaleChinmay04
Copy link

Description

Please include a summary of the change and which issue is fixed. List any dependencies that are required for this change.

Fixes #14

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Other (please specify):

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Screenshots (if applicable)

Please include any relevant screenshots or images that help explain the changes made.

@IngaleChinmay04
Copy link
Author

@BrataBuilds
CI failure: actions/checkout is trying to fetch branch "feat/agno" from the upstream repo (MLSAKIIT/pixly) but that branch lives in the contributor’s fork (IngaleChinmay04/pixly), so git fetch exits with code 1. Failing run: https://github.com/MLSAKIIT/pixly/actions/runs/18633736291/job/53258834651?pr=20
I guess there is a issue regarding the workflow can you check it once?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds tool calling functionality to the chatbot using the Agno framework, replacing direct Gemini API calls with an agent-based architecture that provides better context management and tool integration.

Key Changes:

  • Migrated from direct genai.GenerativeModel usage to Agno's Agent class with tool support
  • Added four decorated tools for game screenshots, game detection, and knowledge search
  • Implemented SQLite-based conversation history storage

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 7 comments.

File Description
services/chatbot.py Complete refactor to use Agno Agent with tool calling, replacing direct Gemini API interactions and adding structured tool definitions
pyproject.toml Added agno and sqlalchemy dependencies to support the new agent-based architecture

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

# Configure Gemini
genai.configure(api_key=os.getenv('GOOGLE_API_KEY'),)
model = genai.GenerativeModel(model_name="gemini-2.5-flash-lite",system_instruction=system_prompt)
genai.configure(api_key=os.getenv('GEMINI_API_KEY'))
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

API key environment variable inconsistency: Line 23 uses 'GEMINI_API_KEY' while lines 66, 89, and the original code use 'GOOGLE_API_KEY'. This will cause authentication failures if GEMINI_API_KEY is not set.

Suggested change
genai.configure(api_key=os.getenv('GEMINI_API_KEY'))
genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +36
def get_game_screenshots(limit: int = 5) -> str:
"""Get recent game screenshots."""
try:
screenshots = get_recent_screenshots(limit=limit)
stats = get_screenshot_stats()
return {
"screenshots": screenshots,
"stats": stats
}
except Exception as e:
return {"error": str(e)}
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Return type annotation is incorrect. The function returns a dictionary but is annotated as returning str. This should be -> Dict[str, Any] to match the actual return value.

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +44
def get_specific_screenshot(screenshot_id: str) -> str:
"""Get a specific screenshot by ID."""
try:
return get_screenshot_by_id(screenshot_id)
except Exception as e:
return {"error": str(e)}
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Return type annotation is inconsistent. The function can return either the result from get_screenshot_by_id() or a dictionary with an error key. The return type should be -> Any or a Union type to accurately reflect both possible return types.

Copilot uses AI. Check for mistakes.
Comment on lines +47 to +52
def detect_game_context(message: str) -> str:
"""Detect the current game from message."""
try:
return detect_current_game(message)
except Exception as e:
return {"error": str(e)}
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Return type annotation is inconsistent. The function returns either the result from detect_current_game() or a dictionary with an error key, but is annotated as returning str. The return type should accurately reflect both possible return types.

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +60
def search_game_knowledge(query: str) -> str:
"""Search the knowledge base for game information."""
try:
return search_knowledge(query)
except Exception as e:
return {"error": str(e)}
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Return type annotation is inconsistent. The function returns either the result from search_knowledge() or a dictionary with an error key, but is annotated as returning str. The return type should accurately reflect both possible return types.

Copilot uses AI. Check for mistakes.
Comment on lines +147 to +148
if game_context:
enhanced_message += f"\n\nDETECTED GAME: {game_context.upper()}"
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Variable enhanced_message is only defined when image_data is provided (line 129), but this code assumes it always exists. If there's no image_data, this will raise an UnboundLocalError. The enhanced_message variable should be initialized before the image_data check or this block should be inside the if image_data condition.

Copilot uses AI. Check for mistakes.
Comment on lines +152 to +155
async for response in agent.arun(
message,
**run_params
):
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

When image_data is provided, the message variable is reassigned to enhanced_message on line 144, but then the agent is called with the original message parameter on line 153. This means the enhanced message with game context is never used. Line 153 should use the potentially modified message variable or create a new variable to track the final message to send.

Copilot uses AI. Check for mistakes.
@BrataBuilds
Copy link
Collaborator

BrataBuilds commented Oct 22, 2025

@BrataBuilds CI failure: actions/checkout is trying to fetch branch "feat/agno" from the upstream repo (MLSAKIIT/pixly) but that branch lives in the contributor’s fork (IngaleChinmay04/pixly), so git fetch exits with code 1. Failing run: https://github.com/MLSAKIIT/pixly/actions/runs/18633736291/job/53258834651?pr=20 I guess there is a issue regarding the workflow can you check it once?

I will be testing the code locally on my system once.
Since our main repo doesnt have the branch feat/agno it is returning that error.

@BrataBuilds
Copy link
Collaborator

BrataBuilds commented Oct 22, 2025

It appears that your code contains multiple issues:

  1. The implementation is not functioning as intended due to issues with the API key handling logic.
  2. The submission does not include clear documentation or references to the tools that have been added, nor an explanation of their respective purposes.
  3. The system prompt has not been updated to inform the LLM of the newly available tools, which is required for proper integration.
  4. Inccorrect variable assignment in line 153 causes the following bug When image_data is provided, the message variable is reassigned to enhanced_message on line 144, but then the agent is called with the original message parameter on line 153. This means the enhanced message with game context is never used. Line 153 should use the potentially modified message variable or create a new variable to track the final message to send.

Please rectify these issues, also do test the code thoroughly on your system as well before submitting another PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add toolcalling to chatbot.py using Agno to improve contextual qeuries

2 participants