Enhanced Component Testing & General Test Fixes (#1585)
This pull request introduces comprehensive new tests for our components, significantly improving our project's test coverage. In addition to the new component tests, this PR addresses and resolves several issues that were affecting our general test suite, enhancing its reliability and efficiency.
This commit is contained in:
commit
452eb224d7
57 changed files with 2472 additions and 640 deletions
|
|
@ -123,7 +123,12 @@ Used to load [OpenAI’s](https://openai.com/) embedding models.
|
|||
Wrapper around [Google Vertex AI](https://cloud.google.com/vertex-ai) [Embeddings API](https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings).
|
||||
|
||||
<Admonition type="info">
|
||||
Vertex AI is a cloud computing platform offered by Google Cloud Platform (GCP). It provides access, management, and development of applications and services through global data centers. To use Vertex AI PaLM, you need to have the [google-cloud-aiplatform](https://pypi.org/project/google-cloud-aiplatform/) Python package installed and credentials configured for your environment.
|
||||
Vertex AI is a cloud computing platform offered by Google Cloud Platform
|
||||
(GCP). It provides access, management, and development of applications and
|
||||
services through global data centers. To use Vertex AI PaLM, you need to have
|
||||
the
|
||||
[google-cloud-aiplatform](https://pypi.org/project/google-cloud-aiplatform/)
|
||||
Python package installed and credentials configured for your environment.
|
||||
</Admonition>
|
||||
|
||||
- **credentials:** The default custom credentials (google.auth.credentials.Credentials) to use.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import Admonition from '@theme/Admonition';
|
||||
import Admonition from "@theme/Admonition";
|
||||
|
||||
# Models
|
||||
|
||||
|
|
@ -13,16 +13,17 @@ This component facilitates the generation of text using the LLM (Large Language
|
|||
- **System Message (Optional):** A system message to pass to the model.
|
||||
|
||||
- **Model ID (Optional):** Specifies the model ID to be used for text generation. Defaults to _`"anthropic.claude-instant-v1"`_. Available options include:
|
||||
- _`"ai21.j2-grande-instruct"`_
|
||||
- _`"ai21.j2-jumbo-instruct"`_
|
||||
- _`"ai21.j2-mid"`_
|
||||
- _`"ai21.j2-mid-v1"`_
|
||||
- _`"ai21.j2-ultra"`_
|
||||
- _`"ai21.j2-ultra-v1"`_
|
||||
- _`"anthropic.claude-instant-v1"`_
|
||||
- _`"anthropic.claude-v1"`_
|
||||
- _`"anthropic.claude-v2"`_
|
||||
- _`"cohere.command-text-v14"`_
|
||||
|
||||
- _`"ai21.j2-grande-instruct"`_
|
||||
- _`"ai21.j2-jumbo-instruct"`_
|
||||
- _`"ai21.j2-mid"`_
|
||||
- _`"ai21.j2-mid-v1"`_
|
||||
- _`"ai21.j2-ultra"`_
|
||||
- _`"ai21.j2-ultra-v1"`_
|
||||
- _`"anthropic.claude-instant-v1"`_
|
||||
- _`"anthropic.claude-v1"`_
|
||||
- _`"anthropic.claude-v2"`_
|
||||
- _`"cohere.command-text-v14"`_
|
||||
|
||||
- **Credentials Profile Name (Optional):** Specifies the name of the credentials profile.
|
||||
|
||||
|
|
@ -39,12 +40,12 @@ This component facilitates the generation of text using the LLM (Large Language
|
|||
- **Stream (Optional):** Specifies whether to stream the response from the model. Defaults to _`False`_.
|
||||
|
||||
<Admonition type="note" title="Note">
|
||||
<p>
|
||||
Ensure that necessary credentials are provided to connect to the Amazon Bedrock API. If connection fails, a ValueError will be raised.
|
||||
</p>
|
||||
<p>
|
||||
Ensure that necessary credentials are provided to connect to the Amazon
|
||||
Bedrock API. If connection fails, a ValueError will be raised.
|
||||
</p>
|
||||
</Admonition>
|
||||
|
||||
|
||||
---
|
||||
|
||||
### Anthropic
|
||||
|
|
@ -54,10 +55,11 @@ This component allows the generation of text using Anthropic Chat&Completion lar
|
|||
**Params**
|
||||
|
||||
- **Model Name:** Specifies the name of the Anthropic model to be used for text generation. Available options include:
|
||||
- _`"claude-2.1"`_
|
||||
- _`"claude-2.0"`_
|
||||
- _`"claude-instant-1.2"`_
|
||||
- _`"claude-instant-1"`_
|
||||
|
||||
- _`"claude-2.1"`_
|
||||
- _`"claude-2.0"`_
|
||||
- _`"claude-instant-1.2"`_
|
||||
- _`"claude-instant-1"`_
|
||||
|
||||
- **Anthropic API Key:** Your Anthropic API key.
|
||||
|
||||
|
|
@ -84,25 +86,27 @@ This component allows the generation of text using the LLM (Large Language Model
|
|||
**Params**
|
||||
|
||||
- **Model Name:** Specifies the name of the Azure OpenAI model to be used for text generation. Available options include:
|
||||
- _`"gpt-35-turbo"`_
|
||||
- _`"gpt-35-turbo-16k"`_
|
||||
- _`"gpt-35-turbo-instruct"`_
|
||||
- _`"gpt-4"`_
|
||||
- _`"gpt-4-32k"`_
|
||||
- _`"gpt-4-vision"`_
|
||||
|
||||
- _`"gpt-35-turbo"`_
|
||||
- _`"gpt-35-turbo-16k"`_
|
||||
- _`"gpt-35-turbo-instruct"`_
|
||||
- _`"gpt-4"`_
|
||||
- _`"gpt-4-32k"`_
|
||||
- _`"gpt-4-vision"`_
|
||||
|
||||
- **Azure Endpoint:** Your Azure endpoint, including the resource. Example: `https://example-resource.azure.openai.com/`.
|
||||
|
||||
- **Deployment Name:** Specifies the name of the deployment.
|
||||
|
||||
- **API Version:** Specifies the version of the Azure OpenAI API to be used. Available options include:
|
||||
- _`"2023-03-15-preview"`_
|
||||
- _`"2023-05-15"`_
|
||||
- _`"2023-06-01-preview"`_
|
||||
- _`"2023-07-01-preview"`_
|
||||
- _`"2023-08-01-preview"`_
|
||||
- _`"2023-09-01-preview"`_
|
||||
- _`"2023-12-01-preview"`_
|
||||
|
||||
- _`"2023-03-15-preview"`_
|
||||
- _`"2023-05-15"`_
|
||||
- _`"2023-06-01-preview"`_
|
||||
- _`"2023-07-01-preview"`_
|
||||
- _`"2023-08-01-preview"`_
|
||||
- _`"2023-09-01-preview"`_
|
||||
- _`"2023-12-01-preview"`_
|
||||
|
||||
- **API Key:** Your Azure OpenAI API key.
|
||||
|
||||
|
|
@ -118,7 +122,6 @@ This component allows the generation of text using the LLM (Large Language Model
|
|||
|
||||
For detailed documentation and integration guides, please refer to the [Azure OpenAI Component Documentation](https://python.langchain.com/docs/integrations/llms/azure_openai).
|
||||
|
||||
|
||||
---
|
||||
|
||||
### Cohere
|
||||
|
|
@ -265,7 +268,7 @@ This component facilitates text generation using OpenAI's models.
|
|||
|
||||
- **OpenAI API Base (Optional):** The base URL of the OpenAI API. Defaults to _`https://api.openai.com/v1`_.
|
||||
|
||||
- **OpenAI API Key (Optional):** The API key for accessing the OpenAI API.
|
||||
- **OpenAI API Key (Optional):** The API key for accessing the OpenAI API.
|
||||
|
||||
- **Temperature:** Controls the creativity of model responses. Defaults to _`0.7`_.
|
||||
|
||||
|
|
@ -282,16 +285,17 @@ This component facilitates the generation of text using Baidu Qianfan chat model
|
|||
**Params**
|
||||
|
||||
- **Model Name:** Specifies the name of the Qianfan chat model to be used for text generation. Available options include:
|
||||
- _`"ERNIE-Bot"`_
|
||||
- _`"ERNIE-Bot-turbo"`_
|
||||
- _`"BLOOMZ-7B"`_
|
||||
- _`"Llama-2-7b-chat"`_
|
||||
- _`"Llama-2-13b-chat"`_
|
||||
- _`"Llama-2-70b-chat"`_
|
||||
- _`"Qianfan-BLOOMZ-7B-compressed"`_
|
||||
- _`"Qianfan-Chinese-Llama-2-7B"`_
|
||||
- _`"ChatGLM2-6B-32K"`_
|
||||
- _`"AquilaChat-7B"`_
|
||||
|
||||
- _`"ERNIE-Bot"`_
|
||||
- _`"ERNIE-Bot-turbo"`_
|
||||
- _`"BLOOMZ-7B"`_
|
||||
- _`"Llama-2-7b-chat"`_
|
||||
- _`"Llama-2-13b-chat"`_
|
||||
- _`"Llama-2-70b-chat"`_
|
||||
- _`"Qianfan-BLOOMZ-7B-compressed"`_
|
||||
- _`"Qianfan-Chinese-Llama-2-7B"`_
|
||||
- _`"ChatGLM2-6B-32K"`_
|
||||
- _`"AquilaChat-7B"`_
|
||||
|
||||
- **Qianfan Ak:** Your Baidu Qianfan access key, obtainable from [here](https://cloud.baidu.com/product/wenxinworkshop).
|
||||
|
||||
|
|
@ -343,4 +347,4 @@ The `ChatVertexAI` is a component for generating text using Vertex AI Chat large
|
|||
|
||||
- **Stream (Optional):** Specifies whether to stream the response from the model. Defaults to _`False`_.
|
||||
|
||||
- **System Message (Optional):** System message to pass to the model.
|
||||
- **System Message (Optional):** System message to pass to the model.
|
||||
|
|
|
|||
0
docs/docs/getting-started/basic-prompting.mdx
Normal file
0
docs/docs/getting-started/basic-prompting.mdx
Normal file
0
docs/docs/getting-started/blog-writer.mdx
Normal file
0
docs/docs/getting-started/blog-writer.mdx
Normal file
0
docs/docs/getting-started/document-qa.mdx
Normal file
0
docs/docs/getting-started/document-qa.mdx
Normal file
0
docs/docs/getting-started/memory-chatbot.mdx
Normal file
0
docs/docs/getting-started/memory-chatbot.mdx
Normal file
195
docs/docs/getting-started/rag-with-astradb.mdx
Normal file
195
docs/docs/getting-started/rag-with-astradb.mdx
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
import ThemedImage from "@theme/ThemedImage";
|
||||
import useBaseUrl from "@docusaurus/useBaseUrl";
|
||||
import ZoomableImage from "/src/theme/ZoomableImage.js";
|
||||
import Admonition from "@theme/Admonition";
|
||||
|
||||
# 🌟 RAG with Astra DB
|
||||
|
||||
This guide will walk you through how to build a RAG (Retrieval Augmented Generation) application using **Astra DB** and **Langflow**.
|
||||
|
||||
[Astra DB](https://www.datastax.com/products/datastax-astra?utm_source=langflow-pre-release&utm_medium=referral&utm_campaign=langflow-announcement&utm_content=astradb) is a cloud-native database built on Apache Cassandra that is optimized for the cloud. It is a fully managed database-as-a-service that simplifies operations and reduces costs. Astra DB is built on the same technology that powers the largest Cassandra deployments in the world.
|
||||
|
||||
In this guide, we will use Astra DB as a vector store to store and retrieve the documents that will be used by the RAG application to generate responses.
|
||||
|
||||
<Admonition type="tip">
|
||||
This guide assumes that you have Langflow up and running. If you are new to
|
||||
Langflow, you can check out the [Getting Started](/) guide.
|
||||
</Admonition>
|
||||
|
||||
TLDR;
|
||||
|
||||
- [Create a free Astra DB account](https://astra.datastax.com/signup?utm_source=langflow-pre-release&utm_medium=referral&utm_campaign=langflow-announcement&utm_content=create-a-free-astra-db-account)
|
||||
- Duplicate our [Langflow 1.0 Space](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true)
|
||||
- Create a new database, get a **Token** and the **API Endpoint**
|
||||
- Click on the **New Project** button and look for Vector Store RAG. This will create a new project with the necessary components
|
||||
- Import the project into Langflow by dropping it on the Canvas or My Collection page
|
||||
- Update the **Token** and **API Endpoint** in the **Astra DB** components
|
||||
- Update the OpenAI API key in the **OpenAI** components
|
||||
- Run the ingestion flow which is the one that uses the **Astra DB** component
|
||||
- Click on the ⚡ _Run_ button and start interacting with your RAG application
|
||||
|
||||
# First things first
|
||||
|
||||
## Create an Astra DB Database
|
||||
|
||||
To get started, you will need to [create an Astra DB database](https://astra.datastax.com/signup?utm_source=langflow-pre-release&utm_medium=referral&utm_campaign=langflow-announcement&utm_content=create-an-astradb-database).
|
||||
|
||||
Once you have created an account, you will be taken to the Astra DB dashboard. Click on the **Create Database** button.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-create-database.png",
|
||||
dark: "img/astra-create-database.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
Now you will need to configure your database. Choose the **Serverless (Vector)** deployment type, and pick a Database name, provider and region.
|
||||
|
||||
After you have configured your database, click on the **Create Database** button.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-configure-deployment.png",
|
||||
dark: "img/astra-configure-deployment.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
Once your database is initialized, to the right of the page, you will see the _Database Details_ section which contains a button for you to copy the **API Endpoint** and another to generate a **Token**.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-generate-token.png",
|
||||
dark: "img/astra-generate-token.png",
|
||||
}}
|
||||
style={{ width: "50%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
Now we are all set to start building our RAG application using Astra DB and Langflow.
|
||||
|
||||
## (Optional) Duplicate the Langflow 1.0 HuggingFace Space
|
||||
|
||||
If you haven't already, now is the time to launch Langflow. To make things easier, you can duplicate our [Langflow 1.0 Space](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true) which sets up a Langflow instance just for you.
|
||||
|
||||
## Open the Vector Store RAG Project
|
||||
|
||||
To get started, click on the **New Project** button and look for the **Vector Store RAG** project. This will open a starter project with the necessary components to run a RAG application using Astra DB.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/drag-and-drop-flow.png",
|
||||
dark: "img/drag-and-drop-flow.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
This project consists of two flows. The simpler one is the **Ingestion Flow** which is responsible for ingesting the documents into the Astra DB database.
|
||||
|
||||
Your first step should be to understand what each flow does and how they interact with each other.
|
||||
|
||||
The ingestion flow consists of:
|
||||
|
||||
- **Files** component that uploads a text file to Langflow
|
||||
- **Recursive Character Text Splitter** component that splits the text into smaller chunks
|
||||
- **OpenAIEmbeddings** component that generates embeddings for the text chunks
|
||||
- **Astra DB** component that stores the text chunks in the Astra DB database
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-ingestion-flow.png",
|
||||
dark: "img/astra-ingestion-flow.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
Now, let's update the **Astra DB** and **Astra DB Search** components with the **Token** and **API Endpoint** that we generated earlier, and the OpenAI Embeddings components with your OpenAI API key.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-ingestion-fields.png",
|
||||
dark: "img/astra-ingestion-fields.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
And run it! This will ingest the Text data from your file into the Astra DB database.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-ingestion-run.png",
|
||||
dark: "img/astra-ingestion-run.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
Now, on to the **RAG Flow**. This flow is responsible for generating responses to your queries. It will define all of the steps from getting the User's input to generating a response and displaying it in the Interaction Panel.
|
||||
|
||||
The RAG flow is a bit more complex. It consists of:
|
||||
|
||||
- **Chat Input** component that defines where to put the user input coming from the Interaction Panel
|
||||
- **OpenAI Embeddings** component that generates embeddings from the user input
|
||||
- **Astra DB Search** component that retrieves the most relevant Records from the Astra DB database
|
||||
- **Text Output** component that turns the Records into Text by concatenating them and also displays it in the Interaction Panel
|
||||
- One interesting point you'll see here is that this component is named `Extracted Chunks`, and that is how it will appear in the Interaction Panel
|
||||
- **Prompt** component that takes in the user input and the retrieved Records as text and builds a prompt for the OpenAI model
|
||||
- **OpenAI** component that generates a response to the prompt
|
||||
- **Chat Output** component that displays the response in the Interaction Panel
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-rag-flow.png",
|
||||
dark: "img/astra-rag-flow.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
To run it all we have to do is click on the ⚡ _Run_ button and start interacting with your RAG application.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-rag-flow-run.png",
|
||||
dark: "img/astra-rag-flow-run.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
This opens the Interaction Panel where you can chat your data.
|
||||
|
||||
Because this flow has a **Chat Input** and a **Text Output** component, the Panel displays a chat input at the bottom and the Extracted Chunks section on the left.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-rag-flow-interaction-panel.png",
|
||||
dark: "img/astra-rag-flow-interaction-panel.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
Once we interact with it we get a response and the Extracted Chunks section is updated with the retrieved records.
|
||||
|
||||
<ZoomableImage
|
||||
alt="Docusaurus themed image"
|
||||
sources={{
|
||||
light: "img/astra-rag-flow-interaction-panel-interaction.png",
|
||||
dark: "img/astra-rag-flow-interaction-panel-interaction.png",
|
||||
}}
|
||||
style={{ width: "80%", margin: "20px auto" }}
|
||||
/>
|
||||
|
||||
And that's it! You have successfully ran a RAG application using Astra DB and Langflow.
|
||||
|
||||
# Conclusion
|
||||
|
||||
In this guide, we have learned how to run a RAG application using Astra DB and Langflow.
|
||||
We have seen how to create an Astra DB database, import the Astra DB RAG Flows project into Langflow, and run the ingestion and RAG flows.
|
||||
|
|
@ -9,6 +9,12 @@ Langflow is an easy way to build from simple to complex AI applications. It is a
|
|||
|
||||
{" "}
|
||||
|
||||
# 👋 Welcome to Langflow
|
||||
|
||||
Langflow is an easy way to build from simple to complex AI applications. It is a low-code platform that allows you to integrate AI into everything you do.
|
||||
|
||||
{" "}
|
||||
|
||||
{" "}
|
||||
|
||||
<ZoomableImage
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ module.exports = {
|
|||
},
|
||||
{
|
||||
type: "category",
|
||||
label: "Step-by-Step Guides",
|
||||
label: "Extended Components",
|
||||
collapsed: false,
|
||||
items: ["guides/langfuse_integration"],
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue