Comments (3)
By design, the EndSession
button is shown if the AI decides to end the session but you can control it by manipulating isSessionEnded
state variable. Just remove the conditional (Line 442, components/chat.jsx) to always show it.
If you want to adapt this to other business application, you need to fix the function calling. Refer to app/chat2/route.js
file. There are several parts you need to edit:
Line 9, is the start of the function definition used in function calling. You need to add your own functions (e.g. get_user_booking, etc.).
Line 61, is the function calling system prompt. Edit it to reflect your function, etc.
Between Line 114 and 158, is the "external API call" part. Change it and put your own code there that will consume the result of the function calling.
Let say you have get_user_booking
that has the output { name: 'John Doe', bookingNo: '1234567' }
, then you can use it to retrieve data from your own DB or API.
from callcenter-simulator.
Thank you for the details:
I have the have get_user_booking that has the output
{ name: 'John Doe', bookingNo: '1234567', status: 'success', amunt: '123', date: '2023-09-01' }, for this do I need insert this value in mongodb first then do the code change ?
actually I am trying replicate how "order inquery" status working for order status , like wise planning to add one more for booking inquery. no need to add UI part , just want to insert few records in db and like check the status in chat and voice.
Can you please share your contact email if you can.
from callcenter-simulator.
Assuming that you are trying to add booking entry, yes you need to insert the output to your own MongoDB. Then you need to tell Chat API the result (if insert is successful or not). Refer to Line 249 of app/chat2/route.js. For example:
If insert failed
messages.push({ role: 'assistant', content: null, function_call: { name: 'get_user_booking', arguments: `{\n "name": "John Doe", "bookingNo": "1234567", "status":"error","amount": "123", "date": "2023-09-01" \n}` }})
messages.push({ role: 'function', name: 'get_user_booking', content: JSON.stringify({ error: "Failed to add booking. Missing parameter." }) })
If successful
messages.push({ role: 'assistant', content: null, function_call: { name: 'get_user_booking', arguments: `{\n "name": "John Doe", "bookingNo": "1234567", "status":"success","amount": "123", "date": "2023-09-01" \n}` }})
messages.push({ role: 'function', name: 'get_user_booking', content: JSON.stringify({ message: "Booking added. Thank you..." }) })
This part is most important so that Chat api can decide what to do next. For example, if it failed and you said in the error message that "contact number" is missing, the AI will ask the user for the contact number.
from callcenter-simulator.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from callcenter-simulator.