查看原文
其他

【AIGC 学习】获取电影信息 - LangChain 使用5

昨天学习了如何使用 Langchain 查询天气,Langchain API 还可以做很多事情,比如查询电影:

先获取 TMDB 的token:https://www.themoviedb.org/settings/api

然后开始配置环境

import os
os.environ['TMDB_BEARER_TOKEN'] = ""
from langchain.chains.api import tmdb_docs
headers = {"Authorization": f"Bearer {os.environ['TMDB_BEARER_TOKEN']}"}
chain = APIChain.from_llm_and_api_docs(llm, tmdb_docs.TMDB_DOCS, headers=headers, verbose=True)

如果查询电影名

chain.run("Search for 'metaverse'")

就可以返回电影列表

This response contains 7 movies related to the search query 'metaverse'. The movies include 'Metaverse', 'Devotional to a Metaverse', 'Inside the Metaverse', 'NFTs: Enter the Metaverse', 'DinoGames. Adventures in the Metaverse', 'Metaverse of Madness', and 'Metaverse'.

也可以问问电影内容

chain.run("tell me more about 'metaverse'")

返回的结果就综合了电影的情节:

The response from the API contains 7 movies related to the term 'metaverse'. These movies explore a dystopian future where VR becomes normal, a group of friends being transported into the metaverse in flesh and bones, a video making a case for two subjects' points of view, a documentary about the gold-rush-like hysteria surrounding NFTs, a world split in two between factual and virtual reality, and more.


继续滑动看下一个
Renee 创业随笔
向上滑动看下一个

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存