从“ Rasa”中的mongo-tracker提取数据,并在运行时将其存储在mongoDB中,例如sender_id,timestamp

时间:2019-03-15 19:40:10

标签: mongodb pymongo rasa-nlu rasa-core

请告诉我您如何从跟踪商店中获取特定详细信息。在下面阐述我的疑问:

在我的run_app.py(socketIO类)中,我像这样使用过mongotracker-

  

db = MongoTrackerStore(域=“ d.yml”,host =“主机ip”,db =“ xyz”,用户名=“ x”,密码=“ x”,集合=“ x”,event_broker =无)

     

agent = Agent.load('models / dialog',interpreter ='models / current / nlu',action_endpoint = action_endpoint,tracker_store = db)

现在我想获取一些数据,例如db.sender_id或db.event。这样做的原因是将它按列明智地存储在mongodb上。请帮助我解决此问题。

2 个答案:

答案 0 :(得分:0)

该信息应该已经存储在您的mongodb中,因此不需要额外的存储信息。 也许请参阅此https://rasa.com/docs/core/tracker_stores/的文档,并确保您的endpoints.yml文件包含正确的信息:

tracker_store:
    store_type: mongod
    url: <url to your mongo instance, e.g. mongodb://localhost:27017>
    db: <name of the db within your mongo instance, e.g. rasa>
    username: <username used for authentication>
    password: <password used for authentication>
    auth_source: <database name associated with the user’s credentials>

有关如何从mongodb中获取特定详细信息的信息,请查看mongodb文档https://docs.mongodb.com/manual/reference/method/db.collection.find/

答案 1 :(得分:0)

看这个例子 我正在使用Pymongo连接monogoDB。尝试理解我的代码

from typing import Any, Text, Dict, List
from pymongo.database import Database
from pymongo import MongoClient
from rasa_sdk import Action, Tracker 
from rasa_sdk.executor import CollectingDispatcher
import pymongo
# url="http://localhost:3000/api"
client = pymongo.MongoClient("localhost", 27017)
db=client.sample
class mercdesCarAction(Action):
    def name(self):
        return "mercdesCarAction"
    def run(self,dispatcher,tracker,domain):
        res = db.datas.find({'action':'mercdesCarAction'})
        for i in res:
            dispatcher.utter_button_message(i['text'],i['buttons'])
        return []