Skip to content

Commit

Permalink
fix: quick fix StarSearch response (#3194)
Browse files Browse the repository at this point in the history
Co-authored-by: John McBride <john@opensauced.pizza>
  • Loading branch information
zeucapua and jpmcb committed Apr 17, 2024
1 parent 43784b2 commit 0c2847e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 3 additions & 6 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions pages/starsearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,17 @@ export default function StarSearchPage({ userId, bearerToken }: StarSearchPagePr
setIsRunning(false); // enables input
return;
}

const values = value.split("\n");
values
.filter((v) => v.startsWith("data:"))
.forEach((v) => {
let { data } = v.match(/data:(?<data>.*)/ms)?.groups || { data: "" };
const result = /(\s{1}[!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~])(\w*)/g.test(data) ? data.trimStart() : data;
const matched = v.match(/data:\s(?<result>.+)/);
if (!matched || !matched.groups) {
return;
}
const temp = [...chat];
const changed = temp.at(temp.length - 1);
changed!.content += result;
changed!.content += matched.groups.result;
setChat(temp);
});
}
Expand Down

0 comments on commit 0c2847e

Please sign in to comment.