Chat GPT Integration
We have an integration to Chat-GPT in our platform, which is implemented for search purpose.
Demo
For complete step-by-step instruction see Quick Start Demo
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."
}
} - Replace 'chat-gpt-quick-start-demo' with the name of your search config, where you want to use it
- Click 'Save'
Json structure
{
"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."
}
}
type
- must besearchResultRefinement
to use it with ChatGPT filtersearchResultRefinement.requestTemplate
- freemarker template, which would be used to send requests to ChatGPTsearchResultRefinement.appendToSearchContextKey
- an alphanumeric value to determine json key where we put a ChatGPT answer in search responsesearchResultRefinement.contextString
- a context for ChatGPT. A string where you would enter the instructions for chat GPT and preconfigure what it needs to do.
Connect config to search
- Go to your search config
- Go to 'Pipeline' tab
- Choose 'Custom' pipeline type
- Post yaml
!!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-integration-config"
modelId: "gpt-3.5-turbo"
chatGptConfigCode: "chat-gpt-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
- Click 'Save'
Yaml structure
- !!com.quasiris.qsc.chatgpt.filter.ChatGPTFilter
active: true
apiKey: "chat-gpt-api-key"
modelId: "gpt-3.5-turbo"
chatGptConfigCode: "chat-gpt-config"
resultSetId: {{searchCode}}
maxTokens: 10
timeoutMills: 8000
temperature: 0
active
- specify if filter must be executedapiKey
- api key for ChatGPTmodelId
- model id of ChatGPTchatGptConfigCode
- the config code, which you created in previous stepsresultSetId
- result set id, where you want to put chat gpt responsemaxTokens
- maxTokens configurations for ChatGPTtimeoutMills
- timeout for the operationtemperature
- temperature for ChatGPT requests (0 - the most precise, 1 - the most unpredictable)
Test search
Now you can make search with the search config and find chat gpt response in context fields.
For example if you have search config with code 'demo', the json path to retrieve the context would be
$.result.demo.context