You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Please perform the following tasks on the text below:
165
-
# 1. Extract Keywords and Generate Synonyms from the text:
166
-
# - At least 0, at most {max_keywords} keywords.
167
-
# - For each keyword, generate its synonyms or possible variant forms.
168
-
# Requirements:
169
-
# - Keywords should be meaningful and specific entities; avoid using meaningless or overly broad terms (e.g., “object,” “the,” “he”).
170
-
# - Prioritize extracting subjects, verbs, and objects; avoid extracting function words or auxiliary words.
171
-
# - Do not expand into unrelated generalized categories.
172
-
# Note:
173
-
# - Only consider semantic synonyms and other words with similar meanings in the given context.
174
-
# Output Format:
175
-
# - Output only one line, prefixed with KEYWORDS:, followed by all keywords and synonyms, separated by commas.No spaces or empty characters are allowed in the extracted keywords.
Please perform the following tasks on the text below:
135
+
1. Extract keywords from the text:
136
+
- Minimum 0, maximum MAX_KEYWORDS keywords.
137
+
- Keywords should be complete semantic words or phrases, ensuring information completeness.
138
+
2. Identify keywords that need rewriting:
139
+
- From the extracted keywords, identify those that are ambiguous or lack information in the original context.
140
+
3. Generate synonyms:
141
+
- For these keywords that need rewriting, generate synonyms or similar terms in the given context.
142
+
- Replace the corresponding keywords in the original text with generated synonyms.
143
+
- If no suitable synonym exists for a keyword, keep the original keyword unchanged.
144
+
145
+
Requirements:
146
+
- Keywords should be meaningful and specific entities; avoid meaningless or overly broad terms, or single-character words (e.g., "items", "actions", "effects", "functions", "the", "he").
147
+
- Prioritize extracting subjects, verbs, and objects; avoid function words or auxiliary words.
148
+
- Maintain semantic integrity: Extracted keywords should preserve their semantic and informational completeness in the original context (e.g., "Apple computer" should be extracted as a whole, not split into "Apple" and "computer").
149
+
- Avoid generalization: Do not expand into unrelated generalized categories.
150
+
151
+
Notes:
152
+
- Only consider context-relevant synonyms: Only consider semantic synonyms and words with similar meanings in the given context.
153
+
- Adjust keyword length: If keywords are relatively broad, you can appropriately increase individual keyword length based on context (e.g., "illegal behavior" can be extracted as a single keyword, or as "illegal", but should not be split into "illegal" and "behavior").
154
+
155
+
Output Format:
156
+
- Output only one line, prefixed with KEYWORDS:, followed by all keywords or corresponding synonyms, separated by commas. No spaces or empty characters are allowed in the extracted keywords.
157
+
- Format example:
158
+
KEYWORDS:keyword1,keyword2,...,keywordN
159
+
160
+
MAX_KEYWORDS: {max_keywords}
161
+
Text:
162
+
{question}
163
+
"""
181
164
182
165
gremlin_generate_prompt="""
183
166
You are an expert in graph query language (Gremlin). Your role is to understand the schema of the graph, recognize the intent behind user queries, and generate accurate Gremlin code based on the given instructions.
184
167
185
168
### Tasks
186
169
## Complex Query Detection:
187
-
Assess the user’s query to determine its complexity based on the following criteria:
170
+
Assess the user's query to determine its complexity based on the following criteria:
188
171
189
172
1. Multiple Reasoning Steps: The query requires several logical steps to arrive at the final result.
190
173
2. Conditional Logic: The query includes multiple conditions or filters that depend on each other.
@@ -209,7 +192,7 @@ class PromptConfig(BasePromptConfig):
209
192
## Gremlin Query Generation (Executed only if the query is not complex):
210
193
# Rules
211
194
- You may use the vertex ID directly if it’s provided in the context.
212
-
- If the provided question contains entity names that are very similar to the Vertices IDs, then in the generated Gremlin statement, replace the approximate entities from the original question.
195
+
- If the provided question contains entity names that are very similar to the Vertices IDs, then in the generated Gremlin statement, replace the approximate entities from the original question.
213
196
For example, if the question includes the name ABC, and the provided VerticesIDs do not contain ABC but only abC, then use abC instead of ABC from the original question when generating the gremlin.
214
197
215
198
The output format must be as follows:
@@ -230,9 +213,146 @@ class PromptConfig(BasePromptConfig):
230
213
"""
231
214
232
215
doc_input_text: str="""Meet Sarah, a 30-year-old attorney, and her roommate, James, whom she's shared a home with since 2010.
233
-
James, in his professional life, works as a journalist. Additionally, Sarah is the proud owner of the website
234
-
www.sarahsplace.com, while James manages his own webpage, though the specific URL is not mentioned here.
235
-
These two individuals, Sarah and James, have not only forged a strong personal bond as roommates but have also
236
-
carved out their distinctive digital presence through their respective webpages, showcasing their varied interests
216
+
James, in his professional life, works as a journalist. Additionally, Sarah is the proud owner of the website
217
+
www.sarahsplace.com, while James manages his own webpage, though the specific URL is not mentioned here.
218
+
These two individuals, Sarah and James, have not only forged a strong personal bond as roommates but have also
219
+
carved out their distinctive digital presence through their respective webpages, showcasing their varied interests
237
220
and experiences.
221
+
"""
222
+
223
+
# TODO: we should switch the prompt automatically based on the language (like using context['language'])
0 commit comments