{"id":22843475,"url":"https://github.com/vectara/py-vectara-agentic","last_synced_at":"2025-04-07T10:19:26.060Z","repository":{"id":254203129,"uuid":"841588153","full_name":"vectara/py-vectara-agentic","owner":"vectara","description":"A python library for creating AI assistants with Vectara, using Agentic RAG","archived":false,"fork":false,"pushed_at":"2024-10-21T22:34:13.000Z","size":655,"stargazers_count":72,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-23T01:13:10.292Z","etag":null,"topics":["agentic-rag","agents","framework","rag","vectara"],"latest_commit_sha":null,"homepage":"https://vectara.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vectara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-12T17:51:14.000Z","updated_at":"2024-10-21T22:34:17.000Z","dependencies_parsed_at":"2024-10-25T20:56:16.753Z","dependency_job_id":null,"html_url":"https://github.com/vectara/py-vectara-agentic","commit_stats":null,"previous_names":["vectara/py-vectara-agentic"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectara%2Fpy-vectara-agentic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectara%2Fpy-vectara-agentic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectara%2Fpy-vectara-agentic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vectara%2Fpy-vectara-agentic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vectara","download_url":"https://codeload.github.com/vectara/py-vectara-agentic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247631834,"owners_count":20970069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agentic-rag","agents","framework","rag","vectara"],"created_at":"2024-12-13T02:14:59.245Z","updated_at":"2025-04-07T10:19:26.035Z","avatar_url":"https://github.com/vectara.png","language":"Python","funding_links":[],"categories":["Frameworks","Building"],"sub_categories":["Frameworks"],"readme":"# \u003cimg src=\"https://raw.githubusercontent.com/vectara/py-vectara-agentic/main/.github/assets/Vectara-logo.png\" alt=\"Vectara Logo\" width=\"30\" height=\"30\" style=\"vertical-align: middle;\"\u003e vectara-agentic\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://vectara.github.io/py-vectara-agentic\"\u003eDocumentation\u003c/a\u003e ·\n  \u003ca href=\"#examples\"\u003eExamples\u003c/a\u003e ·\n  \u003ca href=\"https://discord.gg/S9dwgCNEFs\"\u003eDiscord\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\" alt=\"License\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/vectara/py-vectara-agentic/graphs/commit-activity\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" alt=\"Maintained\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://twitter.com/vectara\"\u003e\n    \u003cimg src=\"https://img.shields.io/twitter/follow/vectara.svg?style=social\u0026label=Follow%20%40Vectara\" alt=\"Twitter\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## ✨ Overview\n\n`vectara-agentic` is a Python library for developing powerful AI assistants and agents using Vectara and Agentic-RAG. It leverages the LlamaIndex Agent framework and provides helper functions to quickly create tools that connect to Vectara corpora.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/vectara/py-vectara-agentic/main/.github/assets/diagram1.png\" alt=\"Agentic RAG diagram\" width=\"100%\" style=\"vertical-align: middle;\"\u003e\n\u003c/p\u003e\n\n### Key Features\n\n- **Rapid Tool Creation:**  \n  Build Vectara RAG tools or search tools with a single line of code.\n- **Agent Flexibility:**  \n  Supports multiple agent types including `ReAct`, `OpenAIAgent`, `LATS`, and `LLMCompiler`.\n- **Pre-Built Domain Tools:**  \n  Tools tailored for finance, legal, and other verticals.\n- **Multi-LLM Integration:**  \n  Seamless integration with OpenAI, Anthropic, Gemini, GROQ, Together.AI, Cohere, Bedrock, and Fireworks.\n- **Observability:**  \n  Built-in support with Arize Phoenix for monitoring and feedback.\n- **Workflow Support:**  \n  Extend your agent’s capabilities by defining custom workflows using the `run()` method.\n\n### 📚 Example AI Assistants\n\nCheck out our example AI assistants:\n\n- [Financial Assistant](https://huggingface.co/spaces/vectara/finance-chat)\n- [Justice Harvard Teaching Assistant](https://huggingface.co/spaces/vectara/Justice-Harvard)\n- [Legal Assistant](https://huggingface.co/spaces/vectara/legal-agent)\n- [EV Assistant](https://huggingface.co/spaces/vectara/ev-assistant)\n\n###  Prerequisites\n\n- [Vectara account](https://console.vectara.com/signup/?utm_source=github\u0026utm_medium=code\u0026utm_term=DevRel\u0026utm_content=vectara-agentic\u0026utm_campaign=github-code-DevRel-vectara-agentic)\n- A Vectara corpus with an [API key](https://docs.vectara.com/docs/api-keys)\n- [Python 3.10 or higher](https://www.python.org/downloads/)\n- OpenAI API key (or API keys for Anthropic, TOGETHER.AI, Fireworks AI, Bedrock, Cohere, GEMINI or GROQ, if you choose to use them)\n\n###  Installation\n\n```bash\npip install vectara-agentic\n```\n\n## 🚀 Quick Start\n\n### 1. Initialize the Vectara tool factory\n\n```python\nimport os\nfrom vectara_agentic.tools import VectaraToolFactory\n\nvec_factory = VectaraToolFactory(\n    vectara_api_key=os.environ['VECTARA_API_KEY'],\n    vectara_customer_id=os.environ['VECTARA_CUSTOMER_ID'],\n    vectara_corpus_key=os.environ['VECTARA_CORPUS_KEY']\n)\n```\n\n### 2. Create a Vectara RAG Tool\n\nA RAG tool calls the full Vectara RAG pipeline to provide summarized responses to queries grounded in data.\n\n```python\nfrom pydantic import BaseModel, Field\n\nyears = list(range(2020, 2024))\ntickers = {\n    \"AAPL\": \"Apple Computer\",\n    \"GOOG\": \"Google\",\n    \"AMZN\": \"Amazon\",\n    \"SNOW\": \"Snowflake\",\n}\n\nclass QueryFinancialReportsArgs(BaseModel):\n    query: str = Field(..., description=\"The user query.\")\n    year: int | str = Field(..., description=f\"The year this query relates to. An integer between {min(years)} and {max(years)} or a string specifying a condition on the year (example: '\u003e2020').\")\n    ticker: str = Field(..., description=f\"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.\")\n\nquery_financial_reports_tool = vec_factory.create_rag_tool(\n    tool_name=\"query_financial_reports\",\n    tool_description=\"Query financial reports for a company and year\",\n    tool_args_schema=QueryFinancialReportsArgs,\n    lambda_val=0.005,\n    summary_num_results=7, \n    # Additional arguments\n)\n```\n\nSee the [docs](https://vectara.github.io/vectara-agentic-docs/) for additional arguments to customize your Vectara RAG tool.\n\n### 3. Create other tools (optional)\n\nIn addition to RAG tools, you can generate a lot of other types of tools the agent can use. These could be mathematical tools, tools \nthat call other APIs to get more information, or any other type of tool.\n\nSee [Agent Tools](#agent-tools) for more information.\n\n### 4. Create your agent\n\n```python\nfrom vectara_agentic import Agent\n\nagent = Agent(\n    tools=[query_financial_reports_tool],\n    topic=\"10-K financial reports\",\n    custom_instructions=\"\"\"\n        - 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.\n        - You can answer questions, provide insights, or summarize any information from financial reports.\n        - 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.\n        - When calculating a financial metric, make sure you have all the information from tools to complete the calculation.\n        - In many cases you may need to query tools on each sub-metric separately before computing the final metric.\n        - When using a tool to obtain financial data, consider the fact that information for a certain year may be reported in the following year's report.\n        - Report financial data in a consistent manner. For example if you report revenue in thousands, always report revenue in thousands.\n    \"\"\"\n)\n```\n\nSee the [docs](https://vectara.github.io/vectara-agentic-docs/) for additional arguments, including `agent_progress_callback` and `query_logging_callback`.\n\n### 5. Run a chat interaction\n\n```python\nres = agent.chat(\"What was the revenue for Apple in 2021?\")\nprint(res.response)\n```\n\nNote that:\n1. `vectara-agentic` also supports `achat()` and two streaming variants `stream_chat()` and `astream_chat()`.\n2. The response types from `chat()` and `achat()` are of type `AgentResponse`. If you just need the actual string\n   response it's available as the `response` variable, or just use `str()`. For advanced use-cases you can look \n   at other `AgentResponse` variables [such as `sources`](https://github.com/run-llama/llama_index/blob/659f9faaafbecebb6e6c65f42143c0bf19274a37/llama-index-core/llama_index/core/chat_engine/types.py#L53).\n\n## Advanced Usage: Workflows\n\nIn addition to standard chat interactions, `vectara-agentic` supports custom workflows via the `run()` method. \nWorkflows allow you to structure multi-step interactions where inputs and outputs are validated using Pydantic models.\nTo learn more about workflows read [the documentation](https://docs.llamaindex.ai/en/stable/understanding/workflows/basic_flow/)\n\n### Defining a Custom Workflow\n\nCreate a workflow by subclassing `llama_index.core.workflow.Workflow` and defining the input/output models:\n\n```python\nfrom pydantic import BaseModel\nfrom llama_index.core.workflow import (\n    StartEvent,StopEvent, Workflow, step,\n)\n\nclass MyWorkflow(Workflow):\n    class InputsModel(BaseModel):\n        query: str\n\n    class OutputsModel(BaseModel):\n        answer: str\n\n    @step\n    async def my_step(self, ev: StartEvent) -\u003e StopEvent:\n        # do something here\n        return StopEvent(result=\"Hello, world!\")\n```\n\nWhen the `run()` method in vectara-agentic is invoked, it calls the workflow with the following variables in the StartEvent:\n* `agent`: the agent object used to call `run()` (self)\n* `tools`: the tools provided to the agent. Those can be used as needed in the flow.\n* `llm`: a pointer to a LlamaIndex llm, so it can be used in the workflow. For example, one of the steps may call `llm.acomplete(prompt)`\n* `verbose`: controls whether extra debug information is displayed\n* `inputs`: this is the actual inputs to the workflow provided by the call to `run()` and must be of type `InputsModel`\n\n### Using the Workflow with Your Agent\n\nWhen initializing your agent, pass the workflow class using the `workflow_cls` parameter:\n\n```python\nagent = Agent(\n    tools=[query_financial_reports_tool],\n    topic=\"10-K financial reports\",\n    custom_instructions=\"You are a helpful financial assistant.\",\n    workflow_cls=MyWorkflow,       # Provide your custom workflow here\n    workflow_timeout=120           # Optional: Set a timeout (default is 120 seconds)\n)\n```\n\n### Running the Workflow\n\nPrepare the inputs using your workflow’s `InputsModel` and execute the workflow using `run()`:\n\n```python\n# Create an instance of the workflow's input model\ninputs = MyWorkflow.InputsModel(query=\"What is Vectara?\", extra_param=42)\n\n# Run the workflow (ensure you're in an async context or use asyncio.run)\nworkflow_result = asyncio.run(agent.run(inputs))\n\n# Access the output from the workflow's OutputsModel\nprint(workflow_result.answer)\n```\n\n### Using SubQuestionQueryWorkflow\n\nvectara-agentic already includes one useful workflow you can use right away (it is also useful as an advanced example)\nThis workflow is called `SubQuestionQueryWorkflow` and it works by breaking a complex query into sub-queries and then\nexecuting each sub-query with the agent until it reaches a good response.\n\n## 🧰 Vectara tools\n\n`vectara-agentic` provides two helper functions to connect with Vectara RAG\n* `create_rag_tool()` to create an agent tool that connects with a Vectara corpus for querying. \n* `create_search_tool()` to create a tool to search a Vectara corpus and return a list of matching documents.\n\nSee the documentation for the full list of arguments for `create_rag_tool()` and `create_search_tool()`, \nto understand how to configure Vectara query performed by those tools.\n\n### Creating a Vectara RAG tool\n\nA Vectara RAG tool is often the main workhorse for any Agentic RAG application, and enables the agent to query \none or more Vectara RAG corpora. \n\nThe tool generated always includes the `query` argument, followed by 1 or more optional arguments used for \nmetadata filtering, defined by `tool_args_schema`.\n\nFor example, in the quickstart example the schema is:\n\n```\nclass QueryFinancialReportsArgs(BaseModel):\n    query: str = Field(..., description=\"The user query.\")\n    year: int | str = Field(..., description=f\"The year this query relates to. An integer between {min(years)} and {max(years)} or a string specifying a condition on the year (example: '\u003e2020').\")\n    ticker: str = Field(..., description=f\"The company ticker. Must be a valid ticket symbol from the list {tickers.keys()}.\")\n```\n\nThe `query` is required and is always the query string.\nThe other arguments are optional and will be interpreted as Vectara metadata filters.\n\nFor example, in the example above, the agent may call the `query_financial_reports_tool` tool with \nquery='what is the revenue?', year=2022 and ticker='AAPL'. Subsequently the RAG tool will issue\na Vectara RAG query with the same query, but with metadata filtering (doc.year=2022 and doc.ticker='AAPL').\n\nThere are also additional cool features supported here:\n* An argument can be a condition, for example year='\u003e2022' translates to the correct metadata \n  filtering condition doc.year\u003e2022\n* if `fixed_filter` is defined in the RAG tool, it provides a constant metadata filtering that is always applied.\n  For example, if fixed_filter=`doc.filing_type='10K'` then a query with query='what is the reveue', year=2022\n  and ticker='AAPL' would translate into query='what is the revenue' with metadata filtering condition of\n  \"doc.year=2022 AND doc.ticker='AAPL' and doc.filing_type='10K'\"\n\nNote that `tool_args_type` is an optional dictionary that indicates the level at which metadata filtering\nis applied for each argument (`doc` or `part`)\n\n### Creating a Vectara search tool\n\nThe Vectara search tool allows the agent to list documents that match a query.\nThis can be helpful to the agent to answer queries like \"how many documents discuss the iPhone?\" or other\nsimilar queries that require a response in terms of a list of matching documents.\n\n## 🛠️ Agent Tools at a Glance\n\n`vectara-agentic` provides a few tools out of the box (see ToolsCatalog for details):\n\n1. **Standard tools**: \n- `summarize_text`: a tool to summarize a long text into a shorter summary (uses LLM)\n- `rephrase_text`: a tool to rephrase a given text, given a set of rephrase instructions (uses LLM)\nThese tools use an LLM and so would use the `Tools` LLM specified in your `AgentConfig`.\nTo instantiate them:\n\n```python\nfrom vectara_agentic.tools_catalog import ToolsCatalog\nsummarize_text = ToolsCatalog(agent_config).summarize_text\n```\n\nThis ensures the summarize_text tool is configured with the proper LLM provider and model as \nspecified in the Agent configuration.\n\n2. **Legal tools**: a set of tools for the legal vertical, such as:\n- `summarize_legal_text`: summarize legal text with a certain point of view\n- `critique_as_judge`: critique a legal text as a judge, providing their perspective\n\n3. **Financial tools**: based on tools from Yahoo! Finance:\n- tools to understand the financials of a public company like: `balance_sheet`, `income_statement`, `cash_flow`\n- `stock_news`: provides news about a company\n- `stock_analyst_recommendations`: provides stock analyst recommendations for a company.\n\n4. **Database tools**: providing tools to inspect and query a database\n- `list_tables`: list all tables in the database\n- `describe_tables`: describe the schema of tables in the database\n- `load_data`: returns data based on a SQL query\n- `load_sample_data`: returns the first 25 rows of a table\n- `load_unique_values`: returns the top unique values for a given column\n\nIn addition, we include various other tools from LlamaIndex ToolSpecs:\n* Tavily search and EXA.AI\n* arxiv\n* neo4j \u0026 Kuzu for Graph DB integration\n* Google tools (including gmail, calendar, and search)\n* Slack\n\nNote that some of these tools may require API keys as environment variables\n\nYou can create your own tool directly from a Python function using the `create_tool()` method of the `ToolsFactory` class:\n\n```python\ndef mult_func(x, y):\n    return x * y\n\nmult_tool = ToolsFactory().create_tool(mult_func)\n```\n\nNote: When you define your own Python functions as tools, implement them at the top module level,\nand not as nested functions. Nested functions are not supported if you use serialization \n(dumps/loads or from_dict/to_dict).\n\n## 🛠️ Configuration\n\n## Configuring Vectara-agentic\n\nThe main way to control the behavior of `vectara-agentic` is by passing an `AgentConfig` object to your `Agent` when creating it.\nFor example:\n\n```python\nagent_config = AgentConfig(\n    agent_type = AgentType.REACT,\n    main_llm_provider = ModelProvider.ANTHROPIC,\n    main_llm_model_name = 'claude-3-5-sonnet-20241022',\n    tool_llm_provider = ModelProvider.TOGETHER,\n    tool_llm_model_name = 'meta-llama/Llama-3.3-70B-Instruct-Turbo'\n)\n\nagent = Agent(\n    tools=[query_financial_reports_tool],\n    topic=\"10-K financial reports\",\n    custom_instructions=\"You are a helpful financial assistant in conversation with a user.\",\n    agent_config=agent_config\n)\n```\n\nThe `AgentConfig` object may include the following items:\n- `agent_type`: the agent type. Valid values are `REACT`, `LLMCOMPILER`, `LATS` or `OPENAI` (default: `OPENAI`).\n- `main_llm_provider` and `tool_llm_provider`: the LLM provider for main agent and for the tools. Valid values are `OPENAI`, `ANTHROPIC`, `TOGETHER`, `GROQ`, `COHERE`, `BEDROCK`, `GEMINI` or `FIREWORKS` (default: `OPENAI`).\n- `main_llm_model_name` and `tool_llm_model_name`: agent model name for agent and tools (default depends on provider).\n- `observer`: the observer type; should be `ARIZE_PHOENIX` or if undefined no observation framework will be used.\n- `endpoint_api_key`: a secret key if using the API endpoint option (defaults to `dev-api-key`)\n- `max_reasoning_steps`: the maximum number of reasoning steps (iterations for React and function calls for OpenAI agent, respectively). Defaults to 50.\n\nIf any of these are not provided, `AgentConfig` first tries to read the values from the OS environment.\n\n## Configuring Vectara tools: rag_tool, or search_tool\n\nWhen creating a `VectaraToolFactory`, you can pass in a `vectara_api_key`, and `vectara_corpus_key` to the factory. \n\nIf not passed in, it will be taken from the environment variables (`VECTARA_API_KEY` and `VECTARA_CORPUS_KEY`). Note that `VECTARA_CORPUS_KEY` can be a single KEY or a comma-separated list of KEYs (if you want to query multiple corpora).\n\nThese values will be used as credentials when creating Vectara tools - in `create_rag_tool()` and `create_search_tool()`.\n\n## Setting up a privately hosted LLM\n\nIf you want to setup vectara-agentic to use your own self-hosted LLM endpoint, follow the example below\n\n```python\n        config = AgentConfig(\n            agent_type=AgentType.REACT,\n            main_llm_provider=ModelProvider.PRIVATE,\n            main_llm_model_name=\"meta-llama/Meta-Llama-3.1-8B-Instruct\",\n            private_llm_api_base=\"http://vllm-server.company.com/v1\",\n            private_llm_api_key=\"TEST_API_KEY\",\n        )\n        agent = Agent(agent_config=config, tools=tools, topic=topic,\n                      custom_instructions=custom_instructions)\n```\n\nIn this case we specify the Main LLM provider to be privately hosted with Llama-3.1-8B as the model.\n- The `ModelProvider.PRIVATE` specifies a privately hosted LLM.\n- The `private_llm_api_base` specifies the api endpoint to use, and the `private_llm_api_key`\n  specifies the private API key requires to use this service.\n\n## ℹ️ Additional Information\n\n### About Custom Instructions for your Agent\n\nThe custom instructions you provide to the agent guide its behavior.\nHere are some guidelines when creating your instructions:\n- Write precise and clear instructions, without overcomplicating.\n- Consider edge cases and unusual or atypical scenarios.\n- Be cautious to not over-specify behavior based on your primary use-case, as it may limit the agent's ability to behave properly in others.\n\n###  Diagnostics\n\nThe `Agent` class defines a few helpful methods to help you understand the internals of your application. \n* The `report()` method prints out the agent object’s type, the tools, and the LLMs used for the main agent and tool calling.\n* The `token_counts()` method tells you how many tokens you have used in the current session for both the main agent and tool calling LLMs. This can be helpful if you want to track spend by token.\n\n###  Serialization\n\nThe `Agent` class supports serialization. Use the `dumps()` to serialize and `loads()` to read back from a serialized stream.\n\nNote: due to cloudpickle limitations, if a tool contains Python `weakref` objects, serialization won't work and an exception will be raised.\n\n###  Observability\n\nvectara-agentic supports observability via the existing integration of LlamaIndex and Arize Phoenix.\nFirst, set `VECTARA_AGENTIC_OBSERVER_TYPE` to `ARIZE_PHOENIX` in `AgentConfig` (or env variable).\n\nThen you can use Arize Phoenix in three ways: \n1. **Locally**. \n   1. If you have a local phoenix server that you've run using e.g. `python -m phoenix.server.main serve`, vectara-agentic will send all traces to it.\n   2. If not, vectara-agentic will run a local instance during the agent's lifecycle, and will close it when finished.\n   3. In both cases, traces will be sent to the local instance, and you can see the dashboard at `http://localhost:6006`\n2. **Hosted Instance**. In this case the traces are sent to the Phoenix instances hosted on Arize.\n   1. Go to `https://app.phoenix.arize.com`, setup an account if you don't have one.\n   2. create an API key and put it in the `PHOENIX_API_KEY` environment variable - this indicates you want to use the hosted version.\n   3. To view the traces go to `https://app.phoenix.arize.com`.\n\nNow when you run your agent, all call traces are sent to Phoenix and recorded. \nIn addition, vectara-agentic also records `FCS` (factual consistency score, aka HHEM) values into Arize for every Vectara RAG call. You can see those results in the `Feedback` column of the arize UI.\n\n## 🌐 API Endpoint\n\n`vectara-agentic` can be easily hosted locally or on a remote machine behind an API endpoint, by following theses steps:\n\n### Step 1: Setup your API key\nEnsure that you have your API key set up as an environment variable:\n\n```\nexport VECTARA_AGENTIC_API_KEY=\u003cYOUR-ENDPOINT-API-KEY\u003e\n```\n\nif you don't specify an Endpoint API key it uses the default \"dev-api-key\".\n\n### Step 2: Start the API Server\nInitialize the agent and start the FastAPI server by following this example:\n\n\n```\nfrom vectara_agentic.agent import Agent\nfrom vectara_agentic.agent_endpoint import start_app\nagent = Agent(...)            # Initialize your agent with appropriate parameters\nstart_app(agent)\n```\n\nYou can customize the host and port by passing them as arguments to `start_app()`:\n* Default: host=\"0.0.0.0\" and port=8000.\nFor example:\n```\nstart_app(agent, host=\"0.0.0.0\", port=8000)\n```\n\n### Step 3: Access the API Endpoint\nOnce the server is running, you can interact with it using curl or any HTTP client. For example:\n\n```\ncurl -G \"http://\u003cremote-server-ip\u003e:8000/chat\" \\\n--data-urlencode \"message=What is Vectara?\" \\\n-H \"X-API-Key: \u003cYOUR-ENDPOINT-API-KEY\u003e\"\n```\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see our [contributing guide](https://github.com/vectara/py-vectara-agentic/blob/main/CONTRIBUTING.md) for more information.\n\n## 📝 License\n\nThis project is licensed under the Apache 2.0 License. See the [LICENSE](https://github.com/vectara/py-vectara-agentic/blob/master/LICENSE) file for details.\n\n## 📞 Contact\n\n- Website: [vectara.com](https://vectara.com)\n- Twitter: [@vectara](https://twitter.com/vectara)\n- GitHub: [@vectara](https://github.com/vectara)\n- LinkedIn: [@vectara](https://www.linkedin.com/company/vectara/)\n- Discord: [Join our community](https://discord.gg/GFb8gMz6UH)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectara%2Fpy-vectara-agentic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvectara%2Fpy-vectara-agentic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvectara%2Fpy-vectara-agentic/lists"}