Skip to content

Instantly share code, notes, and snippets.

@idontcalculate
Created December 13, 2023 04:46
Show Gist options
  • Save idontcalculate/cd99e970de0637fd8de2b6dcbd15151d to your computer and use it in GitHub Desktop.
Save idontcalculate/cd99e970de0637fd8de2b6dcbd15151d to your computer and use it in GitHub Desktop.
# Create vector_index instance
vector_index = VectorStoreIndex(nodes, service_context=service_context)
# Build the summary index
summary_index = SummaryIndex(nodes, service_context=service_context)
# Now you can safely define query engines since vector_index is defined
vector_query_engine = vector_index.as_query_engine()
summary_query_engine = summary_index.as_query_engine()
# Define tools
query_engine_tools = [
QueryEngineTool(
query_engine=vector_query_engine,
metadata=ToolMetadata(
name="vector_tool",
description=(
"Useful for questions related to specific aspects of tesla's inventions, patents"
f" {patent_title} (e.g., the technology, science and inventions"
" electro-engineering, physics, electro-magnetics, or more)."
),
),
),
QueryEngineTool(
query_engine=summary_query_engine,
metadata=ToolMetadata(
name="summary_tool",
description=(
"Useful for any requests that require a holistic summary"
f" of EVERYTHING about {patent_title}. For questions about"
" more specific sections, please use the vector_tool."
),
),
),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment