These are the core concepts that Superagent uses to create AI Assistants.
It contains practical examples as well as links to papers or sources.

### Agents

An agent is a program or system that is designed to perform a
specific task or set of tasks. In the context of Supergent, an agent is
a Large Language Model that has access to a suite of datasources and tools and can
decide which datasources/tools to use based on user input. One or many agents can power an AI Assistant.

Every Agent is equipped with a feature referred to as `memory`. This is a crucial component
that allows the Agent to retain and recall information from its interactions.
Memory can be thought of as the agent's short-term memory, storing recent inputs and outputs
for reference during its current task. This enables the agent to maintain context and provide
relevant responses or actions based on the information it has processed.

### Datasources

Superagent allows users to do question answering over datasources
by attaching a `Datasource` to an `Agent`. Datasources can be both structured (CSV, JSON etc.) or unstructured (PDF, TXT, MD) and depending on the data type Superagent handles these differently. 
In the case of unstructured data (like PDF, TXT, MD), Superagent employs two different strategies. 
The data is split and chunked into manageable pieces. These chunks are then ingested into a vectorstore, such as Pinecone, for efficient retrieval and usage. 
Alternatively, the chunked data can also be used for fine-tuning the language models specific to each Agent. 
This process enhances the Agent's ability to understand and respond to user queries more accurately and contextually.

Below is an overview of all available data sources:

| Datasource                       
| -------------------------- | 
| `PDF`                      | 
| `TXT`                      | 
| `CSV`                      | 
| `MARKDOWN`                 | 
| `PPTX`                     | 
| `DOCX`                     | 
| `XLSX`                     | 
| `YOUTUBE`                  | 
| `WEBPAGE`                  |
| `AIRTABLE`                 | 
| `SITEMAP`                  | 
| `URL`                      | 
| `GITHUB_REPOSITORY`        | 


### Tools (third-party services or APIs)

Superagent provides the capability to create and attach various tools to an `Agent`. These tools can range from ChatGPT Plugins to external APIs. 
The purpose of these tools is to enhance the functionality and versatility of the Agent. 
For instance, a ChatGPT Plugin could be used to improve the conversational abilities of the Agent, 
while an external API could provide the Agent with access to a specific dataset or service. 
The process of attaching a tool to an Agent is straightforward and flexible, allowing users to customize their Agents to best suit their needs.

Below is an overview of all available tools and their corresponding metadata:

| Tool                          | Options                               |
| ----------------------------- | --------------------------------------|
| `ALGOLIA`                     | `appId`, `apiKey`, `index`            |
| `BING_SEARCH`                 | `bingSearchUrl`, `bingSubscriptionKey`|
| `REPLICATE`                   | `model`, `apiKey`, `arguments`        |
| `WOLFRAM_ALPHA`               | `appId`                               |
| `ZAPIER_NLA`                  | `zapierNlaApiKey`, `openaiApiKey`     |
| `AGENT`                       | `agentId`, `apiKey`                   |
| `OPENAPI`                     | `openApiUrl`, `headers`               |
| `CHATGPT_PLUGIN`              | `chatgptPluginURL`                    |
| `METAPHOR`                    | `metaphorApiKey`                      |
| `PUBMED`                      | N/A                                   |
| `CODE_EXECUTOR`               | N/A                                   |
| `GPT_VISION`                  | `openaiApiKey`                        |
| `TTS_1`                       | `openaiApiKey`                        |
| `HAND_OFF`                    | N/A                                   |
| `FUNCTION`                    | `functionName`, `args`                |
| `HTTP`                        | `headers`                             |

### Workflows

Workflows in Superagent consist of a sequence of Agents that run in a specific order. 
Each Agent in the workflow has access to its own specific datasources and tools, allowing it to perform its designated task.
The output from one Agent is passed on to the next in the sequence, creating a chain of information processing and action. 
This allows for complex tasks to be broken down into manageable parts, each handled by a specialized Agent. 
The flexibility of workflows enables the creation of sophisticated systems capable of handling a wide range of tasks.

### LLMs

Language models are the core computational models that power the functionality of an Agent, the nuclear power plant of an Agent. 
They are trained on vast amounts of text data and learn to predict the likelihood of a sentence or to generate a piece of text that follows a given input. 
In the context of Superagent, language models are used to understand and generate human-like text based on the user's input and the context provided by the Agent's memory, datasources, and tools. 
These models are the driving force behind the Agent's ability to engage in meaningful and contextually relevant interactions with the user.

### Vector databases

Superagent ships with support for the following vector databases:

| Name            | .env                                                                                    | ID                                    |
| --------------- | ----------------------------------------------------------------------------------------|---------------------------------------|
| Pinecone        | `PINECONE_ENVIRONMENT`, `PINECONE_API_KEY`, `PINECONE_INDEX`                                                    | `pinecone`    |   
| Astra DB        | `ASTRA_DB_ID`, `ASTRA_DB_REGION, `ASTRA_DB_APPLICATION_TOKEN`, `ASTRA_COLLECTION_NAME`, `ASTRA_KEYSPACE_NAME`   | `astra`       |
| Weaviate        | `WEAVIATE_API_KEY`, `WEAVIATE_INDEX`, `WEAVIATE_URL`                                                            | `weaviate`    |
| Qdrant          | `QDRANT_API_KEY`, `QDRANT_HOST`, `QDRANT_INDEX`                                                                 | `qdrant`      |
| Supabase        | `SUPABASE_DB_URL`, `SUPABASE_TABLE_NAME`                                                                        | `supabase`    |

You can set the default vectorstore by setting the `VECTORSTORE` .env variable to one of th `ID` in the table above, ex: `VECTORSTORE=qdrant`. 

### Tracing and Observability

Superagent allows you to add observability to your Assistants by integration with either [Langfuse](https://www.langfuse.com) (Open Source) or [LangSmith](https://www.langchain.com/langsmith). 
We will be supporting multiple other Open Source alternatives as well.

| Name                          | .env                                                                                        |
| ----------------------------- | --------------------------------------------------------------------------------------------|
| Langfuse (Open source)        | `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, `LANGFUSE_HOST`                               |
| LangSmith                     | `LANGCHAIN_TRACING_V2`, `LANGCHAIN_ENDPOINT`, `LANGSMITH_PROJECT_ID`, `LANGCHAIN_API_KEY`   |
