-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: simplify chat history handling and update vector store inte…
…gration
- Loading branch information
Showing
4 changed files
with
36 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,16 @@ | ||
import { Embeddings } from "@langchain/core/embeddings"; | ||
import { loadTridentSurfacePrompt } from "./prompt"; | ||
import { BaseLanguageModel } from "@langchain/core/language_models/base"; | ||
import { BaseMemory } from "@langchain/core/memory"; | ||
import { RunnableSequence } from "@langchain/core/runnables"; | ||
import { BufferMemory } from "langchain/memory"; | ||
import { ConversationChain } from "langchain/chains"; | ||
import { VectorStore } from "@langchain/core/vectorstores"; | ||
|
||
export const loadTridentSurfaceChain = async ({ | ||
embeddings, | ||
llm, | ||
memory, | ||
vectorStore, | ||
}: { | ||
embeddings: Embeddings; | ||
llm: BaseLanguageModel; | ||
memory?: BaseMemory; | ||
}): Promise<ConversationChain> => { | ||
if (memory === undefined) { | ||
memory = new BufferMemory(); | ||
} | ||
const prompt = await loadTridentSurfacePrompt(embeddings); | ||
const chain = new ConversationChain({ | ||
llm: llm, | ||
prompt: prompt, | ||
memory: memory, | ||
}); | ||
vectorStore: VectorStore; | ||
}): Promise<RunnableSequence> => { | ||
const prompt = await loadTridentSurfacePrompt(vectorStore); | ||
const chain = RunnableSequence.from([prompt, llm]); | ||
return chain; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters