跳到主要內容

NASA 工具包

此筆記本展示如何使用代理與 NASA 工具包互動。此工具包提供 NASA 圖像和影片庫 API 的存取權,並有可能在未來迭代中擴展和包含其他可存取的 NASA API。

注意:當未指定所需媒體結果數量時,NASA 圖像和影片庫搜尋查詢可能會產生大量回應。在使用具有 LLM 代幣額度的代理之前,請考慮這一點。

使用範例:


初始化代理

%pip install -qU langchain-community
from langchain.agents import AgentType, initialize_agent
from langchain_community.agent_toolkits.nasa.toolkit import NasaToolkit
from langchain_community.utilities.nasa import NasaAPIWrapper
from langchain_openai import OpenAI

llm = OpenAI(temperature=0, openai_api_key="")
nasa = NasaAPIWrapper()
toolkit = NasaToolkit.from_nasa_api_wrapper(nasa)
agent = initialize_agent(
toolkit.get_tools(), llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True
)

查詢媒體資產

agent.run(
"Can you find three pictures of the moon published between the years 2014 and 2020?"
)

查詢媒體資產詳細資訊

output = agent.run(
"I've just queried an image of the moon with the NASA id NHQ_2019_0311_Go Forward to the Moon."
" Where can I find the metadata manifest for this asset?"
)

此頁面是否對您有幫助?