Skip to main content

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

  1. Go to Quasiris Search Cloud
  2. Enter 'Config' in the top left search input
  3. Click on 'Config' image.png
  4. Create a config with name 'chat-gpt-integration-config' img.png
  5. 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."
    }
    }
  6. Click 'Save' img.png

Run Quick Start

  1. Go to Quick Start img.png
  2. Enter code chat-gpt-quick-start-demo
  3. 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"
}
]
  1. Click Create Search img.png
  2. Click Next until you see Apply button img.png
  3. Click Apply
  4. Go to Search config img.png
  5. Go to your config chat-gpt-quick-start-demo
  6. Go to Pipeline tab
  7. As Pipeline Type choose Custom
  8. 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
  1. Set the right api key in yaml
  2. Save the config img.png

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'.

  1. Go to your search config
  2. Go to api img.png
  3. Check context field. See the result
  4. Change q=kitchen query parameter. ChatGPT must answer 'no'
  5. Change q=bike query parameter. ChatGPT must answer 'yes'
  6. Change q=abdgdfgbdfg query parameter. ChatGPT must answer 'unknown', because we have empty document list for this query