Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Assistant websearch text/markdown source #1129

Merged
merged 1 commit into from
May 10, 2024
Merged

Conversation

mishig25
Copy link
Collaborator

@mishig25 mishig25 commented May 10, 2024

Description

When you combine assistant websearch with TEI, there was an error. (However, it was/is working fine with local models through transformers.js).

Although we have

body: JSON.stringify({ inputs: batchInputs, normalize: true, truncate: true }),
, there was still an error (i.e. TEI endpoint was rejecting the input citing it as invalid json) when a text value was a text concat value (i.e. rather than "Hello World", the actual value was "Hello " + "World"). Therefore, we needed to add
const text = await r.text();
// JSON.stringify is needed to turn string concatenation into a single string (ex: "Hello, " + "world!" -> "Hello, world!")
return JSON.stringify(text);

on main

image

this PR

Screenshot 2024-05-10 at 14 50 55

@gary149 gary149 requested a review from nsarrazin May 10, 2024 12:59
@@ -32,7 +32,9 @@ export async function parseWeb(url: string) {
r.headers.get("content-type")?.includes("text/plain") ||
r.headers.get("content-type")?.includes("text/markdown")
) {
return r.text();
const text = await r.text();
// JSON.stringify is needed to turn string concatenation into a single string (ex: "Hello, " + "world!" -> "Hello, world!")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> JSON.stringify('"Hello, " + "world!"')
'"\\"Hello, \\" + \\"world!\\""'

It doesn't give "Hello, world!"

Not sure I understand where the concat happens

Copy link
Collaborator Author

@mishig25 mishig25 May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example:

const text = await r.text();
console.log({text})
// {text: "Hello " + "world"}

and TEI endpoint was failing with Invalid json

let text = r.text();
text = JSON.stringify(text)
console.log({text})
// {text: "Hello world"}

TEI endpoint works fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will let @nsarrazin review I don't understand it

Copy link
Collaborator

@nsarrazin nsarrazin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, seems to fix the issue

@mishig25 mishig25 merged commit ed831e8 into main May 10, 2024
3 checks passed
@mishig25 mishig25 deleted the fix_parse_web_plain branch May 10, 2024 15:33
@nsarrazin nsarrazin added the bug Something isn't working label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants