当今,大型语言模型(LLM)已经成为人工智能领域的热门话题。近期,Gemini发布了一款新的大模型,而LangChain也发布了调用接口。在这篇文章中,我们将介绍如何使用LangChain调用Google的大模型Gemini。

通过 ChatGoogleGenerativeAI 和 langchain-google-genai 集成包中的类可以访问 Google gemini 和 gemini-vision 模型。
安装开发包
%pip install -U --quiet langchain-google-genai pillow
引入类和配置GOOGLE_API_KEY
import getpass
import os
if "GOOGLE_API_KEY" not in os.environ:
os.environ["GOOGLE_API_KEY"] = getpass("Provide your Google API Key")
调用Gemini模型
from langchain_google_genai import ChatGoogleGenerativeAI
llm = ChatGoogleGenerativeAI(model="gemini-pro")
result = llm.invoke("Write a ballad about LangChain")
print(result.content)
In realms where data streams like fervent tides,
Whe
588




被折叠的 条评论
为什么被折叠?



