mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Feat: Add industry-related search keyword generation function (#9156)
### What problem does this PR solve? Add industry-related search keyword generation function - When generating search keywords, support for specific industries has been added - If the "industry" parameter is provided, industry-specific restrictions will be added to the prompt - This change can help users generate more precise search keywords within specific industries ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -737,6 +737,7 @@ def related_questions(tenant_id):
|
|||||||
if not req.get("question"):
|
if not req.get("question"):
|
||||||
return get_error_data_result("`question` is required.")
|
return get_error_data_result("`question` is required.")
|
||||||
question = req["question"]
|
question = req["question"]
|
||||||
|
industry = req.get("industry", "")
|
||||||
chat_mdl = LLMBundle(tenant_id, LLMType.CHAT)
|
chat_mdl = LLMBundle(tenant_id, LLMType.CHAT)
|
||||||
prompt = """
|
prompt = """
|
||||||
Objective: To generate search terms related to the user's search keywords, helping users find more valuable information.
|
Objective: To generate search terms related to the user's search keywords, helping users find more valuable information.
|
||||||
@ -746,7 +747,10 @@ Instructions:
|
|||||||
- Use common, general terms as much as possible, avoiding obscure words or technical jargon.
|
- Use common, general terms as much as possible, avoiding obscure words or technical jargon.
|
||||||
- Keep the term length between 2-4 words, concise and clear.
|
- Keep the term length between 2-4 words, concise and clear.
|
||||||
- DO NOT translate, use the language of the original keywords.
|
- DO NOT translate, use the language of the original keywords.
|
||||||
|
"""
|
||||||
|
if industry:
|
||||||
|
prompt += f" - Ensure all search terms are relevant to the industry: {industry}.\n"
|
||||||
|
prompt += """
|
||||||
### Example:
|
### Example:
|
||||||
Keywords: Chinese football
|
Keywords: Chinese football
|
||||||
Related search terms:
|
Related search terms:
|
||||||
|
|||||||
@ -3371,6 +3371,7 @@ The chat model autonomously determines the number of questions to generate based
|
|||||||
- `'Authorization: Bearer <YOUR_LOGIN_TOKEN>'`
|
- `'Authorization: Bearer <YOUR_LOGIN_TOKEN>'`
|
||||||
- Body:
|
- Body:
|
||||||
- `"question"`: `string`
|
- `"question"`: `string`
|
||||||
|
- `"industry"`: `string`
|
||||||
|
|
||||||
##### Request example
|
##### Request example
|
||||||
|
|
||||||
@ -3381,7 +3382,8 @@ curl --request POST \
|
|||||||
--header 'Authorization: Bearer <YOUR_LOGIN_TOKEN>' \
|
--header 'Authorization: Bearer <YOUR_LOGIN_TOKEN>' \
|
||||||
--data '
|
--data '
|
||||||
{
|
{
|
||||||
"question": "What are the key advantages of Neovim over Vim?"
|
"question": "What are the key advantages of Neovim over Vim?",
|
||||||
|
"industry": "software_development"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -3389,6 +3391,8 @@ curl --request POST \
|
|||||||
|
|
||||||
- `"question"`: (*Body Parameter*), `string`
|
- `"question"`: (*Body Parameter*), `string`
|
||||||
The original user question.
|
The original user question.
|
||||||
|
- `"industry"`: (*Body Parameter*), `string`
|
||||||
|
Industry of the question.
|
||||||
|
|
||||||
#### Response
|
#### Response
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user