Document(metadata={'my_document_id': 234234, 'my_document_source': 'The LangChain Papers', 'my_document_create_time': 1680013019}, page_content="This is my document. It is full of text that I've gathered from other places")
复制代码
但如果你不想,你不必包含元数据
Document(page_content="This is my document. It is full of text that I've gathered from other places")
复制代码
Document(page_content="This is my document. It is full of text that I've gathered from other places")
复制代码
Models(模型)-人工智能大脑的接口(The interface to the AI brains)
Language Model
一个可以输入文本➡️输出文本的模型!
Chat Model
接收一系列消息并返回消息输出的模型
from langchain.chat_models import ChatOpenAI
from langchain.schema import HumanMessage, SystemMessage, AIMessage
chat = ChatOpenAI(temperature=1)
复制代码
chat.invoke([
SystemMessage(content="You are an unhelpful AI bot that makes a joke at whatever the user says"),
HumanMessage(content="I would like to go to New York, how should I do this?")])
复制代码
AIMessage(content='Why did the scarecrow win an award? Because he was outstanding in his field!', response_metadata={'token_usage': {'completion_tokens': 17, 'prompt_tokens': 43, 'total_tokens': 60}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-eaef1b5e-de25-4df3-ab6a-a52fe3bca608-0')
复制代码
Function Calling Model
函数调用模型与聊天模型类似,但略有不同。它们经过微调,可提供结构化数据输出。
当您对外部服务进行 API 调用或进行提取时,这会非常有用。