fix ai streaming
This commit is contained in:
parent
b061df7f7d
commit
d59539f197
4 changed files with 9 additions and 6 deletions
|
|
@ -37,14 +37,18 @@ export async function askAi(
|
||||||
|
|
||||||
let answer = "";
|
let answer = "";
|
||||||
let sources: any[] = [];
|
let sources: any[] = [];
|
||||||
|
let buffer = "";
|
||||||
|
|
||||||
if (reader) {
|
if (reader) {
|
||||||
while (true) {
|
while (true) {
|
||||||
const { done, value } = await reader.read();
|
const { done, value } = await reader.read();
|
||||||
if (done) break;
|
if (done) break;
|
||||||
|
|
||||||
const chunk = decoder.decode(value);
|
buffer += decoder.decode(value, { stream: true });
|
||||||
const lines = chunk.split("\n");
|
const lines = buffer.split("\n");
|
||||||
|
|
||||||
|
// Keep the last incomplete line in the buffer
|
||||||
|
buffer = lines.pop() || "";
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.startsWith("data: ")) {
|
if (line.startsWith("data: ")) {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 18e00b18666060e43906740fd28c8a64800637c8
|
Subproject commit 075761c2d9bcae7adcc3de4b1c5b8f8c3b315878
|
||||||
|
|
@ -117,7 +117,7 @@ export class EnvironmentVariables {
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ValidateIf((obj) => obj.AI_EMBEDDING_DIMENSION)
|
@ValidateIf((obj) => obj.AI_EMBEDDING_DIMENSION)
|
||||||
@IsIn(['768', '1024', '1536'])
|
@IsIn(['768', '1024', '1536', '2000'])
|
||||||
@IsString()
|
@IsString()
|
||||||
AI_EMBEDDING_DIMENSION: string;
|
AI_EMBEDDING_DIMENSION: string;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { Editor, findParentNode, isTextSelection } from "@tiptap/core";
|
||||||
import { Selection, Transaction } from "@tiptap/pm/state";
|
import { Selection, Transaction } from "@tiptap/pm/state";
|
||||||
import { CellSelection, TableMap } from "@tiptap/pm/tables";
|
import { CellSelection, TableMap } from "@tiptap/pm/tables";
|
||||||
import { Node, ResolvedPos } from "@tiptap/pm/model";
|
import { Node, ResolvedPos } from "@tiptap/pm/model";
|
||||||
import Table from "@tiptap/extension-table";
|
|
||||||
import { sanitizeUrl as braintreeSanitizeUrl } from "@braintree/sanitize-url";
|
import { sanitizeUrl as braintreeSanitizeUrl } from "@braintree/sanitize-url";
|
||||||
import { customAlphabet } from "nanoid";
|
import { customAlphabet } from "nanoid";
|
||||||
|
|
||||||
|
|
@ -289,7 +288,7 @@ export const isColumnGripSelected = ({
|
||||||
const node = nodeDOM || domAtPos;
|
const node = nodeDOM || domAtPos;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!editor.isActive(Table.name) ||
|
!editor.isActive("table") ||
|
||||||
!node ||
|
!node ||
|
||||||
isTableSelected(state.selection)
|
isTableSelected(state.selection)
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue