Improve IGDB search capabilities.
This commit is contained in:
@@ -320,6 +320,50 @@ class OpenAIResponder(AIResponder, LeonardoAIDrawMixIn):
|
||||
else:
|
||||
return {"games": [], "message": f"No games found matching '{query}'"}
|
||||
|
||||
elif function_name == "get_games_by_release_date":
|
||||
year = function_args.get("year")
|
||||
month = function_args.get("month")
|
||||
platform = function_args.get("platform")
|
||||
limit = function_args.get("limit", 10)
|
||||
|
||||
logging.info(
|
||||
f"🎮 Searching IGDB for games releasing in {year}/{month or 'all'} on {platform or 'all platforms'} (limit: {limit})"
|
||||
)
|
||||
|
||||
if not year:
|
||||
logging.warning("🎮 No year provided to get_games_by_release_date")
|
||||
return {"error": "No year provided"}
|
||||
|
||||
results = self.igdb.get_games_by_release_date(year, month, platform, limit)
|
||||
logging.info(f"🎮 IGDB release date search returned: {len(results) if results and isinstance(results, list) else 0} results")
|
||||
|
||||
if results and isinstance(results, list) and len(results) > 0:
|
||||
return {"games": results}
|
||||
else:
|
||||
period = f"{year}/{month}" if month else str(year)
|
||||
platform_text = f" on {platform}" if platform else ""
|
||||
return {"games": [], "message": f"No games found releasing in {period}{platform_text}"}
|
||||
|
||||
elif function_name == "get_games_by_platform":
|
||||
platform = function_args.get("platform", "")
|
||||
genre = function_args.get("genre")
|
||||
limit = function_args.get("limit", 10)
|
||||
|
||||
logging.info(f"🎮 Searching IGDB for games on {platform} {f'in {genre} genre' if genre else ''} (limit: {limit})")
|
||||
|
||||
if not platform:
|
||||
logging.warning("🎮 No platform provided to get_games_by_platform")
|
||||
return {"error": "No platform provided"}
|
||||
|
||||
results = self.igdb.get_games_by_platform(platform, genre, limit)
|
||||
logging.info(f"🎮 IGDB platform search returned: {len(results) if results and isinstance(results, list) else 0} results")
|
||||
|
||||
if results and isinstance(results, list) and len(results) > 0:
|
||||
return {"games": results}
|
||||
else:
|
||||
genre_text = f" in {genre} genre" if genre else ""
|
||||
return {"games": [], "message": f"No games found for {platform}{genre_text}"}
|
||||
|
||||
elif function_name == "get_game_details":
|
||||
game_id = function_args.get("game_id")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user