Spaces:
Runtime error
Runtime error
matt HOFFNER
commited on
Commit
Β·
8de5da8
1
Parent(s):
c93eac4
cleanup
Browse files- src/components/ChatV2.jsx +1 -1
- src/components/ChatWindow.jsx +0 -3
- src/components/Loader.jsx +10 -7
src/components/ChatV2.jsx
CHANGED
@@ -7,7 +7,7 @@ export default function Chat() {
|
|
7 |
<div>
|
8 |
<div className="flex justify-center m-3 gap-2">
|
9 |
<div className="sm:w-[500px] w-full">
|
10 |
-
<ChatWindow />
|
11 |
</div>
|
12 |
</div>
|
13 |
</div>
|
|
|
7 |
<div>
|
8 |
<div className="flex justify-center m-3 gap-2">
|
9 |
<div className="sm:w-[500px] w-full">
|
10 |
+
<ChatWindow maxTokens={300}/>
|
11 |
</div>
|
12 |
</div>
|
13 |
</div>
|
src/components/ChatWindow.jsx
CHANGED
@@ -28,18 +28,15 @@ function ChatWindow({
|
|
28 |
}
|
29 |
|
30 |
if (fileText) {
|
31 |
-
console.log('found file text splitting into chunks')
|
32 |
const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });
|
33 |
const docs = await textSplitter.createDocuments([fileText]);
|
34 |
let qaPrompt;
|
35 |
-
console.log(docs);
|
36 |
try {
|
37 |
const vectorStore = await MemoryVectorStore.fromTexts(
|
38 |
[...docs.map(doc => doc.pageContent)],
|
39 |
[...docs.map((v, k) => k)],
|
40 |
new XenovaTransformersEmbeddings()
|
41 |
)
|
42 |
-
console.log(vectorStore);
|
43 |
const queryResult = await vectorStore.similaritySearch(userInput, 1);
|
44 |
console.log("queryResult", queryResult);
|
45 |
qaPrompt =
|
|
|
28 |
}
|
29 |
|
30 |
if (fileText) {
|
|
|
31 |
const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });
|
32 |
const docs = await textSplitter.createDocuments([fileText]);
|
33 |
let qaPrompt;
|
|
|
34 |
try {
|
35 |
const vectorStore = await MemoryVectorStore.fromTexts(
|
36 |
[...docs.map(doc => doc.pageContent)],
|
37 |
[...docs.map((v, k) => k)],
|
38 |
new XenovaTransformersEmbeddings()
|
39 |
)
|
|
|
40 |
const queryResult = await vectorStore.similaritySearch(userInput, 1);
|
41 |
console.log("queryResult", queryResult);
|
42 |
qaPrompt =
|
src/components/Loader.jsx
CHANGED
@@ -11,9 +11,9 @@ const Loader = () => {
|
|
11 |
<p style={{ color: "red" }}>Sorry, unsupported!</p>
|
12 |
<p> Reason: {gpuDevice.unsupportedReason}</p>
|
13 |
<p>
|
14 |
-
|
15 |
the browser with WebGPU and only works in Google Chrome v113 and above
|
16 |
-
on Desktop with supported GPUs.
|
17 |
</p>
|
18 |
</div>
|
19 |
);
|
@@ -33,8 +33,11 @@ const Loader = () => {
|
|
33 |
}}
|
34 |
>
|
35 |
<div className="lg:hidden">
|
|
|
|
|
|
|
36 |
<p className="p-1">
|
37 |
-
|
38 |
</p>
|
39 |
<p className="p-1">
|
40 |
No data is sent to the server. Conversations are cached in local
|
@@ -47,13 +50,13 @@ const Loader = () => {
|
|
47 |
Powered by Apache TVM and MLC Relax Runtime.
|
48 |
</p>
|
49 |
<p className="p-1">
|
50 |
-
Model is Vicuna 7b trained by
|
51 |
</p>
|
52 |
</div>
|
53 |
<div>
|
54 |
-
This will download the model and may take a few minutes. After the
|
55 |
-
first time, it will be cached.
|
56 |
-
</div>
|
57 |
|
58 |
<button
|
59 |
style={{ padding: "10px" }}
|
|
|
11 |
<p style={{ color: "red" }}>Sorry, unsupported!</p>
|
12 |
<p> Reason: {gpuDevice.unsupportedReason}</p>
|
13 |
<p>
|
14 |
+
This project runs models in
|
15 |
the browser with WebGPU and only works in Google Chrome v113 and above
|
16 |
+
on Desktop with supported GPUs. Experimental support may be available for desktop Firefox and Safari Tech Preview.
|
17 |
</p>
|
18 |
</div>
|
19 |
);
|
|
|
33 |
}}
|
34 |
>
|
35 |
<div className="lg:hidden">
|
36 |
+
<h1 className="p-1">
|
37 |
+
<b>π web-llm-embed π</b>
|
38 |
+
</h1>
|
39 |
<p className="p-1">
|
40 |
+
Proof of concept using Transformers.js embeddings in a WebGPU powered LLM chat.
|
41 |
</p>
|
42 |
<p className="p-1">
|
43 |
No data is sent to the server. Conversations are cached in local
|
|
|
50 |
Powered by Apache TVM and MLC Relax Runtime.
|
51 |
</p>
|
52 |
<p className="p-1">
|
53 |
+
Model is Vicuna 7b trained by LMSys.
|
54 |
</p>
|
55 |
</div>
|
56 |
<div>
|
57 |
+
This will download the model (~4GB) and may take a few minutes. After the
|
58 |
+
first time, it will be cached. It can be deleted in Dev Tools Cache Storage (tvmjs).
|
59 |
+
</div>
|
60 |
|
61 |
<button
|
62 |
style={{ padding: "10px" }}
|