Merge remote-tracking branch 'origin/dev' into fix/minor_bugs
This commit is contained in:
commit
81f61201be
435 changed files with 9714 additions and 13063 deletions
|
|
@ -4,7 +4,7 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
|
|||
import ReactPlayer from "react-player";
|
||||
import Admonition from "@theme/Admonition";
|
||||
|
||||
# Basic prompting
|
||||
# Basic Prompting
|
||||
|
||||
Prompts serve as the inputs to a large language model (LLM), acting as the interface between human instructions and computational tasks.
|
||||
|
||||
|
|
@ -14,36 +14,17 @@ This article demonstrates how to use Langflow's prompt tools to issue basic prom
|
|||
|
||||
## Prerequisites
|
||||
|
||||
1. Install Langflow.
|
||||
```bash
|
||||
python -m pip install langflow --pre
|
||||
```
|
||||
- [Langflow installed and running](../getting-started/install-langflow.mdx)
|
||||
|
||||
2. Start a local Langflow instance with the Langflow CLI:
|
||||
```bash
|
||||
langflow run
|
||||
```
|
||||
Or start Langflow with Python:
|
||||
```bash
|
||||
python -m langflow run
|
||||
```
|
||||
|
||||
Result:
|
||||
```
|
||||
│ Welcome to ⛓ Langflow │
|
||||
│ │
|
||||
│ Access http://127.0.0.1:7860 │
|
||||
│ Collaborate, and contribute at our GitHub Repo 🚀 │
|
||||
```
|
||||
- [OpenAI API key created](https://platform.openai.com)
|
||||
|
||||
<Admonition type="info">
|
||||
|
||||
Langflow v1.0 alpha is also available in [HuggingFace Spaces](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true). Try it out or follow the instructions [here](/getting-started/huggingface-spaces) to install it locally.
|
||||
|
||||
Langflow v1.0 alpha is also available in HuggingFace Spaces. [Clone the space
|
||||
using this
|
||||
link](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true)
|
||||
to create your own Langflow workspace in minutes.
|
||||
</Admonition>
|
||||
|
||||
3. Create an [OpenAI API key](https://platform.openai.com).
|
||||
|
||||
## Create the basic prompting project
|
||||
|
||||
1. From the Langflow dashboard, click **New Project**.
|
||||
|
|
@ -64,25 +45,21 @@ Examine the **Prompt** component. The **Template** field instructs the LLM to `A
|
|||
This should be interesting...
|
||||
|
||||
4. To create an environment variable for the **OpenAI** component, in the **OpenAI API Key** field, click the **Globe** button, and then click **Add New Variable**.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
|
||||
## Run the basic prompting flow
|
||||
|
||||
1. Click the **Run** button.
|
||||
The **Interaction Panel** opens, where you can converse with your bot.
|
||||
The **Interaction Panel** opens, where you can converse with your bot.
|
||||
2. Type a message and press Enter.
|
||||
The bot responds in a markedly piratical manner!
|
||||
The bot responds in a markedly piratical manner!
|
||||
|
||||
## Modify the prompt for a different result
|
||||
|
||||
1. To modify your prompt results, in the **Prompt** template, click the **Template** field.
|
||||
The **Edit Prompt** window opens.
|
||||
The **Edit Prompt** window opens.
|
||||
2. Change `Answer the user as if you were a pirate` to a different character, perhaps `Answer the user as if you were Harold Abelson.`
|
||||
3. Run the basic prompting flow again.
|
||||
The response will be markedly different.
|
||||
|
||||
|
||||
|
||||
|
||||
The response will be markedly different.
|
||||
|
|
|
|||
|
|
@ -4,42 +4,23 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
|
|||
import ReactPlayer from "react-player";
|
||||
import Admonition from "@theme/Admonition";
|
||||
|
||||
# Blog writer
|
||||
# Blog Writer
|
||||
|
||||
Build a blog writer with OpenAI that uses URLs for reference content.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Install Langflow.
|
||||
```bash
|
||||
python -m pip install langflow --pre
|
||||
```
|
||||
- [Langflow installed and running](../getting-started/install-langflow.mdx)
|
||||
|
||||
2. Start a local Langflow instance with the Langflow CLI:
|
||||
```bash
|
||||
langflow run
|
||||
```
|
||||
Or start Langflow with Python:
|
||||
```bash
|
||||
python -m langflow run
|
||||
```
|
||||
|
||||
Result:
|
||||
```bash
|
||||
│ Welcome to ⛓ Langflow │
|
||||
│ │
|
||||
│ Access http://127.0.0.1:7860 │
|
||||
│ Collaborate, and contribute at our GitHub Repo 🚀 │
|
||||
```
|
||||
- [OpenAI API key created](https://platform.openai.com)
|
||||
|
||||
<Admonition type="info">
|
||||
|
||||
Langflow v1.0 alpha is also available in [HuggingFace Spaces](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true). Try it out or follow the instructions [here](/getting-started/huggingface-spaces) to install it locally.
|
||||
|
||||
Langflow v1.0 alpha is also available in HuggingFace Spaces. [Clone the space
|
||||
using this
|
||||
link](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true)
|
||||
to create your own Langflow workspace in minutes.
|
||||
</Admonition>
|
||||
|
||||
3. Create an [OpenAI API key](https://platform.openai.com).
|
||||
|
||||
## Create the Blog Writer project
|
||||
|
||||
1. From the Langflow dashboard, click **New Project**.
|
||||
|
|
@ -58,6 +39,7 @@ Result:
|
|||
This flow creates a one-shot prompt flow with **Prompt**, **OpenAI**, and **Chat Output** components, and augments the flow with reference content and instructions from the **URL** and **Instructions** components.
|
||||
|
||||
The **Prompt** component's default **Template** field looks like this:
|
||||
|
||||
```bash
|
||||
Reference 1:
|
||||
|
||||
|
|
@ -81,16 +63,16 @@ The `{instructions}` value is received from the **Value** field of the **Instruc
|
|||
The `reference_1` and `reference_2` values are received from the **URL** fields of the **URL** components.
|
||||
|
||||
4. To create an environment variable for the **OpenAI** component, in the **OpenAI API Key** field, click the **Globe** button, and then click **Add New Variable**.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
|
||||
## Run the Blog Writer flow
|
||||
|
||||
1. Click the **Run** button.
|
||||
The **Interaction Panel** opens, where you can run your one-shot flow.
|
||||
The **Interaction Panel** opens, where you can run your one-shot flow.
|
||||
2. Click the **Lighting Bolt** icon to run your flow.
|
||||
3. The **OpenAI** component constructs a blog post with the **URL** items as context.
|
||||
The default **URL** values are for web pages at `promptingguide.ai`, so your blog post will be about prompting LLMs.
|
||||
The default **URL** values are for web pages at `promptingguide.ai`, so your blog post will be about prompting LLMs.
|
||||
|
||||
To write about something different, change the values in the **URL** components, and see what the LLM constructs.
|
||||
To write about something different, change the values in the **URL** components, and see what the LLM constructs.
|
||||
|
|
|
|||
|
|
@ -10,36 +10,17 @@ Build a question-and-answer chatbot with a document loaded from local memory.
|
|||
|
||||
## Prerequisites
|
||||
|
||||
1. Install Langflow.
|
||||
```bash
|
||||
python -m pip install langflow --pre
|
||||
```
|
||||
- [Langflow installed and running](../getting-started/install-langflow.mdx)
|
||||
|
||||
2. Start a local Langflow instance with the Langflow CLI:
|
||||
```bash
|
||||
langflow run
|
||||
```
|
||||
Or start Langflow with Python:
|
||||
```bash
|
||||
python -m langflow run
|
||||
```
|
||||
|
||||
Result:
|
||||
```
|
||||
│ Welcome to ⛓ Langflow │
|
||||
│ │
|
||||
│ Access http://127.0.0.1:7860 │
|
||||
│ Collaborate, and contribute at our GitHub Repo 🚀 │
|
||||
```
|
||||
- [OpenAI API key created](https://platform.openai.com)
|
||||
|
||||
<Admonition type="info">
|
||||
|
||||
Langflow v1.0 alpha is also available in [HuggingFace Spaces](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true). Try it out or follow the instructions [here](/getting-started/huggingface-spaces) to install it locally.
|
||||
|
||||
Langflow v1.0 alpha is also available in HuggingFace Spaces. [Clone the space
|
||||
using this
|
||||
link](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true)
|
||||
to create your own Langflow workspace in minutes.
|
||||
</Admonition>
|
||||
|
||||
3. Create an [OpenAI API key](https://platform.openai.com).
|
||||
|
||||
## Create the Document QA project
|
||||
|
||||
1. From the Langflow dashboard, click **New Project**.
|
||||
|
|
@ -61,24 +42,27 @@ The **Prompt** component is instructed to answer questions based on the contents
|
|||
Including a file with the prompt gives the **OpenAI** component context it may not otherwise have access to.
|
||||
|
||||
4. To create an environment variable for the **OpenAI** component, in the **OpenAI API Key** field, click the **Globe** button, and then click **Add New Variable**.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
|
||||
5. To select a document to load, in the **Files** component, click within the **Path** field.
|
||||
1. Select a local file, and then click **Open**.
|
||||
2. The file name appears in the field.
|
||||
<Admonition type="tip">
|
||||
The file must be of an extension type listed [here](https://github.com/langflow-ai/langflow/blob/dev/src/backend/base/langflow/base/data/utils.py#L13).
|
||||
</Admonition>
|
||||
1. Select a local file, and then click **Open**.
|
||||
2. The file name appears in the field.
|
||||
<Admonition type="tip">
|
||||
The file must be of an extension type listed
|
||||
[here](https://github.com/langflow-ai/langflow/blob/dev/src/backend/base/langflow/base/data/utils.py#L13).
|
||||
</Admonition>
|
||||
|
||||
## Run the Document QA flow
|
||||
|
||||
1. Click the **Run** button.
|
||||
The **Interaction Panel** opens, where you can converse with your bot.
|
||||
The **Interaction Panel** opens, where you can converse with your bot.
|
||||
2. Type a message and press Enter.
|
||||
For this example, we loaded an error log `.txt` file and asked, "What went wrong?"
|
||||
The bot responded:
|
||||
For this example, we loaded an error log `.txt` file and asked, "What went wrong?"
|
||||
The bot responded:
|
||||
|
||||
```
|
||||
The issue occurred during the execution of migrations in the application. Specifically, an error was raised by the Alembic library, indicating that new upgrade operations were detected that had not been accounted for in the existing migration scripts. The operation in question involved modifying the nullable property of a column (apikey, created_at) in the database, with details about the existing type (DATETIME()), existing server default, and other properties.
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,42 +4,23 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
|
|||
import ReactPlayer from "react-player";
|
||||
import Admonition from "@theme/Admonition";
|
||||
|
||||
# Memory chatbot
|
||||
# Memory Chatbot
|
||||
|
||||
This flow extends the [basic prompting flow](./basic-prompting.mdx) to include chat memory for unique SessionIDs.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Install Langflow.
|
||||
```bash
|
||||
python -m pip install langflow --pre
|
||||
```
|
||||
- [Langflow installed and running](../getting-started/install-langflow.mdx)
|
||||
|
||||
2. Start a local Langflow instance with the Langflow CLI:
|
||||
```bash
|
||||
langflow run
|
||||
```
|
||||
Or start Langflow with Python:
|
||||
```bash
|
||||
python -m langflow run
|
||||
```
|
||||
|
||||
Result:
|
||||
```
|
||||
│ Welcome to ⛓ Langflow │
|
||||
│ │
|
||||
│ Access http://127.0.0.1:7860 │
|
||||
│ Collaborate, and contribute at our GitHub Repo 🚀 │
|
||||
```
|
||||
- [OpenAI API key created](https://platform.openai.com)
|
||||
|
||||
<Admonition type="info">
|
||||
|
||||
Langflow v1.0 alpha is also available in [HuggingFace Spaces](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true). Try it out or follow the instructions [here](/getting-started/huggingface-spaces) to install it locally.
|
||||
|
||||
Langflow v1.0 alpha is also available in HuggingFace Spaces. [Clone the space
|
||||
using this
|
||||
link](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true)
|
||||
to create your own Langflow workspace in minutes.
|
||||
</Admonition>
|
||||
|
||||
3. Create an [OpenAI API key](https://platform.openai.com).
|
||||
|
||||
## Create the memory chatbot project
|
||||
|
||||
1. From the Langflow dashboard, click **New Project**.
|
||||
|
|
@ -65,16 +46,16 @@ This chatbot is augmented with the **Chat Memory** component, which stores messa
|
|||
The **Chat History** component gives the **OpenAI** component a memory of previous questions.
|
||||
|
||||
4. To create an environment variable for the **OpenAI** component, in the **OpenAI API Key** field, click the **Globe** button, and then click **Add New Variable**.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
|
||||
## Run the memory chatbot flow
|
||||
|
||||
1. Click the **Run** button.
|
||||
The **Interaction Panel** opens, where you can converse with your bot.
|
||||
The **Interaction Panel** opens, where you can converse with your bot.
|
||||
2. Type a message and press Enter.
|
||||
The bot will respond according to the template in the **Prompt** component.
|
||||
The bot will respond according to the template in the **Prompt** component.
|
||||
3. Type more questions. In the **Outputs** log, your queries are logged in order. Up to 5 queries are stored by default. Try asking `What is the first subject I asked you about?` to see where the LLM's memory disappears.
|
||||
|
||||
## Modify the Session ID field to have multiple conversations
|
||||
|
|
@ -87,11 +68,11 @@ You can demonstrate this by modifying the **Session ID** value to switch between
|
|||
|
||||
1. In the **Session ID** field of the **Chat Memory** and **Chat Input** components, change the **Session ID** value from `MySessionID` to `AnotherSessionID`.
|
||||
2. Click the **Run** button to run your flow.
|
||||
In the **Interaction Panel**, you will have a new conversation. (You may need to clear the cache with the **Eraser** button).
|
||||
In the **Interaction Panel**, you will have a new conversation. (You may need to clear the cache with the **Eraser** button).
|
||||
3. Type a few questions to your bot.
|
||||
4. In the **Session ID** field of the **Chat Memory** and **Chat Input** components, change the **Session ID** value back to `MySessionID`.
|
||||
5. Run your flow.
|
||||
The **Outputs** log of the **Interaction Panel** displays the history from your initial chat with `MySessionID`.
|
||||
The **Outputs** log of the **Interaction Panel** displays the history from your initial chat with `MySessionID`.
|
||||
|
||||
## Store Session ID as a Langflow variable
|
||||
|
||||
|
|
@ -101,4 +82,3 @@ To store **Session ID** as a Langflow variable, in the **Session ID** field, cli
|
|||
2. In the **Value** field, enter a value like `1B5EBD79-6E9C-4533-B2C8-7E4FF29E983B`.
|
||||
3. Click **Save Variable**.
|
||||
4. Apply this variable to **Chat Input**.
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import ZoomableImage from "/src/theme/ZoomableImage.js";
|
|||
import ReactPlayer from "react-player";
|
||||
import Admonition from "@theme/Admonition";
|
||||
|
||||
# Vector store RAG
|
||||
# Vector Store RAG
|
||||
|
||||
Retrieval Augmented Generation, or RAG, is a pattern for training LLMs on your data and querying it.
|
||||
|
||||
|
|
@ -17,16 +17,19 @@ We've chosen [Astra DB](https://astra.datastax.com/signup?utm_source=langflow-pr
|
|||
## Prerequisites
|
||||
|
||||
<Admonition type="info">
|
||||
Langflow v1.0 alpha is also available in [HuggingFace Spaces](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true). Try it out or follow the instructions [here](../getting-started/huggingface-spaces) to install it locally.
|
||||
Langflow v1.0 alpha is also available in HuggingFace Spaces. [Clone the space
|
||||
using this
|
||||
link](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true)
|
||||
to create your own Langflow workspace in minutes.
|
||||
</Admonition>
|
||||
|
||||
* [Langflow installed](../getting-started/install-langflow.mdx)
|
||||
- [Langflow installed and running](../getting-started/install-langflow.mdx)
|
||||
|
||||
* [OpenAI API key](https://platform.openai.com)
|
||||
- [OpenAI API key](https://platform.openai.com)
|
||||
|
||||
* [An Astra DB vector database created](https://docs.datastax.com/en/astra-db-serverless/get-started/quickstart.html) with:
|
||||
* Application token (`AstraCS:WSnyFUhRxsrg…`)
|
||||
* API endpoint (`https://ASTRA_DB_ID-ASTRA_DB_REGION.apps.astra.datastax.com`)
|
||||
- [An Astra DB vector database created](https://docs.datastax.com/en/astra-db-serverless/get-started/quickstart.html) with:
|
||||
- Application token (`AstraCS:WSnyFUhRxsrg…`)
|
||||
- API endpoint (`https://ASTRA_DB_ID-ASTRA_DB_REGION.apps.astra.datastax.com`)
|
||||
|
||||
## Create the vector store RAG project
|
||||
|
||||
|
|
@ -49,38 +52,40 @@ The **ingestion** flow (bottom of the screen) populates the vector store with da
|
|||
It ingests data from a file (**File**), splits it into chunks (**Recursive Character Text Splitter**), indexes it in Astra DB (**Astra DB**), and computes embeddings for the chunks (**OpenAI Embeddings**).
|
||||
This forms a "brain" for the query flow.
|
||||
|
||||
The **query** flow (top of the screen) allows users to chat with the embedded vector store data. It's a little more complex:
|
||||
The **query** flow (top of the screen) allows users to chat with the embedded vector store data. It's a little more complex:
|
||||
|
||||
* **Chat Input** component defines where to put the user input coming from the Playground.
|
||||
* **OpenAI Embeddings** component generates embeddings from the user input.
|
||||
* **Astra DB Search** component retrieves the most relevant Records from the Astra DB database.
|
||||
* **Text Output** component turns the Records into Text by concatenating them and also displays it in the Playground.
|
||||
* **Prompt** component takes in the user input and the retrieved Records as text and builds a prompt for the OpenAI model.
|
||||
* **OpenAI** component generates a response to the prompt.
|
||||
* **Chat Output** component displays the response in the Playground.
|
||||
- **Chat Input** component defines where to put the user input coming from the Playground.
|
||||
- **OpenAI Embeddings** component generates embeddings from the user input.
|
||||
- **Astra DB Search** component retrieves the most relevant Records from the Astra DB database.
|
||||
- **Text Output** component turns the Records into Text by concatenating them and also displays it in the Playground.
|
||||
- **Prompt** component takes in the user input and the retrieved Records as text and builds a prompt for the OpenAI model.
|
||||
- **OpenAI** component generates a response to the prompt.
|
||||
- **Chat Output** component displays the response in the Playground.
|
||||
|
||||
4. To create an environment variable for the **OpenAI** component, in the **OpenAI API Key** field, click the **Globe** button, and then click **Add New Variable**.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
|
||||
4. To create environment variables for the **Astra DB** and **Astra DB Search** components:
|
||||
1. In the **Token** field, click the **Globe** button, and then click **Add New Variable**.
|
||||
2. In the **Variable Name** field, enter `astra_token`.
|
||||
3. In the **Value** field, paste your Astra application token (`AstraCS:WSnyFUhRxsrg…`).
|
||||
4. Click **Save Variable**.
|
||||
5. Repeat the above steps for the **API Endpoint** field, pasting your Astra API Endpoint instead (`https://ASTRA_DB_ID-ASTRA_DB_REGION.apps.astra.datastax.com`).
|
||||
6. Add the global variable to both the **Astra DB** and **Astra DB Search** components.
|
||||
1. In the **Variable Name** field, enter `openai_api_key`.
|
||||
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
|
||||
3. Click **Save Variable**.
|
||||
|
||||
5. To create environment variables for the **Astra DB** and **Astra DB Search** components:
|
||||
1. In the **Token** field, click the **Globe** button, and then click **Add New Variable**.
|
||||
2. In the **Variable Name** field, enter `astra_token`.
|
||||
3. In the **Value** field, paste your Astra application token (`AstraCS:WSnyFUhRxsrg…`).
|
||||
4. Click **Save Variable**.
|
||||
5. Repeat the above steps for the **API Endpoint** field, pasting your Astra API Endpoint instead (`https://ASTRA_DB_ID-ASTRA_DB_REGION.apps.astra.datastax.com`).
|
||||
6. Add the global variable to both the **Astra DB** and **Astra DB Search** components.
|
||||
|
||||
## Run the vector store RAG flow
|
||||
|
||||
1. Click the **Playground** button.
|
||||
The **Playground** opens, where you can chat with your data.
|
||||
The **Playground** opens, where you can chat with your data.
|
||||
2. Type a message and press Enter. (Try something like "What topics do you know about?")
|
||||
3. The bot will respond with a summary of the data you've embedded.
|
||||
|
||||
For example, we embedded a PDF of an engine maintenance manual and asked, "How do I change the oil?"
|
||||
The bot responds:
|
||||
|
||||
```
|
||||
To change the oil in the engine, follow these steps:
|
||||
|
||||
|
|
@ -102,7 +107,3 @@ You should use a 3/8 inch wrench to remove the oil drain cap.
|
|||
```
|
||||
|
||||
This is the size the engine manual lists as well. This confirms our flow works, because the query returns the unique knowledge we embedded from the Astra vector store.
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue