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

unable to generate quiz due to code #20

Open
kiowafa opened this issue Oct 9, 2024 · 18 comments
Open

unable to generate quiz due to code #20

kiowafa opened this issue Oct 9, 2024 · 18 comments
Labels
bug Something isn't working

Comments

@kiowafa
Copy link

kiowafa commented Oct 9, 2024

I used Cohere to get an API key.
When I click generate quiz I get:
Expected ',' or '}' after property value in JSON at position 2365

@ECuiDev ECuiDev added the bug Something isn't working label Oct 9, 2024
@ECuiDev
Copy link
Owner

ECuiDev commented Oct 9, 2024

Can you try again? I just tested it myself and both the Command R and Command R+ models worked on the first try.

If it still doesn't work after multiple attempts, can you provide the model you used, the token count of your notes, and the type and number of questions you tried to generate?

@ECuiDev ECuiDev closed this as completed Oct 13, 2024
@kiowafa
Copy link
Author

kiowafa commented Oct 14, 2024

Hey there!
It worked now with the same short note that I tried it with in the beginning (this plugin is so amazing I love it!)
I tried another long note and I got Unexpected end of JSON input

@ECuiDev
Copy link
Owner

ECuiDev commented Oct 14, 2024

How many tokens was the note and how many questions were you trying to generate?

@ECuiDev ECuiDev reopened this Oct 14, 2024
@kiowafa
Copy link
Author

kiowafa commented Oct 14, 2024

The new one was 24088 tokens.

@ECuiDev
Copy link
Owner

ECuiDev commented Oct 14, 2024

How many questions did you try to generate?

@kiowafa
Copy link
Author

kiowafa commented Oct 14, 2024

I clicked on "Generate Quiz" with the standard settings, so 7.

@ECuiDev
Copy link
Owner

ECuiDev commented Oct 14, 2024

Ok, I'll look into it.

@kiowafa
Copy link
Author

kiowafa commented Oct 22, 2024

Hey, just a heads up: I still have this problem.

@ECuiDev
Copy link
Owner

ECuiDev commented Oct 23, 2024

I did some testing and turns out Cohere's models return nothing if your prompt exceeds ~4000 tokens. Note that this number can vary depending on the content of your notes because I use an extremely simple tokenizer which doesn't perfectly reflect how actual models tokenize inputs.

I plan to fix this by breaking down large inputs into chunks and processing each one separately. But in the meantime, I recommend either keeping each generation request under 4000 tokens, or using Google Gemini which can easily handle tens of thousands of tokens.

@kiowafa
Copy link
Author

kiowafa commented Oct 23, 2024

Thanks!

So I tried to test it with Gemini just now and I got the same error...

@ECuiDev
Copy link
Owner

ECuiDev commented Oct 23, 2024

That's surprising. I just tried with 80,000 tokens and had no issues. What generation language are you using and did your selected notes contain any "special" text (code, LaTeX, tables, non-English characters, embeds, etc.)?

@kiowafa
Copy link
Author

kiowafa commented Oct 23, 2024

I use german as the language for the questions to be generated in.
The only "special" text symbols I use are emojis, I guess.
But if I use different files (that have no emojis) I get the same error message (only with different "position")

@ECuiDev
Copy link
Owner

ECuiDev commented Oct 23, 2024

I just tried again using German as the generation language and even translated my notes into German but didn't have any problems, so this is really strange. Are you using the default Google API base URL or a third-party API? That seems like the only factor left that hasn't been considered.

@kiowafa
Copy link
Author

kiowafa commented Oct 24, 2024

I have not changed anything about the default API...
I'm also really confused about it. Is there anything else I could give you to tackle the problem better? Like a bug-report or something? (I don't know how to get that tho).

Thank you for your efforts!

@ECuiDev
Copy link
Owner

ECuiDev commented Oct 25, 2024

I've attached a custom build of the latest release which has some logging for Cohere and Gemini. Go to YourVault/.obsidian/plugins/quiz-generator and replace the main.js file there with the attached one. Then try generating again with the Developer Tools open in Obsidian by doing Ctrl + Shift + I on Windows or Command + Option + I on Mac.

main.txt

Edit: For some reason Windows Defender flags it as a virus when I tried downloading it even though I made the file so let me know if you can't download it.

Edit2: I found a workaround by replacing the zip file with a .txt file. You can just follow the instructions above but make sure you change the file extension from .txt to .js first.

@kiowafa
Copy link
Author

kiowafa commented Oct 30, 2024

Hey there!
Finally had the time to do this.
I did everything as you said.

Check out this log:

obsidian.md-1730326246731.log

Quiz Generator is only in the last few lines

@ECuiDev
Copy link
Owner

ECuiDev commented Nov 5, 2024

Thanks for the logs. I'm able to reproduce the bug with Cohere so I'll put out a fix for that soon.

Are you able to also send the logs when you try generating with Gemini? I can't get Gemini to fail no matter how many tokens I use so it'd be very helpful to see what error you're getting.

@kiowafa
Copy link
Author

kiowafa commented Nov 13, 2024

Hey there,
here is a log with Google:
obsidian.md-1731513334761.log

and another log with Cohere:
obsidian.md-1731513434176.log

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

No branches or pull requests

2 participants