-
Notifications
You must be signed in to change notification settings - Fork 45
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
Update youtube-rewriter error handling to pass captioning errors as ChatCraft message #625
Conversation
… ImportCommand as ChatCraftHumanMessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the other fix you made before, or does it still have value?
}); | ||
} catch (error) { | ||
return new Response(`**Error**: ${error?.message}`, { | ||
headers: { "Content-Type": "text/markdown; charset=UTF-8" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably OK, but I've never seen Markdown used as an Error body before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to bold it like the "Command" text, but I hadn't considered whether we should include Markdown in an Error body.
I can remove the Markdown for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually an error is informational, not stylistic. You don't want to assume too much about how the client will use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently removed Markdown styling from the error message:
return new Response(`Error: ${error?.message}`, {
I had both fixes in one branch and found that only this fix would be triggered if an error occured (there'd be a ChatCraft message but no Error Toast). |
Deploying chatcraft-org with
|
Latest commit: |
48951a4
|
Status: | ✅ Deploy successful! |
Preview URL: | https://62f568e2.console-overthinker-dev.pages.dev |
Branch Preview URL: | https://issue-605-2.console-overthinker-dev.pages.dev |
This fixes #605
Background
If you use /import with a Youtube video that either has no English captions or no captions at all, ChatCraft will throw a non-descriptive error toast:
![image](https://private-user-images.githubusercontent.com/78163326/327256878-5b5a7814-4faf-4adb-9233-5e460bb81d4b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NTMxNjEsIm5iZiI6MTczOTg1Mjg2MSwicGF0aCI6Ii83ODE2MzMyNi8zMjcyNTY4NzgtNWI1YTc4MTQtNGZhZi00YWRiLTkyMzMtNWU0NjBiYjgxZDRiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA0Mjc0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJlMmQ0M2VmZWQ4MjhiNGU1ODA5ZmE4YTA4YWM2MGFiMDE2ZDc5YWZlOGM2MjE1M2UzM2UxMDQ3NWRjNGJiNTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8BOD9XjsofJgy1CZ5V74ki8CM8do9UYPB-QHmA5eRmk)
Caption extraction for YouTube videos is handled by youtube-captions-scraper within functions/lib/rewriters/youtube-rewriter.ts.
A previous PR for this (#618) would extract unhandled error messages from the HTML of a generated CloudFlare Pages page and put it inside an Error Toast.
Fix
In this PR, any errors thrown in youtube-rewriter will show up in the /import Response (as a ChatCraft message):
![image](https://private-user-images.githubusercontent.com/78163326/327257737-99c5e045-cdce-4354-9a61-ef0e67f479aa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk4NTMxNjEsIm5iZiI6MTczOTg1Mjg2MSwicGF0aCI6Ii83ODE2MzMyNi8zMjcyNTc3MzctOTljNWUwNDUtY2RjZS00MzU0LTlhNjEtZWYwZTY3ZjQ3OWFhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE4VDA0Mjc0MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNlZjFkZjI1MTk5Y2ExN2JlM2M1NGUwNjU4MzQwMjI0MDlkZjAyM2NkOWVjNDMxNzZmOTdkMjNkZWUxNzExMjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.MkqNxnr0Ew3dXA9doJKG3TlXrFiFSngWcHYb-NdqkA4)