... > Running step 8f16654d-e689-4366-a3c0-8e7a397a94cf. Step input: estacionamientos y evaluación ambiental Thought: The current language of the user is: Spanish. I need to determine if the question is specific enough to use the vector_tool or if it requires a more general summary using the summary_tool. The question "estacionamientos y evaluación ambiental" (parking lots and environmental assessment) is quite broad. I will use the summary_tool to get a general overview of how Decreto 40 of 2013 addresses parking lots and environmental assessments. Action: summary_tool Action Input: {'input': 'Decreto 40 de 2013, estacionamientos y evaluación ambiental'} > Refine context: Decreto 30, g ter) Observación ciudadana: Toda ... > Refine context: c) Centrales generadoras de energía mayores a... ------------ ERROR --------- Observation: Error: The model response did not complete successfully. Finish reason: 2. Finish message: . Safety ratings: []. To protect the integrity of the chat session, the request and response were not added to chat history. To skip the response validation, specify `model.start_chat(response_validation=False)`. Note that letting blocked or otherwise incomplete responses into chat history might lead to future interactions being blocked by the service. ------------ --- --------- ...
Settings.embed_model = VertexTextEmbedding("textembedding-gecko-multilingual@001", credentials=credentials) Settings.llm = Vertex( model="gemini-2.0-flash", temperature=0, project=credentials.project_id, credentials=credentials, max_tokens = 8192, context_window=1048576 )
from llama_index.core import SummaryIndex from llama_index.embeddings.vertex import VertexTextEmbedding from llama_index.llms.vertex import Vertex from llama_index.core import ( Settings) import pandas as pd from google.oauth2 import service_account from llama_index.readers.file import PyMuPDFReader from llama_index.core import Document filename = "/path/to/your/file" credentials: service_account.Credentials = ( service_account.Credentials.from_service_account_file(filename) ) Settings.embed_model = VertexTextEmbedding("textembedding-gecko-multilingual@001", credentials=credentials) Settings.llm = Vertex( model="gemini-2.0-flash", temperature=0, project=credentials.project_id, credentials=credentials, max_tokens = 8192, context_window=1048576 ) loader = PyMuPDFReader() pdf_path = '1.dp_inmobiliarios.pdf' extra_info = {"document_name": pdf_path} splitted_text = loader.load(file_path=pdf_path, metadata=True, extra_info=extra_info) full_text = "\n\n".join([d.get_content() for d in splitted_text]) single_document = Document(text=full_text) summary_index = SummaryIndex.from_documents([single_document]) query_engine = summary_index.as_query_engine( llm=Settings.llm, response_mode="tree_summarize", )
response = query_engine.query(""" Entrega un resumen altamente específico y detallado de todos los elementos claves de este documento, indicando los puntos claves más importantes, y también generalidades suficientes para poder entregar el texto retornado a un agente con herramientas para saber redigirirlo a este documento si corresponde dada una query. Que no se te salte NINGÚN DETALLE IMPORTANTE, y abarcando todo el documento. IMPORTANTE: - Este resumen debe ser dirigido para el área INMOBILIARIA, y mencionar TODOS LOS ELEMENTOS. Si existen elementos de otros áreas, ignoralos, ya que para este contexto no sirve en absoluto. - Ocupa la cantidad máxima de tokens si es posible, tiene que ser un resumen largo de 8192 tokens que es lo máximo permitido. - Nunca menciones "entre otros". Incluye todos los elementos enumerados que se mencionen en el documento. Por ejemplo, si se habla de elementos acerca de la construcción de un edificio, menciona todos los elementos de construcción, pero no menciones elementos de diseño, ya que no es relevante para el área inmobiliaria. Otro ejemplo, menciona los estacionamientos si se menciona, ya que son elementos que son de interés para el área inmobiliaria. Así, para todos los documentos. """)