Save Chat history conversations in txt file or json file or yml file in python
Hi,
I want to save the chat conversations between user and bot and save it on the txt file or yml file or json format this help in avoid training all the time and i want call this chat history file for further process could any one help in this issue please
Thank you in advance
Happy codding...
This might helpful https://chatterbot.readthedocs.io/en/stable/corpus.html#exporting-your-chat-bot-s-database-as-a-training-corpus
@vkosuri hi this is my code
from flask import Flask, render_template, request from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer
app = Flask(name)
english_bot = ChatBot("Chatterbot", storage_adapter="chatterbot.storage.SQLStorageAdapter")
english_bot.set_trainer(ChatterBotCorpusTrainer) english_bot.train("./data")
@app.route("/") def home(): return render_template("index.html")
@app.route("/get") def get_bot_response(): userText = request.args.get('msg') reply = str(english_bot.get_response(userText))
if name == "main": app.run()
now i want to save the chat conversations which are from the data folder(contains yml files) and after the conversation is finished i want to save that conversation in one file
could you help me in that way
Thank you in advance
Happy codding....
You can probably do this manually. Every time the user asks a question, add it do a dict. When you get the bot response, add it to the dict as well and so on and so forth. At the end, when the user exists the program, you can export the dict into a file. For example, if you use PyYAML, you can simply do yaml.dump(dict) . Then you can use the resulting .yaml file to train your bot via the ChatterbotCorpusTrainer.
Thank you @Ligh7bringer
Hi every one while i am saving the chat data into a yml file i failed to save the url data how can i save that data in then yml file in chatterbot using python
Thank you in advance ..... Happy codding......
Hi everyone, I want to save the chat conversations which are from the data folder and after the conversation is finished, I want to save that conversation in on file.