Function Description

The AI Prompts plugin allows inserting prompts before and after requests in LLM.

Execution Properties

Plugin execution phase: Default Phase
Plugin execution priority: 450

Configuration Description

NameData TypeRequirementDefault ValueDescription
prependarray of message objectoptional-Statements inserted before the initial input
appendarray of message objectoptional-Statements inserted after the initial input

Message object configuration description:

NameData TypeRequirementDefault ValueDescription
rolestringrequired-Role
contentstringrequired-Message

Example

An example configuration is as follows:

  1. prepend:
  2. - role: system
  3. content: Please answer the questions in English.”
  4. append:
  5. - role: user
  6. content: After answering each question, try to ask a follow-up question.”

Using the above configuration to initiate a request:

  1. -H content-type: application/json \
  2. -d ‘{
  3. model”: gpt-3.5-turbo”,
  4. messages”: [
  5. {
  6. role”: user”,
  7. content”: Who are you?”
  8. }
  9. ]
  10. }

After processing through the plugin, the actual request will be:

  1. -H content-type: application/json \
  2. -d ‘{
  3. model”: gpt-3.5-turbo”,
  4. messages”: [
  5. {
  6. role”: system”,
  7. content”: Please answer the questions in English.”
  8. },
  9. {
  10. role”: user”,
  11. content”: Who are you?”
  12. },
  13. {
  14. role”: user”,
  15. content”: After answering each question, try to ask a follow-up question.”
  16. }
  17. ]
  18. }

Based on the geo-ip plugin’s capabilities, extend AI Prompt Decorator plugin to carry user geographic location information.

If you need to include user geographic location information before and after the LLM’s requests, please ensure both the geo-ip plugin and the AI Prompt Decorator plugin are enabled. Moreover, in the same request processing phase, the geo-ip plugin’s priority must be higher than that of the AI Prompt Decorator plugin. First, the geo-ip plugin will calculate the user’s geographic location information based on the user’s IP, and then pass it to subsequent plugins via request attributes. For instance, in the default phase, the geo-ip plugin’s priority configuration is 1000, while the ai-prompt-decorator plugin’s priority configuration is 500.

Example configuration for the geo-ip plugin:

  1. ipProtocal: ipv4

An example configuration for the AI Prompt Decorator plugin is as follows:

  1. prepend:
  2. - role: system
  3. content: The users current geographic location is, country: ${geo-country}, province: ${geo-province}, city: ${geo-city}.”
  4. append:
  5. - role: user
  6. content: After answering each question, try to ask a follow-up question.”

Using the above configuration to initiate a request:

  1. -H content-type: application/json \
  2. -H x-forwarded-for: 87.254.207.100,4.5.6.7 \
  3. -d ‘{
  4. model”: gpt-3.5-turbo”,
  5. messages”: [
  6. {
  7. role”: user”,
  8. content”: How is the weather today?”
  9. }
  10. ]
  11. }’

After processing through the plugin, the actual request will be:

  1. -H content-type: application/json \
  2. -H x-forwarded-for: 87.254.207.100,4.5.6.7 \
  3. -d ‘{
  4. model”: gpt-3.5-turbo”,
  5. messages”: [
  6. {
  7. role”: system”,
  8. content”: The users current geographic location is, country: China, province: Beijing, city: Beijing.”
  9. },
  10. {
  11. role”: user”,
  12. content”: How is the weather today?”
  13. },
  14. {
  15. role”: user”,
  16. content”: After answering each question, try to ask a follow-up question.”
  17. }
  18. ]
  19. }’