聊天机器人

收集窗帘相关的数据

可以用gpt生成,也可以用爬虫

图形化界面 gradio

向量数据库 faiss

python代码

python 复制代码
import gradio as gr
import random
import time

from typing import List

from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import FAISS
from langchain.chains import RetrievalQA
from langchain.chat_models import ChatOpenAI


def initialize_sales_bot(vector_store_dir: str="real_estates_sale"):
    db = FAISS.load_local(vector_store_dir, OpenAIEmbeddings())
    llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0)
    
    global SALES_BOT    
    SALES_BOT = RetrievalQA.from_chain_type(llm,
                                           retriever=db.as_retriever(search_type="similarity_score_threshold",
                                                                     search_kwargs={"score_threshold": 0.8}))
    # 返回向量数据库的检索结果
    SALES_BOT.return_source_documents = True

    return SALES_BOT

def sales_chat(message, history):
    print(f"[message]{message}")
    print(f"[history]{history}")
    # TODO: 从命令行参数中获取
    enable_chat = True

    ans = SALES_BOT({"query": message})
    # 如果检索出结果,或者开了大模型聊天模式
    # 返回 RetrievalQA combine_documents_chain 整合的结果
    if ans["source_documents"] or enable_chat:
        print(f"[result]{ans['result']}")
        print(f"[source_documents]{ans['source_documents']}")
        return ans["result"]
    # 否则输出套路话术
    else:
        return "这个问题我要问问领导"
    

def launch_gradio():
    demo = gr.ChatInterface(
        fn=sales_chat,
        title="窗帘销售",
        # retry_btn=None,
        # undo_btn=None,
        chatbot=gr.Chatbot(height=600),
    )

    demo.launch()

if __name__ == "__main__":
    # 初始化房产销售机器人
    initialize_sales_bot()
    # 启动 Gradio 服务
    launch_gradio()

最中结果如下:

相关推荐
小康小小涵1 小时前
WSL2安装移植到F盘并集成ubuntu20的ros-noetic
人工智能·机器人·自动驾驶
热爱专研AI的学妹2 小时前
用n8n搭建新闻推送简报机器人:数眼智能搜索+网页阅读API实战指南
机器人
具身智能之心2 小时前
ImaginationPolicy:迈向通用、精确、可靠的机器人操作端到端策略
机器人·端到端·具身智能
Deepoch3 小时前
从“机械执行”到“意图理解”:Deepoc如何重塑人机交互新范式
人工智能·机器人·开发板·具身模型·deepoc
码农三叔3 小时前
(9-2-01)自动驾驶中基于概率采样的路径规划:基于Gazebo仿真的路径规划系统(1)
人工智能·机器学习·机器人·自动驾驶·路径规划
富唯智能3 小时前
人形机器人 | 富唯智能具身智能赋能工业柔性制造
机器人·制造
智慧医院运行管理解决方案专家3 小时前
平安医院 智守心安 | AI智能巡逻机器人 全时域守护日志
人工智能·机器人
Deepoch3 小时前
Deepoc具身模型开发板:让采摘机器人成为果园的“智能农艺师“
人工智能·机器人·农业·采摘机器人·具身模型·deepoc·采摘
视***间3 小时前
视程空间AIR算力开发平台:以边缘智能之核,驱动机器人产业迈入全域自动化时代
大数据·人工智能·机器人·区块链·边缘计算·视程空间
AI猫站长4 小时前
快讯|DeepSeek Engram论文详解存算分离,华为SWE-Lego开源轻量级代码智能体全栈方案,
人工智能·机器人·开源·具身智能·deepseek·灵心巧手