Giter Site home page Giter Site logo

langchain_llm_chatbot's Introduction

LangChain 学习指南

案例-01 基于上传PDF文档进行QA问答

  • 01 实现基于 streamlit + OpenAI 的QA问答(文件格式:PDF)
streamlit run chatbot.py
  • 02 实现基于 gradio + OpenAI 的QA问答(文件格式:PDF)
gradio chatbot_gradio.py

或者

访问HuggingFace Space体验:
https://huggingface.co/spaces/Tommy930/chatbot-PDF

langchain_llm_chatbot's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

langchain_llm_chatbot's Issues

执行chatbot.py 执行, 构建vectorstore之后, 查询文档报错

遇到一个问题,使用streamlit构建的应用,执行chatbot.py脚本,第一次查询可以得到结果,第二次再输入查询,报错信息
ValueError: Unsupported chat history format: <class 'str'>. Full chat history: Human

  • 使用的本地服务器部署的ChatGLM模型,没有使用openai

报错位置
def process_user_input(user_input):
if st.session_state.conversation is not None:
# 调用函数st.session_state.conversation,并把用户输入的内容作为一个问题传入,返回响应。
response = st.session_state.conversation({'question': user_input})
# session状态是Streamlit中的一个特性,允许在用户的多个请求之间保存数据。
st.session_state.chat_history = response['chat_history']

顺便看了一下源码
def _get_chat_history(chat_history: List[CHAT_TURN_TYPE]) -> str:
buffer = ""
for dialogue_turn in chat_history:
if isinstance(dialogue_turn, BaseMessage):
role_prefix = _ROLE_MAP.get(dialogue_turn.type, f"{dialogue_turn.type}: ")
buffer += f"\n{role_prefix}{dialogue_turn.content}"
elif isinstance(dialogue_turn, tuple):
human = "Human: " + dialogue_turn[0]
ai = "Assistant: " + dialogue_turn[1]
buffer += "\n" + "\n".join([human, ai])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.