ChatExcel?

2023-11-07

大家好,我是章北海mlpy
最近在浅学LangChain,在大模型时代,感觉这玩意很有前途。

LangChain是一个开源的应用开发框架,目前支持Python和TypeScript两种编程语言。

它赋予LLM两大核心能力:数据感知,将语言模型与其他数据源相连接;代理能力,允许语言模型与其环境互动。

LangChain的主要应用场景包括个人助手、基于文档的问答、聊天机器人、查询表格数据、代码分析等。

之前大火的ChatPDF应该就是用LangChain实现的
昨晚又看到一个有趣的实例:Chat with CSV&Excel using LangChain and OpenAI,蛮粗糙的,感觉可以用Gradio加个前端,或许有点意思。

https://github.com/amrrs/csvchat-langchain

源代码有TypeError的bug,我改了一下,可以跑通了,有感兴趣的可以直接复制。

# -*- coding: utf-8 -*-

from langchain.document_loaders import CSVLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.chains import RetrievalQA
from langchain.llms import OpenAI
import os
os.environ["OPENAI_API_KEY"] = "sk-你的API"
!wget https://gist.githubusercontent.com/armgilles/194bcff35001e7eb53a2a8b441e8b2c6/raw/92200bc0a673d5ce2110aaad4544ed6c4010f687/pokemon.csv 
# Load the documents
import csv
loader = CSVLoader(file_path='/Users/huhaiyang/projs/myrepo/pokemon.csv', csv_args={
    'delimiter': ','})
# Create an index using the loaded documents
index_creator = VectorstoreIndexCreator()
docsearch = index_creator.from_loaders([loader])
# Create a question-answering chain using the index
chain = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff", retriever=docsearch.vectorstore.as_retriever(), input_key="question")

# Pass a query to the chain
query = "Do you have a column called age?"
response = chain({"question": query})
print(response['result'])

我简单测试了,胡说八道含量很高。

后期再深入研究吧,看是否可以达到简单统计,甚至实现透视表的程度。
基于ChatGPT,论文写作工具

围绕 ChatGPT,赚了点小钱

国内可用 ChatGPT 客户端下载

数据分析入门:统计学基础知识总结

可能是全网最全的速查表:Python Numpy Pandas Matplotlib 机器学习 ChatGPT

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ChatExcel? 的相关文章

随机推荐