Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ import json
|
|
| 15 |
import os
|
| 16 |
from markdown_pdf import MarkdownPdf, Section
|
| 17 |
import tempfile
|
| 18 |
-
|
| 19 |
# Configure Gemini API
|
| 20 |
gemini_api_key = os.environ.get('GOOGLE_API_KEY')
|
| 21 |
if not gemini_api_key:
|
|
@@ -34,7 +34,16 @@ model = genai.GenerativeModel(
|
|
| 34 |
model_name="gemini-2.0-flash-thinking-exp",
|
| 35 |
generation_config=generation_config,
|
| 36 |
)
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
def load_data():
|
| 40 |
"""Load data from CSV files and validate"""
|
|
@@ -139,7 +148,7 @@ class StreamLitResponse(ResponseParser):
|
|
| 139 |
|
| 140 |
def generateResponse(prompt, data):
|
| 141 |
"""Generate response using PandasAI with SmartDataLake"""
|
| 142 |
-
|
| 143 |
|
| 144 |
# Ensure data is a dictionary of DataFrames
|
| 145 |
if not isinstance(data, dict) or not all(isinstance(df, pd.DataFrame) for df in data.values()):
|
|
@@ -149,7 +158,7 @@ def generateResponse(prompt, data):
|
|
| 149 |
pandas_agent = SmartDatalake(
|
| 150 |
list(data.values()), # Pass list of DataFrames
|
| 151 |
config={
|
| 152 |
-
"llm":
|
| 153 |
"response_parser": StreamLitResponse
|
| 154 |
}
|
| 155 |
)
|
|
|
|
| 15 |
import os
|
| 16 |
from markdown_pdf import MarkdownPdf, Section
|
| 17 |
import tempfile
|
| 18 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 19 |
# Configure Gemini API
|
| 20 |
gemini_api_key = os.environ.get('GOOGLE_API_KEY')
|
| 21 |
if not gemini_api_key:
|
|
|
|
| 34 |
model_name="gemini-2.0-flash-thinking-exp",
|
| 35 |
generation_config=generation_config,
|
| 36 |
)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
# Pandasai gemini
|
| 40 |
+
llm1 = ChatGoogleGenerativeAI(
|
| 41 |
+
model="gemini-2.0-flash-thinking-exp",
|
| 42 |
+
temperature=0,
|
| 43 |
+
max_tokens=None,
|
| 44 |
+
timeout=None,
|
| 45 |
+
max_retries=2
|
| 46 |
+
)
|
| 47 |
|
| 48 |
def load_data():
|
| 49 |
"""Load data from CSV files and validate"""
|
|
|
|
| 148 |
|
| 149 |
def generateResponse(prompt, data):
|
| 150 |
"""Generate response using PandasAI with SmartDataLake"""
|
| 151 |
+
|
| 152 |
|
| 153 |
# Ensure data is a dictionary of DataFrames
|
| 154 |
if not isinstance(data, dict) or not all(isinstance(df, pd.DataFrame) for df in data.values()):
|
|
|
|
| 158 |
pandas_agent = SmartDatalake(
|
| 159 |
list(data.values()), # Pass list of DataFrames
|
| 160 |
config={
|
| 161 |
+
"llm": llm1,
|
| 162 |
"response_parser": StreamLitResponse
|
| 163 |
}
|
| 164 |
)
|