跳到主要內容
Open In ColabOpen on GitHub

Steam 工具組

Steam (維基百科) 是一個由 Valve Corporation 開發的電子遊戲數位發行服務和商店。它為 Valve 的遊戲提供自動遊戲更新,並擴展到發行第三方遊戲。 Steam 提供各種功能,例如使用 Valve 反作弊措施的遊戲伺服器配對、社交網路和遊戲串流服務。

Steam 是遊玩、討論和創作遊戲的終極目的地。

Steam 工具組有兩個工具

  • 遊戲詳情
  • 推薦遊戲

本筆記本逐步示範如何使用 Steam API 和 LangChain,根據您目前的 Steam 遊戲庫檢索 Steam 遊戲推薦,或收集您提供的一些 Steam 遊戲的相關資訊。

設定

我們必須安裝兩個 Python 函式庫。

導入

%pip install --upgrade --quiet  python-steam-api python-decouple

指定環境變數

若要使用此工具組,請準備好您的 OpenAI API 金鑰、Steam API 金鑰(從這裡取得)和您自己的 SteamID。收到 Steam API 金鑰後,您可以將其作為環境變數輸入在下方。工具組會讀取「STEAM_KEY」API 金鑰作為環境變數來驗證您的身分,因此請在此處設定。您還需要設定您的「OPENAI_API_KEY」和「STEAM_ID」。

import os

os.environ["STEAM_KEY"] = "xyz"
os.environ["STEAM_ID"] = "123"
os.environ["OPENAI_API_KEY"] = "abc"

初始化:

初始化 LLM、SteamWebAPIWrapper、SteamToolkit 以及最重要的 langchain 代理程式來處理您的查詢!

範例

from langchain.agents import AgentType, initialize_agent
from langchain_community.agent_toolkits.steam.toolkit import SteamToolkit
from langchain_community.utilities.steam import SteamWebAPIWrapper
from langchain_openai import OpenAI
llm = OpenAI(temperature=0)
Steam = SteamWebAPIWrapper()
toolkit = SteamToolkit.from_steam_api_wrapper(Steam)
agent = initialize_agent(
toolkit.get_tools(), llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)
out = agent("can you give the information about the game Terraria")
print(out)


> Entering new AgentExecutor chain...
 I need to find the game details
Action: Get Games Details
Action Input: Terraria
Observation: 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

Thought: I now know the final answer
Final Answer: Terraria is a game with an id of 105600, a link of https://store.steampowered.com/app/105600/Terraria/?snr=1_7_15__13, a price of $9.99, a summary of "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

> Finished chain.
{'input': 'can you give the information about the game Terraria', 'output': 'Terraria is a game with an id of 105600, a link of https://store.steampowered.com/app/105600/Terraria/?snr=1_7_15__13, a price of $9.99, a summary of "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'}

此頁面是否對您有幫助?