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
For more details, see the **AI Search, Enterprise Edition** section: [Connecting to Enterprise GAI and LLMs](AI-Search#connecting-to-generative-ai-gai-and-large-language-models-llms).
77
+
76
78
## Launching Assistant
77
79
78
80
Once the AI provider is configured correctly, **Assistant should be accessible via a browser**.
@@ -81,9 +83,6 @@ For a default installation, go to: [http://localhost:8000/galaxy/chat](http://lo
For more details, see the **AI Search, Enterprise Edition** section: [Connecting to Enterprise GAI and LLMs](AI-Search#connecting-to-generative-ai-gai-and-large-language-models-llms).
85
-
86
-
87
86
## Listing Sources
88
87
89
88
Instruct the Assistant to: `List sources`
@@ -112,6 +111,84 @@ Queries information on 7 million companies worldwide, including number of employ
112
111
113
112
The `description` field can be up to 2k in length.
114
113
114
+
## Using Prompts
115
+
116
+
SWIRL Enterprise includes a set of pre-loaded, standard prompts. Each consiss of three key components:
117
+
118
+
| Field | Description |
119
+
| ----- | ----------- |
120
+
|`prompt`| The main body of the prompt. Use `{query}` to represent the SWIRL query. |
121
+
|`note`| Text appended to search result data sent to the LLM for insight generation. |
122
+
|`footer`| Additional instructions appended after the prompt and RAG data. This is ideal for formatting guidance. |
123
+
124
+
The name of the `prompt` has no importance. SWIRL uses the `tags` field to determine which prompt is used for a given function.
125
+
126
+
The following table presents the `tags` options:
127
+
128
+
| Tag | LLM Role |
129
+
| --- | -------- |
130
+
| chat | Used by AI Search Assistant for chat conversations, including company background; not technical |
131
+
| chat-rag | Used by AI Search Assistant to answer questions and summarize data via RAG; somewhat technical |
132
+
| search-rag | Used by AI Search, `Generate AI Insight` (RAG) switch, somewhat technical |
133
+
134
+
Note that there must be at least one `active` prompt for each of these tags for the relevant SWIRL features to work.
135
+
136
+
### Modifying the Standard Prompts
137
+
138
+
{.warning}
139
+
**Warning: never modify the standard prompts!** Any such changes will be discarded when SWIRL updates.
140
+
141
+
Use the [Customizing Prompts](#customizing-the-ai-search-assistant-prompts) procedure instead.
142
+
143
+
### Customizing the AI Search Assistant Prompts
144
+
145
+
The following procedure below below to copy the standard prompts, modify them, then make them active.
146
+
New prompts that you create won't be disturbed during upgrades.
147
+
148
+
1. Open [http://localhost:8000/swirl/prompts/](http://localhost:8000/swirl/prompts/)
149
+
150
+
2. Locate the `chat_rag_instructions_standard`, `chat_rag_standard` or `chat_rag_deeplink` prompts and note the `id`.
151
+
152
+
3. Add the `id` to the URL to view just that prompt.
153
+
154
+
4. Click the `Raw data` tab at the bottom of the page. Copy the entire JSON record to the clipboard.
155
+
156
+
5. Click the `HTML form` tab at the bottom of the page. Set `active` to `false`. Click `PUT` to save the change.
157
+
158
+
6. Go back to [http://localhost:8000/swirl/prompts/](http://localhost:8000/swirl/prompts/) and scroll to the bottom of the form.
159
+
160
+
7. Select the `Raw data` tab if necessary. Paste the prompt copied in step #4 into `Content:` block. **Do not hit `Put` yet**.
161
+
162
+
8. Remove the `id`, `owner`, `date_created` and `date_updated` fields. Change the `name` field to something descriptive. Also, make sure `active` is set to `true`. Finally, if you don't wish to share this prompt with other users, set `shared` to `false`. Feel free to hit `PUT` now to save the record.
163
+
164
+
9. Modify the `prompt` field, and change `SWIRL Corporation` to the name of your organization. We also recommend adding adding 2-3 sentences describing the organization as well. immediately afterwards.
165
+
166
+
For example:
167
+
168
+
```json
169
+
{
170
+
"prompt": "You are an expert online assistant and reference librarian working for **<your-company-name>. <Your-company-name> is located in <description> and operates in <industry> etc**... Your job is...
171
+
}
172
+
```
173
+
174
+
{: .warning }
175
+
**Warning:** Removing important sections of any prompt such as variables like `{header}` and `{query}` may cause AI Insight generation to fail or not contain important features such as follow-up questions or citations.
To go back to a standard prompt after creating a new one:
184
+
185
+
1. Edit the new prompt and set `active` to `false`.
186
+
2. Edit the standard prompt and set `active` to `true`.
187
+
188
+
### Restoring All Prompts to Default
189
+
190
+
To restore all prompts to the default, refer to the [Admin Guide on Resetting Prompts](Admin-Guide.html#resetting-prompts).
191
+
115
192
## Advanced Querying
116
193
117
194
To enable the Assistant to query in advanced query languages like SQL, the elastic API or Mongo MQL, add an LLM generated instruction set to this structure, including:
| search-rag | Used by AI Search, `Generate AI Insight` (RAG) switch, somewhat technical |
304
+
| chat | Used by AI Search Assistant for chat conversations, including company background; not technical |
305
+
| chat-rag | Used by AI Search Assistant to answer questions and summarize data via RAG; somewhat technical |
294
306
295
-
## Creating New Saved Prompts
307
+
Note that there must be at least one `active` prompt for each of these tags for the relevant SWIRL features to work.
296
308
297
-
To create a new saved prompt:
309
+
### Modifying the Standard Prompts
310
+
311
+
{.warning}
312
+
**Warning: never modify the standard prompts!** Any such changes will be discarded when SWIRL updates.
313
+
314
+
Use the [Customizing Prompts](#customizing-the-ai-search-rag-prompt) procedure instead.
315
+
316
+
### Customizing the AI Search RAG Prompt
317
+
318
+
The following procedure below below to copy the standard prompts, modify them, then make them active.
319
+
New prompts that you create won't be disturbed during upgrades.
298
320
299
321
1. Open [http://localhost:8000/swirl/prompts/](http://localhost:8000/swirl/prompts/)
300
-
2. Use the form at the bottom of the page to create a new prompt **or** paste raw JSON and click `POST`.
301
322
302
-
**Example: Creating a Pirate-Themed Prompt**
323
+
2. Locate the `search_rag_standard` or, if using [Deep Linking](./User-Guide-Enterprise.md#deep-linked-citations)`search_rag_deeplink` prompt, and note the `id`.
324
+
325
+
3. Add the `id` to the URL to view just that prompt.
326
+
327
+
4. Click the `Raw data` tab at the bottom of the page. Copy the entire JSON record to the clipboard.
328
+
329
+
5. Click the `HTML form` tab at the bottom of the page. Set `active` to `false`. Click `PUT` to save the change.
303
330
304
-
Modify the default prompt to generate responses in pirate-speak:
331
+
6. Go back to [http://localhost:8000/swirl/prompts/](http://localhost:8000/swirl/prompts/) and scroll to the bottom of the form.
305
332
333
+
7. Select the `Raw data` tab if necessary. Paste the prompt copied in step #4 into `Content:` block. **Do not hit `Put` yet**.
334
+
335
+
8. Remove the `id`, `owner`, `date_created` and `date_updated` fields. Change the `name` field to something descriptive. Also, make sure `active` is set to `true`. Finally, if you don't wish to share this prompt with other users, set `shared` to `false`. Feel free to hit `PUT` now to save the record.
336
+
337
+
9. Modify the `prompt`, `note` and/or `footer` as needed, while retaining all critical instructions. For example, to instruct the LLM to use pirate-speak:
306
338
```json
307
339
{
308
-
"name": "pirate",
340
+
"name": "search_rag_standard_pirate",
309
341
"...": "... etc ...",
310
342
"footer": "--- Final Instructions ---
311
343
In your response, pretend you are a pirate comedian, but keep it clean!",
**Warning:** Removing important sections of any prompt such as variables like `{header}` and `{query}` may cause AI Insight generation to fail or not contain important features such as follow-up questions or citations.
353
+
354
+
## Specifying a Saved Prompt when Generating AI Insights
355
+
356
+
There are two ways to select a saved prompt:
357
+
358
+
1. Use the prompt selector on the AI Search form:
359
+

321
360
322
-
Test a saved prompt using the **prompt operator**:
361
+
2. Use the **prompt operator** in your query. For example:
323
362
324
363
```
325
364
swirl AI Search prompt:pirate
326
365
```
327
366
328
-
The response should be generated in pirate-speak:
329
-
367
+
In either case, the response is generated in pirate-speak as the prompt instructs:
330
368

331
369
332
-
## Understanding Saved Prompts
370
+
## Restoring Standard Prompts
333
371
334
-
SWIRL prompts consist of three key components:
372
+
To go back to a standard prompt after creating a new one:
335
373
336
-
| Field | Description |
337
-
| ----- | ----------- |
338
-
|`prompt`| The main body of the prompt. Use `{query}` to represent the SWIRL query. |
339
-
|`note`| Text appended to RAG data chunks, annotated by the [Text Analyzer](#text-summarization). |
340
-
|`footer`| Additional instructions appended after the prompt and RAG data. This is ideal for formatting guidance. |
374
+
1. Edit the new prompt and set `active` to `false`.
375
+
2. Edit the standard prompt and set `active` to `true`.
376
+
377
+
### Restoring All Prompts to Default
378
+
379
+
To restore all prompts to the default, refer to the [Admin Guide on Resetting Prompts](https://docs.swirlaiconnect.com/Admin-Guide#resetting-prompts).
341
380
342
381
## Using a Prompt in a Query Processor or Connector
Copy file name to clipboardExpand all lines: docs/Developer-Guide.md
+3-5Lines changed: 3 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -200,11 +200,9 @@ To address this, use the **[DateFindingResultProcessor](#find-dates-in-bodytitle
200
200
201
201
## Use an LLM to Rewrite Queries
202
202
203
-
SWIRL AI Search supports **query rewriting** using `ChatGPTQueryProcessor` (for the Community edition) or the `GenAIQueryProcessor`(for Enterprise).
203
+
SWIRL AI Search supports **query rewriting** using an LLM. To set this up, add the `GenAIQueryProcessor`to some `SearchProvider.query_processors` list.
204
204
205
-
To enable it, add the processor to `SearchProvider.query_processors`.
206
-
207
-
For details, see: [Developer Reference - Query Processors](./Developer-Reference#query-processors).
205
+
For details, see: [Developer Reference - GenAIQueryProcessor](./Developer-Reference.md#genai-and-chatgpt-connectors)
208
206
209
207
## Adjust `swirl_score` for Starred Results in Galaxy UI
Copy file name to clipboardExpand all lines: docs/Developer-Reference.md
+22-31Lines changed: 22 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -297,14 +297,13 @@ The included [BigQuery SearchProvider](https://github.com/swirlai/swirl-search/b
297
297
298
298
More information: [BigQuery Documentation](https://cloud.google.com/bigquery/docs)
299
299
300
-
## GenAI and ChatGPT Connectors
300
+
## GenAI Connectors
301
301
302
-
SWIRL includes connectors that can be used to obtain direct answers from LLMs, as if they were regular SearchProviders. The connector is the `ChatGPTConnector` (for the Community edition) or the `GenAIConnector` (for Enterprise).
303
-
304
-
Both connectors return at most one result.
302
+
SWIRL includes the `GenAIConnector` which can ask for direct answers from LLMs, as if they were regular SearchProviders. It returns at most one result.
305
303
306
304
The included [SearchProvider](https://github.com/swirlai/swirl-search/blob/main/SearchProviders/gen_ai.json) is pre-configured with a "Tell me about: ..." prompt.
307
305
306
+
308
307
```json
309
308
{
310
309
"name": "GenAI - OpenAI",
@@ -316,7 +315,7 @@ The included [SearchProvider](https://github.com/swirlai/swirl-search/blob/main/
316
315
"query_processors": [
317
316
"AdaptiveQueryProcessor"
318
317
],
319
-
"query_mappings": "",
318
+
"query_mappings": "PROMPT='Tell me about: {query_to_provider}'",
320
319
"result_processors": [
321
320
"GenericResultProcessor",
322
321
"CosineRelevancyResultProcessor"
@@ -332,40 +331,37 @@ The included [SearchProvider](https://github.com/swirlai/swirl-search/blob/main/
332
331
}
333
332
```
334
333
335
-
The `Question` and `GenAI` SearchProvider Tags enable targeted queries. For example:
336
-
337
-
```shell
338
-
Question: Tell me about knowledge management software?
339
-
```
340
-
341
334
### Setting the GenAI Prompt or Role
342
335
343
-
The following tags adjust the prompt or role passed to GenAI.
336
+
The following `query_mappings`**including quotes** adjust the prompt or role passed to GenAI.
344
337
345
338
*`CHAT_QUERY_REWRITE_PROMPT`: Customizes the prompt used to refine the query.
346
339
347
340
```json
348
-
"CHAT_QUERY_REWRITE_PROMPT:Write a more precise query of similar length to this: {query_string}"
341
+
"CHAT_QUERY_REWRITE_PROMPT:Write a more precise query of similar length to this: {query_to_provider}"
349
342
```
350
343
351
344
*`CHAT_QUERY_REWRITE_GUIDE`: Overrides the `system` role.
352
345
353
346
```json
354
-
"CHAT_QUERY_REWRITE_GUIDE:You are a helpful assistant that responds like a pirate captain"
347
+
"CHAT_QUERY_REWRITE_GUIDE:You are a helpful assistant that responds like a pirate captain"
355
348
```
356
349
357
350
*`CHAT_QUERY_DO_FILTER`: Enables/disables internal filtering of LLM responses.
358
351
359
352
```json
360
-
"CHAT_QUERY_DO_FILTER:false"
353
+
"CHAT_QUERY_DO_FILTER:false"
361
354
```
362
355
363
-
The following `query_mapping` adjusts the default role passed to GenAI:
356
+
For example:
364
357
365
-
```shell
366
-
"query_mappings": "PROMPT='Tell me about: {query_to_provider}',CHAT_QUERY_REWRITE_GUIDE='You are a helpful assistant that responds like a pirate captain'",
358
+
```json
359
+
"query_mappings": "CHAT_QUERY_REWRITE_PROMPT='Tell me about: {query_to_provider}',CHAT_QUERY_REWRITE_GUIDE='You are a helpful assistant that talks like a pirate captain but keeps it clean!'",
367
360
```
368
361
362
+
{.warning}
363
+
Do not use commas inside of a prompt passed in this manner.
364
+
369
365
# Elastic & OpenSearch
370
366
371
367
The [Elastic](https://github.com/swirlai/swirl-search/blob/main/swirl/connectors/elastic.py) and [OpenSearch](https://github.com/swirlai/swirl-search/blob/main/swirl/connectors/opensearch.py) Connectors use each engine's Python client.
@@ -917,22 +913,15 @@ Query Processors modify queries. The field they operate on depends on where they
917
913
| Processor | Description | Notes |
918
914
| ---------- | ---------- | ---------- |
919
915
|**AdaptiveQueryProcessor**| Rewrites queries based on `query_mappings` for a given SearchProvider | Not for `pre_query_processors`|
920
-
|**ChatGPTQueryProcessor**| Uses OpenAI to rewrite queries, making them broader, more specific, boolean, or in another language | Community edition only |
921
-
|**GenAIQueryProcessor**| Uses an LLM to rewrite queries, making them broader, more specific, boolean, or in another language | Enterprise edition only |
916
+
|**GenAIQueryProcessor**| Uses an LLM to rewrite queries, making them broader, more specific, boolean, or in another language ||
922
917
|**GenericQueryProcessor**| Removes special characters from queries ||
923
918
|**SpellcheckQueryProcessor**| Uses [TextBlob](https://textblob.readthedocs.io/en/dev/quickstart.html#spelling-correction) to correct spelling errors | Best used in `SearchProvider.query_processors`; avoid with Google PSE |
924
919
|**NoModQueryProcessor**| Removes only leading SearchProvider Tags, leaving query terms unchanged | For repositories allowing non-search characters (e.g., brackets) |
925
920
|**RemovePIIQueryProcessor**| Removes PII entities from queries without replacing them ||
926
921
927
922
## GenAIQueryProcessor
928
923
929
-
The `GenAIQueryProcessor` calls an LLM with the user's query and a custom prompt to enable rewriting. For example this processor can:
930
-
931
-
* Translate queries between languages
932
-
* Rewrite queries as booleans
933
-
* Perform phrase detection
934
-
935
-
And much more.
924
+
The `GenAIQueryProcessor` calls an LLM with the user's query and a custom prompt to enable rewriting, translation phrase detection and much more.
936
925
937
926
### Configuring the SearchProvider
938
927
@@ -954,18 +943,20 @@ To alter the query sent to all Searchproviders, add it to the `search.pre_query_
954
943
}
955
944
```
956
945
957
-
Note: this requires calling the Swirl Search API and is not supported via Galaxy.
946
+
Note that the example above only applies to calling the SWIRL API. Please [contact support](#support) for instructions on how to configure this behavior with the Galaxy UI.
958
947
959
948
### Configuring the QueryProcessor
960
949
961
-
The GenAIQueryProcessor supports the same tags and configuration options as the [GenAIConnector](#setting-the-genai-prompt-or-role).
950
+
The GenAIQueryProcessor supports the same tags and configuration options as the [GenAIConnector](#setting-the-genai-prompt-or-role) but using a colon (':') as a delimeter.
962
951
963
952
For example:
964
953
965
954
```json
966
955
"tags": [
967
-
"PROMPT='Translate this query to japanese, if necessary: {query_string}"
968
-
],
956
+
"CHAT_QUERY_REWRITE_PROMPT:If this query is in Japanese, tokenize it, and output ONLY the tokenized japanese, NOTHING ELSE -> {query_string}",
957
+
"CHAT_QUERY_REWRITE_GUIDE:You are a speedy tokenizer!",
0 commit comments