GetCodeTemplateFromVectorDB
- class hana_ai.tools.code_template_tools.GetCodeTemplateFromVectorDB(*, name: str = 'CodeTemplatesFromVectorDB', description: str = 'useful for when you need to create hana-ml code templates.', args_schema: Type[BaseModel] = None, return_direct: bool = False, verbose: bool = False, callbacks: list[BaseCallbackHandler] | BaseCallbackManager | None = None, tags: list[str] | None = None, metadata: dict[str, Any] | None = None, handle_tool_error: bool | str | Callable[[ToolException], str] | None = False, handle_validation_error: bool | str | Callable[[ValidationError | ValidationError], str] | None = False, response_format: Literal['content', 'content_and_artifact'] = 'content', extras: dict[str, Any] | None = None, vectordb: HANAMLinVectorEngine = None, is_transform: bool = False)
Get code template from vector database.
Examples
Assume cc is a connection to a SAP HANA instance:
>>> from hana_ai.tools.code_template_tools import GetCodeTemplateFromVectorDB >>> from hana_ai.vectorstore.hana_vector_engine import HANAMLinVectorEngine >>> from hana_ai.agents.hana_dataframe_agent import create_hana_dataframe_agent
>>> hana_vec = HANAMLinVectorEngine(connection_context=cc, table_name="hana_vec_hana_ml_python_knowledge") >>> hana_vec.create_knowledge() >>> code_tool = GetCodeTemplateFromVectorDB() >>> code_tool.set_vectordb(vectordb=hana_vec) >>> agent = create_hana_dataframe_agent(llm=llm, tools=[code_tool], df=hana_df, verbose=True, handle_parsing_errors=True) >>> agent.invoke("Create a dataset report for this dataframe.")
- name: str
The unique name of the tool that clearly communicates its purpose.
- description: str
Used to tell the model how/when/why to use the tool.
You can provide few-shot examples as a part of the description.
- set_vectordb(vectordb)
Set the vector database.
- Parameters:
- vectordbHANAMLinVectorEngine
Vector database.
- set_transform(is_transform: bool)
Return a copy of the tool with the is_transform flag set.
- Parameters:
- is_transformbool
Whether to set the tool to transform mode.