From f5e3410e9ae1102428746686b69590082f1eccaf Mon Sep 17 00:00:00 2001 From: Deshraj Yadav Date: Wed, 3 Jan 2024 01:14:47 +0530 Subject: [PATCH] Update docs for session_id (#1105) --- docs/api-reference/pipeline/chat.mdx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/api-reference/pipeline/chat.mdx b/docs/api-reference/pipeline/chat.mdx index a8fe32e6..b044777e 100644 --- a/docs/api-reference/pipeline/chat.mdx +++ b/docs/api-reference/pipeline/chat.mdx @@ -18,6 +18,9 @@ title: '💬 chat' A dictionary of key-value pairs to filter the chunks from the vector database. Defaults to `None` + + Session ID of the chat. This can be used to maintain chat history of different user sessions. Default value: `default` + Return citations along with the LLM answer. Defaults to `False` @@ -107,3 +110,22 @@ answer = app.chat("What is the net worth of Elon?") print(answer) # Answer: The net worth of Elon Musk is $221.9 billion. ``` + +### With session id + +If you want to maintain chat sessions for different users, you can simply pass the `session_id` keyword argument. See the example below: + +```python With session id +from embedchain import App + +app = App() +app.add("https://www.forbes.com/profile/elon-musk") + +# Chat on your data using `.chat()` +app.chat("What is the net worth of Elon Musk?", session_id="user1") +# 'The net worth of Elon Musk is $250.8 billion.' +app.chat("What is the net worth of Bill Gates?", session_id="user2") +# "I don't know the current net worth of Bill Gates." +app.chat("What was my last question", session_id="user1") +# 'Your last question was "What is the net worth of Elon Musk?"' +```