跳到主要内容
Steam (维基百科) 是由 Valve Corporation 开发的视频游戏数字发行服务和商店。它为 Valve 的游戏自动提供游戏更新,并扩展到发行第三方游戏。Steam 提供各种功能,如带有 Valve 反作弊措施的游戏服务器匹配、社交网络和游戏流媒体服务。
Steam 是玩游戏、讨论游戏和创造游戏的终极目的地。
Steam 工具包包含两个工具
  • 游戏详情
  • 推荐游戏
本指南将逐步介绍如何使用 LangChain 和 Steam API,根据您当前的 Steam 游戏库检索 Steam 游戏推荐,或收集您提供的某些 Steam 游戏的信息。

设置

我们需要安装两个 Python 库。

导入

pip install -qU python-steam-api python-decouple steamspypi
Note: you may need to restart the kernel to use updated packages.

分配环境变量

要使用此工具包,请准备好您的 OpenAI API 密钥、Steam API 密钥(可在此处获取:here)以及您自己的 SteamID。获取 Steam API 密钥后,您可以将其作为环境变量输入。工具包将读取名为“STEAM_KEY”的环境变量作为 API 密钥进行身份验证,因此请在此处进行设置。您还需要设置“OPENAI_API_KEY”和“STEAM_ID”。
import os

os.environ["STEAM_KEY"] = ""
os.environ["STEAM_ID"] = ""
os.environ["OPENAI_API_KEY"] = ""

初始化

初始化 LLM、SteamWebAPIWrapper、SteamToolkit,最重要的是初始化 LangChain 代理以处理您的查询!

示例

from langchain_community.agent_toolkits.steam.toolkit import SteamToolkit
from langchain_community.utilities.steam import SteamWebAPIWrapper

steam = SteamWebAPIWrapper()
tools = [steam.run]
from langchain.agents import create_agent

agent = create_agent("gpt-4.1-mini", tools)
events = agent.stream(
    {"messages": [("user", "can you give the information about the game Terraria?")]},
    stream_mode="values",
)
for event in events:
    event["messages"][-1].pretty_print()
================================ Human Message =================================

can you give the information about the game Terraria?
================================== Ai Message ==================================
Tool Calls:
  run (call_6vHAXSIL2MPugXxlv5uyf9Xk)
 Call ID: call_6vHAXSIL2MPugXxlv5uyf9Xk
  Args:
    mode: get_games_details
    game: Terraria
================================= Tool Message =================================
Name: run

The id is: [105600]
The link is: https://store.steampowered.com/app/105600/Terraria/?snr=1_7_15__13
The price is: $9.99
The summary of the game is: Dig, Fight, Explore, Build:  The very world is at your fingertips as you fight for survival, fortune, and glory.   Will you delve deep into cavernous expanses in search of treasure and raw materials with which to craft ever-evolving gear, machinery, and aesthetics?   Perhaps you will choose instead to seek out ever-greater foes to test your mettle in combat?   Maybe you will decide to construct your own city to house the host of mysterious allies you may encounter along your travels? In the World of Terraria, the choice is yours!Blending elements of classic action games with the freedom of sandbox-style creativity, Terraria is a unique gaming experience where both the journey and the destination are completely in the player’s control.   The Terraria adventure is truly as unique as the players themselves!  Are you up for the monumental task of exploring, creating, and defending a world of your own?   Key features: Sandbox Play  Randomly generated worlds Free Content Updates
The supported languages of the game are: English, French, Italian, German, Spanish - Spain, Polish, Portuguese - Brazil, Russian, Simplified Chinese

================================== Ai Message ==================================

Terraria is a game where you can dig, fight, explore, and build in a world that is totally at your fingertips. The game gives you the freedom to survive, seek fortune, and achieve glory. You can explore cavernous expanses in search of treasure and materials to craft various gear, machinery, and aesthetic items. Alternatively, you can challenge powerful foes or construct your own city to house mysterious allies you may encounter. The game blends classic action elements with sandbox-style creativity, offering a unique experience where your journey and destination are controlled by you.

Key features of Terraria include sandbox play, randomly generated worlds, and free content updates.

The game is priced at $9.99 and supports multiple languages including English, French, Italian, German, Spanish (Spain), Polish, Portuguese (Brazil), Russian, and Simplified Chinese.

You can find more information and purchase it here: [Terraria on Steam](https://store.steampowered.com/app/105600/Terraria/?snr=1_7_15__13).

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.