This repository was archived by the owner on Jul 22, 2025. It is now read-only.
generated from discourse/discourse-plugin-skeleton
-
Couldn't load subscription status.
- Fork 41
FIX: make AI helper more robust #1484
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
SamSaffron
commented
Jul 3, 2025
- If JSON is broken for structured output then lean on a more forgiving parser
- Gemini 2.5 flash does not support temp, support opting out
- Evals for assistant were broken, fix interface
- Add some missing LLMs
- Translator was not mapped correctly to the feature - fix that
- Don't mix XML in prompt for translator
- If JSON is broken for structured output then lean on a more forgiving parser - Gemini 2.5 flash does not support temp, support opting out - Evals for assistant were broken, fix interface - Add some missing LLMs - Translator was not mapped correctly to the feature - fix that - Don't mix XML in prompt for translator
nattsw
reviewed
Jul 3, 2025
|
Nope :)
…On Thu, 3 Jul 2025 at 6:27 pm, Natalie Tay ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/ai_helper/assistant.rb
<#1484 (comment)>
:
> @@ -151,6 +164,18 @@ def generate_prompt(
bot.reply(context, &buffer_blk)
+ # handle edge cases where structured output is all over the place
+ if bad_json
+ helper_response = helper_response.join if helper_response.is_a?(Array)
+ helper_response =
+ DiscourseAi::Utils::BestEffortJsonParser.extract_key(
+ helper_response,
+ schema_type,
+ schema_key,
+ )
+ p helper_response
Is this intended?
—
Reply to this email directly, view it on GitHub
<#1484 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAABIXOBUVV7SKIFKRF4BRT3GTSQ7AVCNFSM6AAAAACAV33C7OVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSOBSGIZTCOBQHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
romanrizzi
suggested changes
Jul 3, 2025
lib/ai_helper/assistant.rb
Outdated
| if bad_json | ||
| helper_response = helper_response.join if helper_response.is_a?(Array) | ||
| helper_response = | ||
| DiscourseAi::Utils::BestEffortJsonParser.extract_key( |
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 great! I suggest we move it inside #read_buffered_property.
| @partial_json_tracker << raw | ||
| end | ||
|
|
||
| def broken? |
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.
No need for this if we move the best effort parser inside this object.
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.
actually we still need it cause on finish when streaming we need to double check.
romanrizzi
approved these changes
Jul 3, 2025
keegangeorge
added a commit
that referenced
this pull request
Jul 7, 2025
This update fixes a regression from #1484, which caused AI helper title suggestions to begin suggesting numerous non-unique titles because it was looping through structured responses incorrectly.
keegangeorge
added a commit
that referenced
this pull request
Jul 8, 2025
This update fixes a regression from #1484, which caused AI helper title suggestions to begin suggesting numerous non-unique titles because it was looping through structured responses incorrectly.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.