Spaces:
Sleeping
Sleeping
UPDATE: Analyzer
Browse files- app.py +3 -3
- functions.py +3 -4
app.py
CHANGED
|
@@ -165,14 +165,14 @@ async def getYTTranscript(url: str):
|
|
| 165 |
|
| 166 |
@app.post("/analyzeData")
|
| 167 |
async def analyzeAndAnswer(query: str, file: UploadFile = File(...)):
|
| 168 |
-
extension = file.
|
| 169 |
if extension in ["xls", "xlsx", "xlsm", "xlsb"]:
|
| 170 |
-
df = pd.read_excel(io.BytesIO(file.read()))
|
| 171 |
return {
|
| 172 |
"output": analyzeData(query = query, dataframe = df)
|
| 173 |
}
|
| 174 |
elif extension == "csv":
|
| 175 |
-
df = pd.read_csv(io.BytesIO(file.read()))
|
| 176 |
return {
|
| 177 |
"output": analyzeData(query = query, dataframe = df)
|
| 178 |
}
|
|
|
|
| 165 |
|
| 166 |
@app.post("/analyzeData")
|
| 167 |
async def analyzeAndAnswer(query: str, file: UploadFile = File(...)):
|
| 168 |
+
extension = file.filename.split(".")[-1]
|
| 169 |
if extension in ["xls", "xlsx", "xlsm", "xlsb"]:
|
| 170 |
+
df = pd.read_excel(io.BytesIO(await file.read()))
|
| 171 |
return {
|
| 172 |
"output": analyzeData(query = query, dataframe = df)
|
| 173 |
}
|
| 174 |
elif extension == "csv":
|
| 175 |
+
df = pd.read_csv(io.BytesIO(await file.read()))
|
| 176 |
return {
|
| 177 |
"output": analyzeData(query = query, dataframe = df)
|
| 178 |
}
|
functions.py
CHANGED
|
@@ -298,10 +298,9 @@ def getTextFromImagePDF(pdfBytes):
|
|
| 298 |
text = "\n\n\n".join(["\n".join([text[1] for text in reader.readtext(image, paragraph=True)]) for image in allImages])
|
| 299 |
return text
|
| 300 |
|
| 301 |
-
|
| 302 |
-
def getTranscript(urls: dict[str, str]):
|
| 303 |
loader = YoutubeLoader.from_youtube_url(
|
| 304 |
-
|
| 305 |
)
|
| 306 |
try:
|
| 307 |
doc = " ".join([x.page_content for x in loader.load()])
|
|
@@ -311,7 +310,7 @@ def getTranscript(urls: dict[str, str]):
|
|
| 311 |
|
| 312 |
|
| 313 |
def analyzeData(query, dataframe):
|
| 314 |
-
llm = ChatGroq("gemma2-9b-it")
|
| 315 |
df = SmartDataframe(dataframe, config = {"llm": llm, "verbose": False})
|
| 316 |
response = df.chat(query)
|
| 317 |
return response
|
|
|
|
| 298 |
text = "\n\n\n".join(["\n".join([text[1] for text in reader.readtext(image, paragraph=True)]) for image in allImages])
|
| 299 |
return text
|
| 300 |
|
| 301 |
+
def getTranscript(urls: str):
|
|
|
|
| 302 |
loader = YoutubeLoader.from_youtube_url(
|
| 303 |
+
urls.split(","), add_video_info = False
|
| 304 |
)
|
| 305 |
try:
|
| 306 |
doc = " ".join([x.page_content for x in loader.load()])
|
|
|
|
| 310 |
|
| 311 |
|
| 312 |
def analyzeData(query, dataframe):
|
| 313 |
+
llm = ChatGroq(name = "gemma2-9b-it")
|
| 314 |
df = SmartDataframe(dataframe, config = {"llm": llm, "verbose": False})
|
| 315 |
response = df.chat(query)
|
| 316 |
return response
|