A Python package for creating AI Assistants and AI Agents with Vectara
Project description
vectara-agentic
Overview
vectara-agentic is a Python library for developing powerful AI assistants using Vectara and Agentic-RAG. It leverages the LlamaIndex Agent framework, customized for use with Vectara.
Key Features
- Supports
ReActandOpenAIAgentagent types. - Includes pre-built tools for various domains (e.g., finance, legal).
- Enables easy creation of custom AI assistants and agents.
Important Links
- Documentation: https://vectara.github.io/vectara-agentic-docs/
Prerequisites
- Vectara account
- A Vectara corpus with an API key
- Python 3.10 or higher
- OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, or GROQ)
Installation
pip install vectara-agentic
Quick Start
- Create a Vectara RAG tool
import os
from vectara_agentic import VectaraToolFactory
vec_factory = VectaraToolFactory(
vectara_api_key=os.environ['VECTARA_API_KEY'],
vectara_customer_id=os.environ['VECTARA_CUSTOMER_ID'],
vectara_corpus_id=os.environ['VECTARA_CORPUS_ID']
)
query_financial_reports = vec_factory.create_rag_tool(
tool_name="query_financial_reports",
tool_description="Query financial reports for a company and year",
tool_args_schema=QueryFinancialReportsArgs,
tool_filter_template="doc.year = {year} and doc.ticker = '{ticker}'"
)
- Create other tools (optional)
In addition to RAG tools, you can generate a lot of other types of tools the agent can use. These could be mathematical tools, tools that call other APIs to get more information, or any other type of tool.
See Tools for more information.
- Create your agent
agent = Agent(
tools = [query_financial_reports],
topic = topic_of_expertise,
custom_instructions = financial_bot_instructions,
)
toolsis the list of tools you want to provide to the agent. In this example it's just a single tool.topicis a string that defines the expertise you want the agent to specialize in.custom_instructionsis an optional string that defines special instructions to the agent.
For example, for a financial agent we might use:
topic_of_expertise = "10-K financial reports",
financial_bot_instructions = """
- You are a helpful financial assistant in conversation with a user. Use your financial expertise when crafting a query to the tool, to ensure you get the most accurate information.
- You can answer questions, provide insights, or summarize any information from financial reports.
- A user may refer to a company's ticker instead of its full name - consider those the same when a user is asking about a company.
- When calculating a financial metric, make sure you have all the information from tools to complete the calculation.
- In many cases you may need to query tools on each sub-metric separately before computing the final metric.
- When using a tool to obtain financial data, consider the fact that information for a certain year may be reported in the the following year's report.
- Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.
"""
Configuration
Configure vectara-agentic using environment variables:
VECTARA_AGENTIC_AGENT_TYPE: valid values areREACTorOPENAI(default:OPENAI)VECTARA_AGENTIC_MAIN_LLM_PROVIDER: valid values areOPENAI,ANTHROPIC,TOGETHER,GROQ, orFIREWORKS(default:OPENAI)VECTARA_AGENTIC_MAIN_MODEL_NAME: agent model name (default depends on provider)VECTARA_AGENTIC_TOOL_LLM_PROVIDER: tool LLM provider (default:OPENAI)VECTARA_AGENTIC_TOOL_MODEL_NAME: tool model name (default depends on provider)
Agent Tools
vectara-agentic provides a few tools out of the box:
- Standard tools:
summarize_text: a tool to summarize a long text into a shorter summary (uses LLM)rephrase_text: a tool to rephrase a given text, given a set of rephrase instructions (uses LLM)
- Legal tools: a set of tools for the legal vertical, such as:
summarize_legal_text: summarize legal text with a certain point of viewcritique_as_judge: critique a legal text as a judge, providing their perspective
- Financial tools: based on tools from Yahoo Finance:
- tools to understand the financials of a public company like:
balance_sheet,income_statement,cash_flow stock_news: provides news about a companystock_analyst_recommendations: provides stock analyst recommendations for a company.
- database_tools: providing a few tools to inspect and query a database
list_tables: list all tables in the databasedescribe_tables: describe the schema of tables in the databaseload_data: returns data based on a SQL query
More tools coming soon.
You can create your own tool directly from a Python function using the create_tool() method of the ToolsFactor class:
def mult_func(x, y):
return x*y
mult_tool = ToolsFactory().create_tool(mult_func)
Examples
Check out our example AI assistants:
Contributing
We welcome contributions! Please see our contributing guide for more information.
License
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
Contact
- Website: vectara.com
- Twitter: @vectara
- GitHub: @vectara
- LinkedIn: @vectara
- Discord: Join our community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vectara_agentic-0.1.7.tar.gz.
File metadata
- Download URL: vectara_agentic-0.1.7.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57b22755bda700e1573f915335917bd43d823ecc263707028ba997848b492f6c
|
|
| MD5 |
95bc099b282ce0eef7e8dbd0926e8dcc
|
|
| BLAKE2b-256 |
c5317e0e9c17e8f3e1cb6e1518d2929d68950fd87db0ab24d949edce9fa1fcc5
|
File details
Details for the file vectara_agentic-0.1.7-py3-none-any.whl.
File metadata
- Download URL: vectara_agentic-0.1.7-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a17c7a7a4187ffa7945a4bd519f594dbdf375248f2c19cc98f36a05dd09d395
|
|
| MD5 |
c4c0ea6185bf482dce3610da15d84288
|
|
| BLAKE2b-256 |
6d242e261d01c5873628f17ba8cc22aaebed2f8a62c633a969c4b000796560b3
|