Spaces:
Sleeping
Sleeping
fschwartzer
commited on
Commit
•
12c16b3
1
Parent(s):
651ecea
Update app.py
Browse files
app.py
CHANGED
@@ -30,7 +30,7 @@ model = genai.GenerativeModel(model_name="gemini-pro",
|
|
30 |
|
31 |
def gemini(query):
|
32 |
prompt_parts = [
|
33 |
-
f"input: \"Procurar {query} em df['Title'] que sejam mais
|
34 |
"output: ",
|
35 |
f"input: {query}",
|
36 |
"output: ",
|
@@ -70,17 +70,18 @@ def fetch_data_to_dataframe(query, limit=50, source="mercadolibre", token=None):
|
|
70 |
|
71 |
def integrated_app(query):
|
72 |
# Interpret the prompt using the Gemini model
|
73 |
-
interpreted_response = gemini(query)
|
|
|
|
|
74 |
|
75 |
-
# Fetch data from Mercado Livre based on the
|
76 |
-
df = fetch_data_to_dataframe(
|
77 |
|
78 |
if df.empty:
|
79 |
return "No data found", pd.DataFrame()
|
80 |
else:
|
81 |
# Process the fetched data
|
82 |
median_price = df['Price'].median()
|
83 |
-
# You could add more processing here based on the Gemini response
|
84 |
|
85 |
# Return the processed data
|
86 |
return median_price, df
|
|
|
30 |
|
31 |
def gemini(query):
|
32 |
prompt_parts = [
|
33 |
+
f"input: \"Procurar e selecionar {query} em df['Title'] que, numa análise sintática, sejam as mais próximas possíveis\"",
|
34 |
"output: ",
|
35 |
f"input: {query}",
|
36 |
"output: ",
|
|
|
70 |
|
71 |
def integrated_app(query):
|
72 |
# Interpret the prompt using the Gemini model
|
73 |
+
interpreted_response = gemini(query)
|
74 |
+
|
75 |
+
refined_query = extract_refined_query(interpreted_response)
|
76 |
|
77 |
+
# Fetch data from Mercado Livre based on the refined query
|
78 |
+
df = fetch_data_to_dataframe(refined_query, 50, source="mercadolibre")
|
79 |
|
80 |
if df.empty:
|
81 |
return "No data found", pd.DataFrame()
|
82 |
else:
|
83 |
# Process the fetched data
|
84 |
median_price = df['Price'].median()
|
|
|
85 |
|
86 |
# Return the processed data
|
87 |
return median_price, df
|