Spaces:
Runtime error
Runtime error
matt HOFFNER
commited on
Commit
Β·
c63af75
1
Parent(s):
5e14bd6
cleanup
Browse files
src/components/ChatWindow.jsx
CHANGED
|
@@ -5,6 +5,7 @@ import MessageList from './MessageList';
|
|
| 5 |
import {FileLoader} from './FileLoader';
|
| 6 |
import { db } from '@/utils/db-client';
|
| 7 |
import Loader from "./Loader";
|
|
|
|
| 8 |
|
| 9 |
function ChatWindow({
|
| 10 |
stopStrings,
|
|
@@ -28,7 +29,7 @@ function ChatWindow({
|
|
| 28 |
if (fileId) {
|
| 29 |
const similarityMatches = 2;
|
| 30 |
const fileContents = await db.docs.get(fileId);
|
| 31 |
-
const vectorStore = await
|
| 32 |
const result = await vectorStore.similaritySearch(userInput, similarityMatches);
|
| 33 |
const qaPrompt =
|
| 34 |
`You are an AI assistant providing helpful advice. You are given the following extracted parts of a long document and a question. Provide a conversational answer based on the context provided.
|
|
@@ -75,7 +76,6 @@ function ChatWindow({
|
|
| 75 |
}
|
| 76 |
|
| 77 |
useEffect(() => {
|
| 78 |
-
console.log('have a fileId, look it up and summarize after uploading for demo');
|
| 79 |
loadFile();
|
| 80 |
|
| 81 |
}, [fileId])
|
|
|
|
| 5 |
import {FileLoader} from './FileLoader';
|
| 6 |
import { db } from '@/utils/db-client';
|
| 7 |
import Loader from "./Loader";
|
| 8 |
+
import { Chroma } from "langchain/vectorstores/chroma";
|
| 9 |
|
| 10 |
function ChatWindow({
|
| 11 |
stopStrings,
|
|
|
|
| 29 |
if (fileId) {
|
| 30 |
const similarityMatches = 2;
|
| 31 |
const fileContents = await db.docs.get(fileId);
|
| 32 |
+
const vectorStore = await Chroma.fromDocuments(fileContents, new XenovaTransformersEmbeddings());
|
| 33 |
const result = await vectorStore.similaritySearch(userInput, similarityMatches);
|
| 34 |
const qaPrompt =
|
| 35 |
`You are an AI assistant providing helpful advice. You are given the following extracted parts of a long document and a question. Provide a conversational answer based on the context provided.
|
|
|
|
| 76 |
}
|
| 77 |
|
| 78 |
useEffect(() => {
|
|
|
|
| 79 |
loadFile();
|
| 80 |
|
| 81 |
}, [fileId])
|