Chat Gpt Demo
In this section we have a simple tutorial how to create simple search with 'Quick Start' with ChatGPT integration. Make
sure you have access to necessary configs (searchapp
, search
, config
). If you don't have access to this configs
please contact an administration to provide it
Create config
Create config
- Go to Quasiris Search Cloud
- Enter 'Config' in the top left search input
- Click on 'Config'
- Create a config with name 'chat-gpt-integration-config'
- In tab 'Config' post a json
{
"type": "searchResultRefinement",
"searchResultRefinement": {
"requestTemplate": "Title is '${(searchResults['chat-gpt-quick-start-demo'].documents[0].document.title)!\"\"}'",
"appendToSearchContextKey": "biking",
"contextString": "This is a chat for the application, where I would enter a query, and you would answer the question from this query. Possible answers are only yes, no, unknown. Don't add any comments or symbols. ONLY 'yes', 'no', 'unknown'. \nWe are at biking shop, I want to know if the title user enter somehow connected to biking topic."
}
} - Click 'Save'
Run Quick Start
- Go to
Quick Start
- Enter code
chat-gpt-quick-start-demo
- Enter data
[
{
"title": "mountain bike",
"name": "name of the bike",
"description": "Perfect for sport"
},
{
"title": "kitchen scales",
"name": "name of the scalse",
"description": "Perfect for kitchen"
}
]
- Click
Create Search
- Click
Next
until you seeApply
button - Click
Apply
- Go to
Search
config - Go to your config
chat-gpt-quick-start-demo
- Go to
Pipeline
tab - As
Pipeline Type
chooseCustom
- Enter yaml document
!!com.quasiris.qsf.pipeline.Pipeline
id: search-pipeline
timeout: 4000
filterList:
- !!com.quasiris.qsf.pipeline.filter.DebugFilter
active: true
id: search-pipeline.DebugFilter
- !!com.quasiris.qsc.search.service.query.QscSearchQueryFilter
active: true
id: search-pipeline.QscSearchQueryFilter
- !!com.quasiris.qsc.search.service.rules.QueryRuleFilter
active: true
baseUrl: {{ searchIndexBaseUrl }}
env: {{ env }}
id: queryRuleFilter
- !!com.quasiris.qsf.pipeline.filter.elastic.ElasticFilter
active: true
baseUrl: {{searchIndexBaseUrl}}
id: searchElasticFilter
resultSetId: {{searchCode}}
queryTransformer: !!com.quasiris.qsc.search.service.QscSearchQueryTransformer
profile: {{profile}}
searchResultTransformer: !!com.quasiris.qsc.search.service.QscResultTransformer
elasticSearchClient: !!com.quasiris.qsf.commons.elasticsearch.client.ElasticSearchClient
useApacheClient: false
- !!com.quasiris.qsf.pipeline.filter.ConditionFilter
active: true
condition: !!com.quasiris.qsf.pipeline.filter.conditions.EmptyResultCondition
resultSetId: {{searchCode}}
id: conditional.isSpellcheck
pipeline:
filterList:
- !!com.quasiris.qsf.pipeline.filter.TokenizerFilter
active: true
id: qsc-spellcheck.TokenizerFilter
- !!com.quasiris.qsf.pipeline.filter.elastic.SpellCheckElasticFilter
active: true
baseUrl: {{searchIndexBaseUrl}}-spellcheck
id: qsc-spellcheck.SpellCheckElasticFilter
maxTokenLenght: 10
minTokenLenght: 4
minTokenWeight: 1
sentenceScoringEnabled: false
restartPipelineId: search-pipeline
id: qsc-spellcheck
timeout: 1000
- !!com.quasiris.qsf.pipeline.filter.QSFQLResponseRefinementFilter
active: true
id: search-pipeline.QSFQLResponseRefinementFilter
resultId: {{searchCode}}
- !!com.quasiris.qsc.chatgpt.filter.ChatGPTFilter
active: true
apiKey: "chat-gpt-api-key"
modelId: "gpt-3.5-turbo"
chatGptConfigCode: "chat-gpt-integration-config"
resultSetId: {{searchCode}}
maxTokens: 10
timeoutMills: 8000
temperature: 0
- !!com.quasiris.qsf.pipeline.filter.elastic.ElasticTrackingFilter
active: true
baseUrl: {{trackingIndexBaseUrl}}
customParameter:
app: search
searchCode: {{searchCode}}
tenantCode: {{tenant}}
env: {{env}}
id: search-pipeline.ElasticTrackingFilter
idFieldName: id
resultSetId: {{searchCode}}
rotation: none
trackingId: null
- Set the right api key in yaml
- Save the config
Test the search
The search configuration now is configured to check if the title of the first document is about biking. It must return 'yes' if it is, and 'no' if it is not. If chat gpt doesn't know it must answer 'unknown'.
- Go to your
search
config - Go to api
- Check context field. See the result
- Change
q=kitchen
query parameter. ChatGPT must answer 'no' - Change
q=bike
query parameter. ChatGPT must answer 'yes' - Change
q=abdgdfgbdfg
query parameter. ChatGPT must answer 'unknown', because we have empty document list for this query