From 2b5059ea256b2ccf0bc1c8f2f0a14a5494d7eb9b Mon Sep 17 00:00:00 2001 From: Kostas Minaidis Date: Tue, 9 Jul 2024 23:35:50 +0200 Subject: [PATCH 1/4] Update concepts.mdx Just adding a missing period. --- docs/core_docs/docs/concepts.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core_docs/docs/concepts.mdx b/docs/core_docs/docs/concepts.mdx index f7ef36afbccd..b4e64d96697c 100644 --- a/docs/core_docs/docs/concepts.mdx +++ b/docs/core_docs/docs/concepts.mdx @@ -434,7 +434,7 @@ An essential component of a conversation is being able to refer to information i At bare minimum, a conversational system should be able to access some window of past messages directly. The concept of `ChatHistory` refers to a class in LangChain which can be used to wrap an arbitrary chain. -This `ChatHistory` will keep track of inputs and outputs of the underlying chain, and append them as messages to a message database +This `ChatHistory` will keep track of inputs and outputs of the underlying chain, and append them as messages to a message database. Future interactions will then load those messages and pass them into the chain as part of the input. ### Document From c819bbb8e4e8d7218ece9a3799fd21dbe640892a Mon Sep 17 00:00:00 2001 From: Kostas Minaidis Date: Sat, 27 Jul 2024 01:52:46 +0200 Subject: [PATCH 2/4] Remove unnecessary else/if statements Make the code example cleaner and easier to read by removing unnecessary else/if statements. --- .../expression_language/how_to_routing_custom_function.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/src/guides/expression_language/how_to_routing_custom_function.ts b/examples/src/guides/expression_language/how_to_routing_custom_function.ts index cb1d4de80fcb..235ff0380a09 100644 --- a/examples/src/guides/expression_language/how_to_routing_custom_function.ts +++ b/examples/src/guides/expression_language/how_to_routing_custom_function.ts @@ -61,11 +61,11 @@ Answer:` const route = ({ topic }: { input: string; topic: string }) => { if (topic.toLowerCase().includes("anthropic")) { return anthropicChain; - } else if (topic.toLowerCase().includes("langchain")) { + } + if (topic.toLowerCase().includes("langchain")) { return langChainChain; - } else { - return generalChain; - } + } + return generalChain; }; const fullChain = RunnableSequence.from([ From 18fef4ac5595be24c55c89aecf0852686346a74b Mon Sep 17 00:00:00 2001 From: Kostas Minaidis Date: Sat, 27 Jul 2024 02:23:54 +0200 Subject: [PATCH 3/4] Update how_to_routing_custom_function.ts --- .../how_to_routing_custom_function.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/src/guides/expression_language/how_to_routing_custom_function.ts b/examples/src/guides/expression_language/how_to_routing_custom_function.ts index 235ff0380a09..864e6e5b6fff 100644 --- a/examples/src/guides/expression_language/how_to_routing_custom_function.ts +++ b/examples/src/guides/expression_language/how_to_routing_custom_function.ts @@ -39,7 +39,7 @@ Always answer questions starting with "As Harrison Chase told me". Respond to the following question: Question: {question} -Answer:` +Answer:`, ).pipe(model); const anthropicChain = ChatPromptTemplate.fromTemplate( @@ -48,23 +48,23 @@ Always answer questions starting with "As Dario Amodei told me". \ Respond to the following question: Question: {question} -Answer:` +Answer:`, ).pipe(model); const generalChain = ChatPromptTemplate.fromTemplate( `Respond to the following question: Question: {question} -Answer:` +Answer:`, ).pipe(model); const route = ({ topic }: { input: string; topic: string }) => { if (topic.toLowerCase().includes("anthropic")) { return anthropicChain; - } + } if (topic.toLowerCase().includes("langchain")) { return langChainChain; - } + } return generalChain; }; From d76cd5aabff3c37348fc34a0461dea0b61e1be28 Mon Sep 17 00:00:00 2001 From: Kostas Minaidis Date: Sat, 27 Jul 2024 02:28:46 +0200 Subject: [PATCH 4/4] Update how_to_routing_custom_function.ts --- .../expression_language/how_to_routing_custom_function.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/src/guides/expression_language/how_to_routing_custom_function.ts b/examples/src/guides/expression_language/how_to_routing_custom_function.ts index 864e6e5b6fff..eb1969be5257 100644 --- a/examples/src/guides/expression_language/how_to_routing_custom_function.ts +++ b/examples/src/guides/expression_language/how_to_routing_custom_function.ts @@ -39,7 +39,7 @@ Always answer questions starting with "As Harrison Chase told me". Respond to the following question: Question: {question} -Answer:`, +Answer:` ).pipe(model); const anthropicChain = ChatPromptTemplate.fromTemplate( @@ -48,14 +48,14 @@ Always answer questions starting with "As Dario Amodei told me". \ Respond to the following question: Question: {question} -Answer:`, +Answer:` ).pipe(model); const generalChain = ChatPromptTemplate.fromTemplate( `Respond to the following question: Question: {question} -Answer:`, +Answer:` ).pipe(model); const route = ({ topic }: { input: string; topic: string }) => {