denaneek commited on
Commit
5b74c5b
·
1 Parent(s): 3e7595d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -6,9 +6,13 @@ from langchain.chains.question_answering import load_qa_chain
6
  from langchain.llms import OpenAI
7
  from langchain.document_loaders.csv_loader import CSVLoader
8
  import os
9
-
 
10
  file_name = 'gpt-generated-food-data.csv'
11
 
 
 
 
12
  agent = create_csv_agent(OpenAI(temperature=0),
13
  file_name,
14
  verbose=True)
@@ -16,7 +20,7 @@ agent = create_csv_agent(OpenAI(temperature=0),
16
  loader = CSVLoader(file_path=file_name)
17
  data = loader.load()
18
 
19
- text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0, separator = "\n")
20
  texts = text_splitter.split_text(data)
21
 
22
  embeddings = OpenAIEmbeddings()
@@ -41,5 +45,5 @@ if __name__ == "__main__":
41
  ],
42
  gr.outputs.Textbox(label="Response"),
43
  title="🍲SmartMenuCSV📄",
44
- 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 ...',
45
  ).launch()
 
6
  from langchain.llms import OpenAI
7
  from langchain.document_loaders.csv_loader import CSVLoader
8
  import os
9
+ import pandas as pd
10
+
11
  file_name = 'gpt-generated-food-data.csv'
12
 
13
+
14
+ df = pd.read_csv(file_name)
15
+
16
  agent = create_csv_agent(OpenAI(temperature=0),
17
  file_name,
18
  verbose=True)
 
20
  loader = CSVLoader(file_path=file_name)
21
  data = loader.load()
22
 
23
+ text_splitter = CharacterTextSplitter(chunk_size=100, chunk_overlap=0, separator = "\n")
24
  texts = text_splitter.split_text(data)
25
 
26
  embeddings = OpenAIEmbeddings()
 
45
  ],
46
  gr.outputs.Textbox(label="Response"),
47
  title="🍲SmartMenuCSV📄",
48
+ description="🍲SmartMenuCSV📄 is a tool that allows you to ask questions about food menu items.",
49
  ).launch()