Skip to content

Commit

Permalink
Merge branch 'main' into feat/support-tongyi
Browse files Browse the repository at this point in the history
  • Loading branch information
yugasun authored Nov 24, 2024
2 parents 1aa6b9d + bd15071 commit dc75a4e
Show file tree
Hide file tree
Showing 130 changed files with 11,886 additions and 1,715 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/python_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,16 @@ jobs:
if: steps.check-version.outputs.skipped == 'false'
run: |
make build main=true
- name: Install wheel
- name: Install wheel and Test CLI
if: steps.check-version.outputs.skipped == 'false'
run: |
python -m pip install dist/*.whl
uv venv new-venv
source new-venv/bin/activate
uv pip install dist/*.whl
- name: Test CLI
if: steps.check-version.outputs.skipped == 'false'
run: |
source new-venv/bin/activate
python -m langflow run --host 127.0.0.1 --port 7860 --backend-only &
SERVER_PID=$!
# Wait for the server to start
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ src/frontend/temp
.history

.dspy_cache/
cache.db
*.db
76 changes: 76 additions & 0 deletions docs/docs/Configuration/configuration-custom-database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: Configure an external PostgreSQL database
sidebar_position: 8
---
Langflow's default database is [SQLite](https://www.sqlite.org/docs.html), but you can configure Langflow to use PostgreSQL instead.

This guide will walk you through the process of setting up an external database for Langflow by replacing the default SQLite connection string `sqlite:///./langflow.db` with PostgreSQL.

## Prerequisite

* A [PostgreSQL](https://www.pgadmin.org/download/) database

## Connect Langflow to PostgreSQL

To connect Langflow to PostgreSQL, follow these steps.

1. Find your PostgreSQL database's connection string.
It looks like `postgresql://user:password@host:port/dbname`.
For example, if you started PostgreSQL with this Docker command:

```
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
```

Your connection string would be `postgresql://some-postgres:mysecretpassword@localhost:5432/postgres`.

2. Create a `.env` file for configuring Langflow.
```
touch .env
```

3. To set the database URL environment variable, add it to your `.env` file:
```plaintext
LANGFLOW_DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
```

:::tip
The Langflow project includes a [`.env.example`](https://github.com/langflow-ai/langflow/blob/main/.env.example) file to help you get started.
You can copy the contents of this file into your own `.env` file and replace the example values with your own preferred settings.
Replace the value for `LANGFLOW_DATABASE_URL` with your PostgreSQL connection string.
:::

4. Run Langflow with the `.env` file:
```bash
langflow run --env-file .env
```

5. In Langflow, create traffic by running a flow.
6. Inspect your PostgreSQL deployment's tables and activity.
You will see new tables and traffic created.

## Example Langflow and PostgreSQL docker-compose.yml

The Langflow project includes a [`docker-compose.yml`](https://github.com/langflow-ai/langflow/blob/main/docker_example/docker-compose.yml) file for quick deployment with PostgreSQL.

This configuration launches Langflow and PostgreSQL containers, with Langflow pre-configured to use the PostgreSQL database. Customize the database credentials as needed.

To start the services, navigate to the `/docker_example` directory, and then run `docker-compose up`.

```yaml
services:
langflow:
image: langflow-ai/langflow:latest
environment:
- LANGFLOW_DATABASE_URL=postgresql://user:password@postgres:5432/langflow
depends_on:
- postgres

postgres:
image: postgres:15
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=langflow
```
6 changes: 3 additions & 3 deletions docs/docs/Guides/guides-chat-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ slug: /guides-chat-memory



Langflow allows every chat message to be stored, and a single flow can have multiple memory sessions. This enables you to create separate _memories_ for agents to store and recall information as needed.
Langflow allows every chat message to be stored, and a single flow can have multiple memory sessions. This enables you to create separate _memories_ for agents to store and recall information as needed.


In any project, as long as there are [**Chat**](/components-io) being used, memories are always being stored by default. These are messages from a user to the AI or vice-versa.
Expand All @@ -26,7 +26,7 @@ Memories can be visualized and managed directly from the **Playground**. You can

Modifying these memories will influence the behavior of the chatbot responses, as long as an agent uses them. Here you have the ability to remove or edit previous messages, allowing them to manipulate and explore how these changes affect model responses.

To modify chat memories, click your **Flow Name**, and then click **Logs**.
To modify chat memories, from the playground, click the **Options** menu of any session, and then select **Message Logs**.


![](/img/logs.png)
Expand All @@ -45,7 +45,7 @@ The **Chat Memory** component also retrieves message histories by `Session ID`,

![](/img/chat-input-controls-pane.png)

By default, if the `Session ID` value is empty, it is set to match the the same value as the `Flow ID`.
By default, if the `Session ID` value is empty, it is set to the same value as `Flow ID`.

You can also display all messages stored across every flow and session by going to **Settings** > **Messages**.

Expand Down
36 changes: 23 additions & 13 deletions docs/docs/Guides/guides-data-message.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,38 @@ print(data.title) # Outputs: "Hello, World!" because "title" key is in the data
The `Data` object is also convenient for visualization of outputs, since the output preview has visual elements to inspect data as a table and its cells as pop ups for basic types. The idea is to create a unified way to work and visualize complex information in Langflow.


To receive `Data` objects in a component input, you can use the `DataInput` input type.
To receive `Data` objects in a component input, you can use the `DataInput` input type.


## The Message Object {#f4f17cad02a545068f407d515cbc2902}
## Message object attributes {#f4f17cad02a545068f407d515cbc2902}


---


The `Message` object extends the functionality of `Data` and includes additional attributes and methods for chat interactions.

- **Main Attributes:**
- `text_key`: Key to retrieve the primary text data.
- `text`: The main text content of the message.
- `sender`: Identifier for the sender (e.g., "User" or "AI").
- `sender_name`: Name of the sender.
- `files`: List of files associated with the message.
- `session_id`: Identifier for the chat session.
- `timestamp`: Timestamp when the message was created.
- `flow_id`: Identifier for the flow.

The `Message` object can be used to send, store and manipulate chat messages within Langflow. You can create a `Message` object by directly assigning key-value pairs to it. For example:

- **Core message data:**
- `text`: The main text content of the message
- `sender`: Identifier for the sender (e.g., "User" or "AI")
- `sender_name`: Name of the sender
- `session_id`: Identifier for the chat session
- `timestamp`: Timestamp when the message was created (UTC)
- `flow_id`: Identifier for the flow
- `id`: Unique identifier for the message

- **Content and files:**
- `files`: List of files or images associated with the message
- `content_blocks`: List of structured content blocks
- `properties`: Additional properties including visual styling and source information

- **Message state:**
- `error`: Boolean indicating if there was an error
- `edit`: Boolean indicating if the message was edited
- `category`: Message category ("message", "error", "warning", "info")

The `Message` object can be used to send, store, and manipulate chat messages within Langflow. You can create a `Message` object by directly assigning key-value pairs to it. For example:


```python
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/Workspace/workspace-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The **Playground** executes the current flow in the workspace.

Chat with your flow, view inputs and outputs, and modify your AI's memories to tune your responses in real time.

Any input or output component can be opened in the **Playground** and tested in real time.
Either the **Chat Input** or **Chat Output** component can be opened in the **Playground** and tested in real time.

For more information, see the [Playground documentation](/workspace-playground).

Expand Down
13 changes: 5 additions & 8 deletions docs/docs/Workspace/workspace-playground.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@ Notice how the **Playground's** window arrangement changes depending on what com
:::


You can also open a flow's **Playground** without entering its workspace. From **My Collections** or **Langflow Store**, click the **Playground** in one of the projects card.


## Memory Management {#821a5ee2a8a44d35b49943cba630511c}


---

Click the Memories tab to open a table of previous interactions for a specific flow.
When you send a message from the **Playground** interface, the interactions for that session are stored in the **Message Logs**.

Whenever you send a message from the **Playground** interface, under the **Memories** tab you'll see a table of previous interactions for that session.

Langflow allows every chat message to be stored, and a single flow can have multiple memory sessions.
Langflow allows every chat message to be stored, and a single flow can have multiple chat sessions.

Chat conversations store messages categorized by a Session ID. A single flow can host multiple Session IDs, and different flows can share the same Session ID.

To view messages by session ID, from the Playground, click the Options menu of any session, and then select Message Logs.

Individual messages in chat memory can be edited or deleted. Modifying these memories will influence the behavior of the chatbot responses.

To learn more about memories in Langflow, see [Chat Memory](/guides-chat-memory).
Expand All @@ -63,7 +60,7 @@ curl -X POST \
}'
```

Check your flow’s Memories tab. In addition to the messages stored for the Default Session, a new chat session is started with your new Session ID.
Check your flow's **Playground**. In addition to the messages stored for the Default Session, a new session is started with your new Session ID.

**Chat Input** and **Chat Output** components can also store a `session_id` parameter as a **Tweak** for specific sessions. The Playground will still display all available sessions, but the flow will use the value stored in the `session_id` tweak.

Expand Down
Binary file modified docs/static/img/logs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 62 additions & 66 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,90 +32,86 @@ maintainers = [
# Define your main dependencies here
dependencies = [
"langflow-base==0.1.0",
"beautifulsoup4>=4.12.2",
"google-search-results>=2.4.1",
"google-api-python-client>=2.130.0",
"huggingface-hub[inference]>=0.23.2",
"networkx>=3.1",
"fake-useragent>=1.5.0",
"pyarrow>=14.0.0",
"wikipedia>=1.4.0",
"beautifulsoup4>=4.12.2,<5.0.0",
"google-search-results>=2.4.1,<3.0.0",
"google-api-python-client>=2.130.0,<3.0.0",
"huggingface-hub[inference]>=0.23.2,<1.0.0",
"networkx>=3.1,<4.0.0",
"fake-useragent>=1.5.0,<2.0.0",
"pyarrow>=14.0.0,<18.0.0",
"wikipedia>=1.4.0,<2.0.0",
"qdrant-client~=1.9.2",
"weaviate-client>=4.8",
"cohere>=5.5.3",
"faiss-cpu>=1.8.0",
"types-cachetools>=5.3.0.5",
"pymongo>=4.6.0",
"weaviate-client>=4.8,<5.0.0",
"cohere>=5.5.3,<6.0.0",
"faiss-cpu>=1.8.0,<2.0.0",
"types-cachetools>=5.3.0.5,<6.0.0",
"pymongo>=4.6.0,<5.0.0",
"supabase~=2.6.0",
"certifi>=2023.11.17,<2025.0.0",
"fastavro>=1.8.0",
"redis>=5.0.1",
"metaphor-python>=0.1.11",
'pywin32>=306; sys_platform == "win32"',
"fastavro>=1.8.0,<2.0.0",
"redis>=5.0.1,<6.0.0",
"metaphor-python>=0.1.11,<1.0.0",
'pywin32>=306,<307; sys_platform == "win32"',
"langfuse~=2.53.1",
"metal-sdk>=2.5.0",
"markupsafe>=2.1.3",
"metal-sdk>=2.5.0,<3.0.0",
"markupsafe>=2.1.3,<4.0.0",
"boto3~=1.34.162",
"numexpr>=2.8.6",
"numexpr>=2.8.6,<3.0.0",
"qianfan==0.3.5",
"pgvector>=0.2.3",
"pyautogen>=0.2.0",
"pgvector>=0.2.3,<1.0.0",
"pyautogen>=0.2.0,<1.0.0",
"langchain~=0.3.3",
"elasticsearch>=8.12.0",
"pytube>=15.0.0",
"dspy-ai>=2.4.0",
"assemblyai>=0.33.0",
"litellm>=1.44.0",
"chromadb>=0.4",
"zep-python>=2.0.0",
"langchain-groq>=0.1.9",
"langchain-pinecone>=0.1.3",
"youtube-transcript-api>=0.6.2",
"markdown>=3.7",
"upstash-vector>=0.5.0",
"gitpython>=3.1.43",
"kubernetes>=30.1.0",
"firecrawl-py==1.5.0",
"json-repair>=0.25.2",
"langchain-google-calendar-tools>=0.0.1",
"langchain-milvus>=0.1.1",
"elasticsearch>=8.12.0,<9.0.0",
"pytube>=15.0.0,<16.0.0",
"dspy-ai>=2.4.0,<3.0.0",
"assemblyai>=0.33.0,<1.0.0",
"litellm>=1.44.0,<2.0.0",
"chromadb>=0.4,<1.0.0",
"zep-python>=2.0.0,<3.0.0",
"langchain-groq>=0.1.9,<1.0.0",
"langchain-pinecone>=0.1.3,<1.0.0",
"youtube-transcript-api>=0.6.2,<1.0.0",
"markdown>=3.7,<4.0.0",
"upstash-vector>=0.5.0,<1.0.0",
"gitpython>=3.1.43,<4.0.0",
"kubernetes>=30.1.0,<32.0.0",
"json-repair>=0.25.2,<1.0.0",
"langchain-google-calendar-tools>=0.0.1,<1.0.0",
"langchain-milvus>=0.1.1,<1.0.0",
"langwatch==0.1.16",
"langsmith~=0.1.136",
"yfinance>=0.2.40",
"wolframalpha>=5.1.3",
"yfinance>=0.2.40,<1.0.0",
"wolframalpha>=5.1.3,<6.0.0",
"astra-assistants[tools]~=2.2.6",
"composio-langchain==0.5.9",
"spider-client>=0.0.27",
"nltk>=3.9.1",
"lark>=1.2.2",
"jq>=1.8.0",
"composio-langchain==0.5.42",
"spider-client>=0.0.27,<1.0.0",
"nltk>=3.9.1,<4.0.0",
"lark>=1.2.2,<2.0.0",
"jq>=1.8.0,<2.0.0",
"pydantic-settings==2.4.0",
"ragstack-ai-knowledge-store>=0.2.1",
"duckduckgo-search>=6.3.4",
"opensearch-py>=2.7.1",
"langchain-google-genai>=1.0.8",
"langchain-cohere>=0.1.5",
"langchain-anthropic>=0.1.23",
"ragstack-ai-knowledge-store>=0.2.1,<1.0.0",
"duckduckgo-search>=6.3.4,<7.0.0",
"opensearch-py>=2.7.1,<3.0.0",
"langchain-google-genai>=2.0.1,<3.0.0",
"langchain-cohere>=0.1.5,<1.0.0",
"langchain-anthropic>=0.1.23,<1.0.0",
"langchain-astradb~=0.5.2",
"langchain-openai~=0.2.2",
"langchain-google-vertexai~=2.0.5",
"langchain-groq>=0.1.9",
"langchain-groq>=0.1.9,<1.0.0",
"langchain-pinecone~=0.2.0",
"langchain-mistralai~=0.2.0",
"langchain-chroma>=0.1.1",
"langchain-aws>=0.1.16",
"langchain-chroma>=0.1.1,<1.0.0",
"langchain-aws>=0.1.16,<1.0.0",
"langchain-unstructured~=0.1.5",
"langchain-mongodb>=0.1.6",
"langchain-mongodb>=0.1.6,<1.0.0",
"langchain-nvidia-ai-endpoints~=0.3.0",
"langchain-google-calendar-tools>=0.0.1",
"langchain-milvus>=0.1.1",
"langchain-google-community~=2.0.1",
"langchain-elasticsearch>=0.2.0",
"opensearch-py>=2.7.1",
"langchain-ollama>=0.2.0",
"sqlalchemy[aiosqlite,postgresql_psycopg2binary,postgresql_psycopgbinary]>=2.0.36",
"atlassian-python-api>=3.41.16",
"mem0ai>=0.1.26",
"langchain-elasticsearch>=0.2.0,<1.0.0",
"langchain-ollama>=0.2.0,<1.0.0",
"sqlalchemy[aiosqlite,postgresql_psycopg2binary,postgresql_psycopgbinary]>=2.0.36,<3.0.0",
"atlassian-python-api>=3.41.16,<4.0.0",
"mem0ai>=0.1.26,<1.0.0",
]

[project.urls]
Expand Down Expand Up @@ -180,7 +176,7 @@ dev-dependencies = [
"asgi-lifespan>=2.1.0",
"pytest-github-actions-annotate-failures>=0.2.0",
"pytest-codspeed>=3.0.0",
"forbiddenfruit>=0.1.4",
"blockbuster>=1.1.1,<1.2",
]


Expand Down
Loading

0 comments on commit dc75a4e

Please sign in to comment.