Skip to content

feat: ai-prompt-decorator plugin#11515

Merged
shreemaan-abhishek merged 13 commits into
apache:masterfrom
shreemaan-abhishek:feat/prompt-decorator
Aug 30, 2024
Merged

feat: ai-prompt-decorator plugin#11515
shreemaan-abhishek merged 13 commits into
apache:masterfrom
shreemaan-abhishek:feat/prompt-decorator

Conversation

@shreemaan-abhishek

@shreemaan-abhishek shreemaan-abhishek commented Aug 20, 2024

Copy link
Copy Markdown
Contributor

Description

Implement the prompt decorator plugin.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@shreemaan-abhishek
shreemaan-abhishek marked this pull request as ready for review August 21, 2024 04:15
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. doc Documentation things plugin labels Aug 21, 2024
Comment thread apisix/plugins/ai-prompt-decorator.lua Outdated

local body_tab, err = core.json.decode(body)
if not body_tab then
return nil, { message = "could not get parse JSON request body: ", err }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, { message = "could not get parse JSON request body: ", err }
return nil, { message = "could not get parse JSON request body: " .. err }

Comment thread apisix/plugins/ai-prompt-decorator.lua Outdated


local function decorate(conf, body_tab)
local new_messages = conf.prepend or {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we can reuse this temporary table, eg: top level empty table

Comment thread apisix/plugins/ai-prompt-decorator.lua Outdated

local new_jbody, err = core.json.encode(body_tab)
if not new_jbody then
return 500, { message = "failed to parse modified JSON request body: ", err }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Suggested change
return 500, { message = "failed to parse modified JSON request body: ", err }
return 500, { message = "failed to parse modified JSON request body: " .. err }

@bzp2010
bzp2010 self-requested a review August 23, 2024 05:43

@bzp2010 bzp2010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This plugin should also be added to config.yaml.example.

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor Author

This plugin should also be added to config.yaml.example.

done

bzp2010
bzp2010 previously approved these changes Aug 27, 2024
@kayx23
kayx23 self-requested a review August 28, 2024 05:09

@kayx23 kayx23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other doc changes lgtm.

Comment thread docs/en/latest/plugins/ai-prompt-decorator.md Outdated
Comment thread docs/en/latest/plugins/ai-prompt-decorator.md Outdated
Comment thread docs/en/latest/plugins/ai-prompt-decorator.md Outdated
moonming
moonming previously approved these changes Aug 28, 2024
@shreemaan-abhishek
shreemaan-abhishek dismissed stale reviews from moonming and bzp2010 via 564c8bb August 28, 2024 17:15
kayx23
kayx23 previously approved these changes Aug 29, 2024

@kayx23 kayx23 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

doc LGTM

local _M = {
version = 0.1,
priority = 1060,
priority = 1071,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ai-prompt-decorator plugin should run before ai-prompt-decorator

@shreemaan-abhishek
shreemaan-abhishek merged commit 3387916 into apache:master Aug 30, 2024
@shreemaan-abhishek
shreemaan-abhishek deleted the feat/prompt-decorator branch August 30, 2024 04:59
MrLinMH pushed a commit to MrLinMH/apisix that referenced this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Documentation things plugin size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants