Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
eyurtsev committed Feb 15, 2024
1 parent bc99d1b commit 1fd4126
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions docs/docs/modules/model_io/chat/custom_chat_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@
":::\n"
]
},
{
"cell_type": "markdown",
"id": "6c61c165-975a-4cad-aa7c-5e5d9e2dedd2",
"metadata": {},
"source": [
"### Implementation"
]
},
{
"cell_type": "code",
"execution_count": 23,
Expand Down Expand Up @@ -241,7 +249,7 @@
"id": "714dede0",
"metadata": {},
"source": [
"### Let's test it 🧪\n",
"### Using it\n",
"\n",
"The chat model will implement the standard `Runnable` interface of LangChain which many of the LangChain abstractions support!"
]
Expand Down Expand Up @@ -408,7 +416,7 @@
"id": "bbfebea1",
"metadata": {},
"source": [
"## BaseChatModel\n",
"## Base Chat Model\n",
"\n",
"You may want to add additional features like function calling or running the model in JSON mode or streaming.\n",
"\n",
Expand All @@ -422,10 +430,18 @@
"* `_agenerate` - Use to implement a native async method "
]
},
{
"cell_type": "markdown",
"id": "8e7047bd-c235-46f6-85e1-d6d7e0868eb1",
"metadata": {},
"source": [
"### Implementation"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "d309a719-087e-4e39-a291-6aaa16da7a55",
"execution_count": null,
"id": "25ba32e5-5a6d-49f4-bb68-911827b84d61",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -568,7 +584,7 @@
"id": "1e9af284-f2d3-44e2-ac6a-09b73d89ada3",
"metadata": {},
"source": [
"### Let's test it 🧪\n",
"### Using it\n",
"\n",
"The chat model will implement the standard `Runnable` interface of LangChain which many of the LangChain abstractions support!"
]
Expand Down Expand Up @@ -753,24 +769,32 @@
"An overview of things to verify to make sure that the implementation is done correctly.\n",
"\n",
"Documentation:\n",
"- [ ] The model contains doc-strings for all initialization arguments, as these will be surfaced in the [APIReference](https://api.python.langchain.com/en/stable/langchain_api_reference.html).\n",
"- [ ] The class doc-string for the model contains a link to the model API if the model is powered by a service.\n",
"* The model contains doc-strings for all initialization arguments, as these will be surfaced in the [APIReference](https://api.python.langchain.com/en/stable/langchain_api_reference.html).\n",
"* The class doc-string for the model contains a link to the model API if the model is powered by a service.\n",
"\n",
"Tests:\n",
"- [ ] Add unit or integration tests to the overridden methods. Verify that `invoke`, `ainvoke`, `batch`, `stream` work if you've over-ridden the corresponding code.\n",
"* Add unit or integration tests to the overridden methods. Verify that `invoke`, `ainvoke`, `batch`, `stream` work if you've over-ridden the corresponding code.\n",
"\n",
"Streaming (if you're implementing it):\n",
"- [ ] Provided an async implementation via `_astream`\n",
"- [ ] Make sure to invoke the `on_llm_new_token` callback\n",
"- [ ] `on_llm_new_token` is invoked BEFORE yielding the chunk\n",
"* Provided an async implementation via `_astream`\n",
"* Make sure to invoke the `on_llm_new_token` callback\n",
"* `on_llm_new_token` is invoked BEFORE yielding the chunk\n",
"\n",
"Stop Token Behavior:\n",
"- [ ] Stop token should be respected\n",
"- [ ] Stop token should be INCLUDED as part of the response\n",
"* Stop token should be respected\n",
"* Stop token should be INCLUDED as part of the response\n",
"\n",
"Secret API Keys:\n",
"- [ ] If your model connects to an API it will likely accept API keys as part of its initialization. Use Pydantic's `SecretStr` type for secrets, so they don't get accidentally printed out when folks print the model."
"* If your model connects to an API it will likely accept API keys as part of its initialization. Use Pydantic's `SecretStr` type for secrets, so they don't get accidentally printed out when folks print the model."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4f3bbb70-5568-4bfe-810c-ad83fdf76dac",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 1fd4126

Please sign in to comment.