Agents

Interact with Agents through Python classes.

Agents build upon the framework of Pipelines. They allow you to automate workflows by letting LLMs perform actions autonomously. We suggest reading the platform documentation on Agents to gain an appropriate context.

The SDK offers an interface atop the API endpoints through a class to easily work with Agents. Since some methods interface with the VectorShift platform, they require API keys. If the API keys have already been set as environment variables, they do not need to be supplied in those methods. The output of all methods invoking APIs is a dictionary representing the API JSON response.

Tool Names

As part of their functionality, Agents can interact from a set of tools meant to help with the workflows they are automating. Currently, a list of supported tools through the SDK is as follows.

  • 'calculator': An arithmetic calculator tool.

  • 'code_interpreter': Executes Python code and saves the result in a variable.

  • 'serpapi': Obtain search results with SerpApi.

  • 'wikipedia_loader': Data loader for Wikipedia documents.

  • 'url_loader': Data loader for URL contents.

  • 'youtube_loader': Data loader for transcriptions of audio of YouTube videos.

  • 'arxiv_loader': Load documents from ArXiv based on a query.

  • 'github_loader': Load documents from a GitHub repository.

  • 'notion_loader': Forthcoming. Load documents from a Notion database.

  • 'confluence_loader': Forthcoming. Load documents from Confluence.

  • 'image_generation': Generate an image from a text prompt.

  • 'speech_to_text': Convert speech to text.

  • 'csv_query': Query a CSV file.

  • 'vectordb_loader': Load documents into a blank, temporary vector database.

  • 'vectordb_query': Query a vector database.

  • 'vectorstore': Query an existing Vector Store.

  • 'save_file': Save a file to the VectorShift platform.

  • 'load_file': Forthcoming. Load an existing file from the VectorShift platform.

  • 'agent': Dispatch a task to a separate Agent.

  • 'pipeline': Run an existing pipeline.

vectorshift.agent.Agent.from_tool_names(
    name: str, 
    task: str, 
    tool_names: list[str], 
    llm: str = "gpt-3.5-turbo", 
    framework: str = "ReAct", 
    inputs: dict = None, 
    outputs: dict = None, 
    id : str = None
)

A static method that creates a new Agent object given tool names.

Arguments:

  • name: The name of the new Agent.

  • task: A string describing the task the Agent is meant to accomplish.

  • tool_names: A list of tools the Agent is equipped with. All tools aside from the calculator and code interpreter can be thought of as roughly analogous with their corresponding nodes. Each tool name should be a valid string for a tool as listed above.

  • llm: The overall large language model used to run the Agent. Should be a string corresponding to a valid LLM.

  • framework: The agentic framework to use with the LLM.

  • inputs: A map of specified inputs to the overall agent workflow. Maps input names to dictionaries of details. For instance, a valid key-value entry would be:

    "Query": {
        "name": "Query",
        "type": "Text"
    }
  • outputs: A map of specified outputs to the overall agent workflow, analogous to inputs.

  • api_key: The VectorShift API key.

vectorshift.agent.Agent.fetch(
    agent_name: str = None, 
    agent_id: str = None, 
    username: str = None, 
    org_name: str = None, 
    api_key: str = None, 
)

A static method that creates a Agent object representing an existing Agent on the VectorShift platform, given an ID or name.

Arguments:

  • agent_name: The name of the Vector Store being represented.

  • agent_id: The ID of the Vector Store being represented. At least one of agent_id and agent_name should be provided. If both are provided, agent_id is used to search for the Vector Store.

  • username: The username of the user owning the Agent.

  • org_name: The organization name of the user owning the Agent, if applicable.

  • api_key: The VectorShift API key.

save(
    update_existing: bool = False,
    api_key: str = None, 
)

A method to save or update an Agent object to the VectorShift platform.

Arguments:

  • update_existing: Whether or not to save the Agent as a new object or replace an existing one. If set to True, the Agent should have an ID, and the existing Agent with the ID will be replaced with the object's data. If set to False, the ID, if any, is ignored and a new Agent object is created with the object's data.

  • api_key: The VectorShift API key.

run(
    inputs: dict = {}, 
    api_key: str = None, 
)

A method to start the execution of an Agent via an API call. The Agent should already have an ID (have been saved on the VectorShift platform).

Arguments:

  • inputs: A map of input names to corresponding input values for the Agent. Should match up with the Agent's defined inputs.

  • api_key: The VectorShift API key.

Last updated