diff options
| author | Dhravya <[email protected]> | 2024-04-13 01:53:50 -0700 |
|---|---|---|
| committer | Dhravya <[email protected]> | 2024-04-13 01:53:50 -0700 |
| commit | f0b2412a8b9b01ab5807dbb807eedb5cd46c69d4 (patch) | |
| tree | b0f9b885eb7bbf16f9729ad93ed7458476ab54ac | |
| parent | switch to cloudfalre (diff) | |
| download | supermemory-f0b2412a8b9b01ab5807dbb807eedb5cd46c69d4.tar.xz supermemory-f0b2412a8b9b01ab5807dbb807eedb5cd46c69d4.zip | |
CloudflareAI for better streaming
| -rw-r--r-- | apps/cf-ai-backend/src/routes/chat.ts | 3 | ||||
| -rw-r--r-- | apps/web/src/components/Main.tsx | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/apps/cf-ai-backend/src/routes/chat.ts b/apps/cf-ai-backend/src/routes/chat.ts index 75c7b426..4dfcde5d 100644 --- a/apps/cf-ai-backend/src/routes/chat.ts +++ b/apps/cf-ai-backend/src/routes/chat.ts @@ -139,7 +139,8 @@ export async function POST(request: Request, _: CloudflareVectorizeStore, embedd // ); // return response; const ai = new Ai(env?.AI); - const output: AiTextGenerationOutput = (await ai.run('@hf/thebloke/mistral-7b-instruct-v0.1-awq', { + // @ts-ignore + const output: AiTextGenerationOutput = (await ai.run('@hf/mistralai/mistral-7b-instruct-v0.2', { prompt, stream: true, })) as ReadableStream; diff --git a/apps/web/src/components/Main.tsx b/apps/web/src/components/Main.tsx index 9869a0fe..037d48a5 100644 --- a/apps/web/src/components/Main.tsx +++ b/apps/web/src/components/Main.tsx @@ -374,7 +374,10 @@ export function Chat({ loading={i === chatHistory.length - 1 ? isLoading : false} sources={msg.answer.sources} > - {msg.answer.parts.map((part) => part.text).join(" ")} + {msg.answer.parts + .map((part) => part.text) + .join("") + .replace("</s>", "")} </ChatAnswer> </ChatMessage> ))} |