Skip to content

Add configurable suggested questions after answer via environment variables - #1

Draft
f4844844235869 with Copilot wants to merge 2 commits into
mainfrom
copilot/what-can-you-do
Draft

Add configurable suggested questions after answer via environment variables#1
f4844844235869 with Copilot wants to merge 2 commits into
mainfrom
copilot/what-can-you-do

Conversation

Copilot AI commented Mar 15, 2026

Copy link
Copy Markdown

Adds operator-level control over the "Suggested Questions After Answer" feature prompt and LLM parameters, enabling deployment-specific customization without code changes.

Summary

The suggested questions feature previously used a hardcoded prompt and fixed LLM parameters. This change exposes three environment variables to override them at deploy time, plus adds comprehensive tests for the output parser and parameter propagation.

New environment variables (api/.env.example):

# Custom prompt (default: generates 3 questions under 20 chars in same language as response)
SUGGESTED_QUESTIONS_PROMPT=

# Token and creativity controls
SUGGESTED_QUESTIONS_MAX_TOKENS=256   # default
SUGGESTED_QUESTIONS_TEMPERATURE=0    # default

Implementation (api/core/llm_generator/prompts.py):

  • SUGGESTED_QUESTIONS_AFTER_ANSWER_INSTRUCTION_PROMPT now reads from SUGGESTED_QUESTIONS_PROMPT env var with the original prompt as fallback
  • SUGGESTED_QUESTIONS_MAX_TOKENS / SUGGESTED_QUESTIONS_TEMPERATURE similarly env-driven

Tests added:

  • test_suggested_questions_after_answer.py — 12 tests covering SuggestedQuestionsAfterAnswerOutputParser.parse(): valid JSON, embedded JSON, empty/invalid arrays, non-string element filtering, multiline, Chinese text, and custom prompt patching
  • 2 new tests in test_llm_generator.py verifying max_tokens and temperature are correctly forwarded to the LLM invoke call

Screenshots

Before After
Hardcoded prompt, fixed 256 max_tokens, temperature 0 Fully configurable via env vars with zero-breaking-change defaults

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pkg.pr.new
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/pnpm install git rev-�� FETCH_HEAD (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/pnpm install --ignore-scripts --prefer-offline app.capabilities\|getCapabilities app/components/base/chat/embedded-chatbot/chat-wrapper.tsx app/components/base/chat/embedded-chatbot/header/__tests__/index.spec.tsx app/components/bbash app/components/b--norc app/components/b--noprofile app/components/base/chat/embedded-chatbot/inputs-form/__tests__/index.spec.tsx app/�� app/components/base/chat/embedded-chatbot/inputs-form/content.tsx app/components/base/chat/embedded-chatbot/inputs-form/index.tsx de/node/bin/bash app/components/bbash app/components/b--norc app/components/b--noprofile app/components/base/chat/embedded-chatbot/hooks.tsx (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…ustomization

Co-authored-by: f4844844235869 <87220135+f4844844235869@users.noreply.github.com>
Copilot AI changed the title [WIP] Add overview of capabilities and features Add configurable suggested questions after answer via environment variables Mar 15, 2026
Copilot AI requested a review from f4844844235869 March 15, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants