mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 23:29:21 +00:00
core[patch]: Add an example to the Document schema doc-string (#23131)
Add an example to the document schema
This commit is contained in:
parent
2b08e9e265
commit
883e90d06e
@ -7,7 +7,19 @@ from langchain_core.pydantic_v1 import Field
|
|||||||
|
|
||||||
|
|
||||||
class Document(Serializable):
|
class Document(Serializable):
|
||||||
"""Class for storing a piece of text and associated metadata."""
|
"""Class for storing a piece of text and associated metadata.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from langchain_core.documents import Document
|
||||||
|
|
||||||
|
document = Document(
|
||||||
|
page_content="Hello, world!",
|
||||||
|
metadata={"source": "https://example.com"}
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
page_content: str
|
page_content: str
|
||||||
"""String text."""
|
"""String text."""
|
||||||
|
@ -40,8 +40,9 @@ class AIMessage(BaseMessage):
|
|||||||
"""Message from an AI."""
|
"""Message from an AI."""
|
||||||
|
|
||||||
example: bool = False
|
example: bool = False
|
||||||
"""Whether this Message is being passed in to the model as part of an example
|
"""Use to denote that a message is part of an example conversation.
|
||||||
conversation.
|
|
||||||
|
At the moment, this is ignored by most models. Usage is discouraged.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tool_calls: List[ToolCall] = []
|
tool_calls: List[ToolCall] = []
|
||||||
|
@ -7,8 +7,9 @@ class HumanMessage(BaseMessage):
|
|||||||
"""Message from a human."""
|
"""Message from a human."""
|
||||||
|
|
||||||
example: bool = False
|
example: bool = False
|
||||||
"""Whether this Message is being passed in to the model as part of an example
|
"""Use to denote that a message is part of an example conversation.
|
||||||
conversation.
|
|
||||||
|
At the moment, this is ignored by most models. Usage is discouraged.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type: Literal["human"] = "human"
|
type: Literal["human"] = "human"
|
||||||
|
@ -306,7 +306,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
|
|||||||
"definitions": {
|
"definitions": {
|
||||||
"Document": {
|
"Document": {
|
||||||
"title": "Document",
|
"title": "Document",
|
||||||
"description": "Class for storing a piece of text and associated metadata.", # noqa: E501
|
"description": AnyStr(),
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"page_content": {"title": "Page Content", "type": "string"},
|
"page_content": {"title": "Page Content", "type": "string"},
|
||||||
@ -396,7 +396,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
|
|||||||
},
|
},
|
||||||
"AIMessage": {
|
"AIMessage": {
|
||||||
"title": "AIMessage",
|
"title": "AIMessage",
|
||||||
"description": "Message from an AI.",
|
"description": AnyStr(),
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"content": {
|
"content": {
|
||||||
@ -450,7 +450,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
|
|||||||
},
|
},
|
||||||
"HumanMessage": {
|
"HumanMessage": {
|
||||||
"title": "HumanMessage",
|
"title": "HumanMessage",
|
||||||
"description": "Message from a human.",
|
"description": AnyStr(),
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"content": {
|
"content": {
|
||||||
@ -491,7 +491,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
|
|||||||
},
|
},
|
||||||
"ChatMessage": {
|
"ChatMessage": {
|
||||||
"title": "ChatMessage",
|
"title": "ChatMessage",
|
||||||
"description": "Message that can be assigned an arbitrary speaker (i.e. role).", # noqa: E501
|
"description": AnyStr(),
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"content": {
|
"content": {
|
||||||
@ -528,7 +528,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
|
|||||||
},
|
},
|
||||||
"SystemMessage": {
|
"SystemMessage": {
|
||||||
"title": "SystemMessage",
|
"title": "SystemMessage",
|
||||||
"description": "Message for priming AI behavior, usually passed in as the first of a sequence\nof input messages.", # noqa: E501
|
"description": AnyStr(),
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"content": {
|
"content": {
|
||||||
@ -564,7 +564,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
|
|||||||
},
|
},
|
||||||
"FunctionMessage": {
|
"FunctionMessage": {
|
||||||
"title": "FunctionMessage",
|
"title": "FunctionMessage",
|
||||||
"description": "Message for passing the result of executing a function back to a model.", # noqa: E501
|
"description": AnyStr(),
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"content": {
|
"content": {
|
||||||
@ -600,7 +600,7 @@ def test_schemas(snapshot: SnapshotAssertion) -> None:
|
|||||||
},
|
},
|
||||||
"ToolMessage": {
|
"ToolMessage": {
|
||||||
"title": "ToolMessage",
|
"title": "ToolMessage",
|
||||||
"description": "Message for passing the result of executing a tool back to a model.", # noqa: E501
|
"description": AnyStr(),
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"content": {
|
"content": {
|
||||||
|
Loading…
Reference in New Issue
Block a user