SmartMenuCSV / app.py
denaneek's picture
Update app.py
36f0216
raw
history blame
1.54 kB
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Chroma
from langchain.text_splitter import CharacterTextSplitter
from langchain.chains.question_answering import load_qa_chain
from langchain.agents import create_csv_agent
from langchain.llms import OpenAI
import os
import pandas as pd
file_name = 'gpt-generated-food-data.csv'
df = pd.read_csv(file_name)
agent = create_csv_agent(OpenAI(temperature=0),
file_name,
verbose=True)
agent.agent.llm_chain.prompt.template
def make_inference(query):
docs = docsearch.get_relevant_documents(query)
return(agent.run(input_documents=docs, question=query))
if __name__ == "__main__":
# make a gradio interface
import gradio as gr
gr.Interface(
make_inference,
[
gr.inputs.Textbox(lines=2, label="Query"),
],
gr.outputs.Textbox(label="Response"),
title="🍲SmartMenuCSV📄",
description='🍲SmartMenuCSV📄 is a tool that allows you to ask questions about food menu items. \n You can ask: \n "How many food items are gluten, vegan?" \n "How many food items have more than 400g calories and what are their names?" \n "What are the names of the food items with pickles and mayo?" \n "Are there more vegan or gluten-free items?" \n What is the average calories per food?" \n "Which ingredient appears the most and how many times does it appear?" \n "What is the ratio of vegan to gluten?" \n And more ...',
).launch()