Comments (8)
I need to be able to change the conversation ID on the fly
@eric-gardyn we just shipped a new version of the chatbot UI that lets you switch the active conversation without requiring a page reload.
npm install mongodb-chatbot-ui@^0.4.0
Specifically there's now a new method available on the conversation
instance you get from the useConversation()
or useChatbot()
hook (which you can call anywhere inside of the <Chatbot />
provider).
// Get the conversation directly
const conversation = useConversation()
// ... or get it from the chatbot hook
const { conversation } = useChatbot()
// Switch conversations by `id`
await conversation.switchConversation("65cbd564891d8167b8a9586e");
// You can also now start a new conversation which will replace the existing one
await conversation.createConversation();
Note - we don't currently have any built-in support for keeping a list of the user's conversation ids. You'll need to save those somewhere in your code if you want to switch between them later.
I'd also recommend upgrading to the latest version of the server which includes a bug fix for the getConversation
route that the switchConversation()
method calls under the hood. The older version of the route returns the entire conversation including the system prompt which you probably don't want.
npm install mongodb-chatbot-server@^0.6.0
from chatbot.
if you're using the UI library, hacking the fetch function like you did is probably the easiest way to go about it. however, to make things less hacky, we already have the following PR up in review that will let you pass fetch options to the chatbot as a prop #308
from chatbot.
Hey Eric!
That's strange that req.params
is empty - it should contain a variable for every route segment that starts with a colon, e.g. /conversations/:conversationId
.
- Are you testing the middleware on a route like that?
- If you
console.log(JSON.stringify(req.params))
what is the output?
Like Ben mentioned we should have a first class way for you to define custom headers and other fetch options in our next UI release. In the meantime, you can also try passing in your properties as query params (e.g. /conversations/65bd1fc7ddda193e3dc25ed8?userId=abc123
) which you could then access on the server via req.query.userId
.
from chatbot.
Hey Eric!
That's strange that
req.params
is empty - it should contain a variable for every route segment that starts with a colon, e.g./conversations/:conversationId
.
- Are you testing the middleware on a route like that?
- If you
console.log(JSON.stringify(req.params))
what is the output?Like Ben mentioned we should have a first class way for you to define custom headers and other fetch options in our next UI release. In the meantime, you can also try passing in your properties as query params (e.g.
/conversations/65bd1fc7ddda193e3dc25ed8?userId=abc123
) which you could then access on the server viareq.query.userId
.
sorry, I had meant to say that the mongodb-chatbot-ui Chatbot would not let me update the params object (nor header), and could not find an easy way to add query param (?userId=abc123) to the URL in a dynamic way.
I tested with my own test UI, and I am able to extract params from mongodb-chatbot-server, using a middleware.
from chatbot.
Gotcha. Are you still having any issues on this? If so, do you think being able to define custom fetchOptions
to include with all requests (as implemented in #308) will help?
from chatbot.
I took a look at the PR. I think it should work (wasn't able to pull the entire code locally to test).
From a UI point of view, I need to be able to change the conversation ID, on the fly, meaning that it might change throughout the session (to have a history of conversations)
from chatbot.
I need to be able to change the conversation ID on the fly
This is on our roadmap to add soon but unfortunately isn't ready yet. I think you could piece this together using some of the lower level components/hooks we export (e.g. by calling the useConversation
hook in your own components) but this is definitely not optimal.
Since this is something we will want eventually I'll see if we can prioritize shipping first-class conversation switching.
from chatbot.
Following up on the original request here - we just released a new UI version with support for custom fetch options. This should help you pass custom headers and otherwise customize your requests.
npm install mongodb-chatbot-ui@^0.5.0
function App() {
return (
<Chatbot
name="My Chatbot"
serverBaseUrl="https://myserver.example.com"
fetchOptions={{
headers: new Headers({ "X-User-ID": "<You User ID>" })
}}
>
{/* ... */}
</Chatbot>
)
}
from chatbot.
Related Issues (13)
- `ApiConversations` service
- `POST /api-conversation` endpoint to create api conversation for api chat session
- `POST /api-conversations/:conversationId/messages/:messageId/rating` for Api conversation rate message endpoint
- How do you install this? HOT 1
- InputBarTrigger does not accept placeholder HOT 2
- IP error when deploying mongodb-chatbot-server HOT 1
- is VECTOR_SEARCH_INDEX_NAME customizable? HOT 3
- Cannot find the LG packages HOT 5
- OPENAI_EMBEDDING_MODEL="text-embedding-3-small" not working? HOT 9
- Info retrieval and LLM function calling with parameter HOT 5
- Documentation improvement: Booster HOT 3
- Instrumenting with LangSmith HOT 3
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 chatbot.