具有数字和字符串数据的意图聊天机器人
Intent chatbot with numeric and strings data
我正在尝试使用意图作为 json 文件来构建聊天机器人,意图的一个示例是
{"tag": "thanks",
"patterns": ["Thanks", "Thank you", "That's helpful"],
"responses": ["Happy to help!", "Any time!", "My pleasure"]
},
我有很多其他标签,但我希望聊天机器人根据输入文本和其他因素检测响应,例如语音强度,其值范围为 1-10。
聊天机器人已经使用 tensorflow 进行了训练。
如何修改意图文件并向聊天机器人输入文本和一些信息。
Chatbot 通过此代码运行
def chat():
print("Start talking with the bot (type quit to stop)!")
while True:
inp = input("You: ")
if inp.lower() == "quit":
break
results = model.predict([bag_of_words(inp, words)])
results_index = numpy.argmax(results)
tag = labels[results_index]
for tg in data["intents"]:
if tg['tag'] == tag:
responses = tg['responses']
print("Chatbot: ",random.choice(responses))
我想要的是,例如语音强度是 8,句子是“你想要什么”,响应应该是这样的
“你为什么紧张?”
您可以向意图文件添加一个函数,该函数可以在每个意图中执行任何目的。例如
{"tag": "thanks",
"patterns": ["Thanks", "Thank you", "That's helpful"],
"responses": ["Happy to help!", "Any time!", "My pleasure"]
"action": getname()
},
我正在尝试使用意图作为 json 文件来构建聊天机器人,意图的一个示例是
{"tag": "thanks",
"patterns": ["Thanks", "Thank you", "That's helpful"],
"responses": ["Happy to help!", "Any time!", "My pleasure"]
},
我有很多其他标签,但我希望聊天机器人根据输入文本和其他因素检测响应,例如语音强度,其值范围为 1-10。 聊天机器人已经使用 tensorflow 进行了训练。 如何修改意图文件并向聊天机器人输入文本和一些信息。
Chatbot 通过此代码运行
def chat():
print("Start talking with the bot (type quit to stop)!")
while True:
inp = input("You: ")
if inp.lower() == "quit":
break
results = model.predict([bag_of_words(inp, words)])
results_index = numpy.argmax(results)
tag = labels[results_index]
for tg in data["intents"]:
if tg['tag'] == tag:
responses = tg['responses']
print("Chatbot: ",random.choice(responses))
我想要的是,例如语音强度是 8,句子是“你想要什么”,响应应该是这样的 “你为什么紧张?”
您可以向意图文件添加一个函数,该函数可以在每个意图中执行任何目的。例如
{"tag": "thanks",
"patterns": ["Thanks", "Thank you", "That's helpful"],
"responses": ["Happy to help!", "Any time!", "My pleasure"]
"action": getname()
},