Source code for langchain_community.utilities.steam
"""Util that calls Steam-WebAPI."""
from typing import Any, List
from langchain_core.pydantic_v1 import BaseModel, Extra, root_validator
[docs]class SteamWebAPIWrapper(BaseModel):
    """Wrapper for Steam API."""
    steam: Any  # for python-steam-api
    from langchain_community.tools.steam.prompt import (
        STEAM_GET_GAMES_DETAILS,
        STEAM_GET_RECOMMENDED_GAMES,
    )
    # operations: a list of dictionaries, each representing a specific operation that
    # can be performed with the API
    operations: List[dict] = [
        {
            "mode": "get_game_details",
            "name": "Get Game Details",
            "description": STEAM_GET_GAMES_DETAILS,
        },
        {
            "mode": "get_recommended_games",
            "name": "Get Recommended Games",
            "description": STEAM_GET_RECOMMENDED_GAMES,
        },
    ]
    class Config:
        """Configuration for this pydantic object."""
        extra = Extra.forbid
[docs]    def get_operations(self) -> List[dict]:
        """Return a list of operations."""
        return self.operations
    @root_validator
    def validate_environment(cls, values: dict) -> dict:
        """Validate api key and python package has been configured."""
        # check if the python package is installed
        try:
            from steam import Steam
        except ImportError:
            raise ImportError("python-steam-api library is not installed. ")
        try:
            from decouple import config
        except ImportError:
            raise ImportError("decouple library is not installed. ")
        # initialize the steam attribute for python-steam-api usage