Commit graph

2,192 commits

Author SHA1 Message Date
Carlos Coelho
272be9f566
Update README.md
added discord link
2023-06-19 22:21:43 -03:00
Rodrigo Nader
53ff28ecde
Update README.md 2023-06-19 22:08:30 -03:00
Rodrigo Nader
06dbfb5faf
Update README.md (#515) 2023-06-19 21:43:39 -03:00
Rodrigo Nader
bf869232f7
Update README.md 2023-06-19 21:43:30 -03:00
Lucas Oliveira
c969bcca78 Fixed spearator 2023-06-19 19:33:07 -03:00
Gabriel Luiz Freitas Almeida
f511ddc20f Merge remote-tracking branch 'origin/main' into dev 2023-06-19 17:17:07 -03:00
Gustavo Schaedler
fa2d2fbc97
Small bugfixes and improvements (#514)
# Pull Request Description

## Summary

This Pull Request includes several code improvements, refactoring,
feature additions, and documentation updates mainly focused on enhancing
the functionality and maintainability of the codebase.

## Details

### Refactoring and Improvements:

- **Commit (5ea20aa) by @ogabrielluiz**: Unnecessary indentation in the
`getPythonCode` function within `constants.tsx` has been removed to
improve code readability.

- **Commit (6886828) by @ogabrielluiz**: 
- Changed the `load_flow_from_json` function signature in `process.py`
to accept either a JSON file path or a JSON object.
- Updated the import statement for `Chain` in `base.py` to be more
explicit by importing it from `langchain.chains.base` instead of
`langflow.graph.vertex.types`.
- Removed a print statement from the `process_tweaks` function in
`process.py`.
- Added an optional `tweaks` parameter to the `load_flow_from_json`
function.
- Changed the return type of the `build` method in the `Graph` class
from `List[Vertex]` to `Chain`.

- **Commit (83c28dc) by @ogabrielluiz**: The `process_tweaks` function
in `process.py` has been refactored to improve readability and
maintainability. An `apply_tweaks` function was added to apply tweaks to
the node, and a `validate_input` function was added for input
validation. The function now raises a `ValueError` if the input is not
in the expected format.

- **Commit (11185af) by @ogabrielluiz**: Refactored the
`fix_memory_inputs` function in `process.py` to improve readability by
reducing nesting. The function now checks if the `langchain_object` has
a `memory` attribute and if it is not `None` before proceeding. The
try-except block was also refactored to reduce nesting.

- **Commit (f180fa6) by @ogabrielluiz**: The input parameter in
`process.py` has been changed to accept a `Path` object in addition to a
string or dictionary, improving the flexibility of the function and
allowing for easier file handling.

### Features:

- **Commit (8a5525f) by @ogabrielluiz**: The `getPythonCode` function in
`constants.tsx` now accepts a `tweaks` parameter which is used to
customize the behavior of the flow. A `buildTweaks` function generates
the `tweaks` object which is passed to the `load_flow_from_json`
function.

- **Commit (c5d6f48) by @ogabrielluiz**: Added a `build_and_install`
target to the `Makefile` to build the package and install it without
running it. This is useful for building and installing on a remote
server. Additionally, fixed the path to the `langflow.main` module in
the backend target of the `Makefile`.

### Documentation:

- **Commit (76a1265) by @ogabrielluiz**: Updated the Langflow API usage
example in `README.md` to reflect the new API endpoint URL. Added a new
optional `tweaks` parameter to the `run_flow` function for flow
customization and updated the example code accordingly.

### Other:

- **Commit (0dcd93e) by @lucaseduoli**: Added Discord and Twitter icons,
and GitHub stars.

- **Commit (0dcd93e) by @lucaseduoli**: Fixed the Twitter link.
2023-06-19 21:10:41 +01:00
Gabriel Luiz Freitas Almeida
7b2849260c 🔖 chore(pyproject.toml): bump version to 0.1.4
The version number has been updated from 0.1.3 to 0.1.4. This is a chore commit as it does not introduce any new features or bug fixes, but rather updates the version number to reflect changes made in the package.
2023-06-19 16:27:08 -03:00
Lucas Oliveira
b616e0dd42 fixed twitter link 2023-06-19 16:16:58 -03:00
Lucas Oliveira
9be559397b removed api key 2023-06-19 16:14:25 -03:00
Gabriel Luiz Freitas Almeida
825f2798c3 🐛 fix(chat.py): fix node to vertex variable name in stream_build function
 feat(chat.py): add progress logging to stream_build function
The variable node was renamed to vertex to improve semantics and consistency with the naming conventions. Progress logging was added to the stream_build function to provide feedback to the user on the progress of the build process.

🐛 fix(index.tsx): fix typo in setSuccessData function call
 feat(index.tsx): add success logging to handleBuild function
A typo in the setSuccessData function call was fixed. Success logging was added to the handleBuild function to provide feedback to the user on the success of the build process.
2023-06-19 16:03:25 -03:00
Lucas Oliveira
0dcd93ef92 added discord and twitter icons, added github stars 2023-06-19 15:45:26 -03:00
Gabriel Luiz Freitas Almeida
c5d6f487fa feat(Makefile): add build_and_install target to build and install package without running it
The path to the langflow.main module was incorrect, causing the backend target to fail. The path has been updated to the correct location.

The build_and_install target has been added to build the package and install it without running it. This is useful when the package needs to be built and installed on a remote server.
🐛 fix(Makefile): fix path to langflow.main module in backend target
2023-06-19 14:28:29 -03:00
Gabriel Luiz Freitas Almeida
f180fa6f26 🐛 fix(process.py): change input parameter type hint to include Path type
The input parameter now accepts a Path object in addition to a string or dictionary. This improves the flexibility of the function and allows for easier file handling.
2023-06-19 14:25:10 -03:00
Gabriel Luiz Freitas Almeida
8a5525f465 🚀 feat(constants.tsx): add tweaks parameter to getPythonCode function to allow for customization of flow behavior
The `getPythonCode` function now accepts a `tweaks` parameter which is used to customize the behavior of the flow. The `buildTweaks` function is called to generate the `tweaks` object which is then passed to the `load_flow_from_json` function. This allows for more flexibility in the usage of the flow.
2023-06-19 14:24:48 -03:00
Gabriel Luiz Freitas Almeida
98f3c708e4 🚚 chore(pyproject.toml): move dev dependencies to group.dev
The dev dependencies were moved to the group.dev section to improve the organization of the pyproject.toml file.
2023-06-19 12:49:36 -03:00
Gabriel Luiz Freitas Almeida
76a1265eee 📝 docs(README.md): update Langflow API usage example and add tweaks parameter
The Langflow API usage example has been updated to reflect the new API endpoint URL. Additionally, a new optional `tweaks` parameter has been added to the `run_flow` function to allow customization of the flow. The example code has been updated to demonstrate how to use the `tweaks` parameter.
2023-06-19 12:37:33 -03:00
Gabriel Luiz Freitas Almeida
11185affdd 🐛 fix(process.py): refactor fix_memory_inputs function to improve readability and reduce nesting
The fix_memory_inputs function was refactored to reduce nesting and improve readability. The function now checks if the langchain_object has a memory attribute and if it is not None before proceeding. The try-except block was also refactored to reduce nesting.
2023-06-19 12:02:15 -03:00
Gabriel Luiz Freitas Almeida
83c28dcabe 🔨 refactor(process.py): refactor process_tweaks function to improve readability and maintainability
 feat(process.py): add input validation to process_tweaks function
The process_tweaks function has been refactored to improve readability and maintainability. The apply_tweaks function has been added to apply the tweaks to the node. The validate_input function has been added to validate the input parameters. The process_tweaks function now raises a ValueError if the input is not in the expected format.
2023-06-19 11:59:34 -03:00
Gabriel Luiz Freitas Almeida
6886828ddd 🔀 refactor(process.py): change load_flow_from_json function signature to accept either a JSON file path or a JSON object
🔀 refactor(base.py): import Chain from langchain.chains.base instead of importing it from langflow.graph.vertex.types
🔀 refactor(process.py): remove print statement from process_tweaks function
🔀 refactor(process.py): change load_flow_from_json function signature to accept optional tweaks parameter
🔀 refactor(process.py): change return type of build method in Graph class from List[Vertex] to Chain
🧪 test(loading.py): add test case for loading a flow from a JSON file and applying tweaks
🧪 test(loading.py): remove unused import statement
The import statement for Chain in base.py is now more explicit and imports it from langchain.chains.base instead of importing it from langflow.graph.vertex.types. The load_flow_from_json function in process.py now accepts either a JSON file path or a JSON object. The print statement in process_tweaks function has been removed. The load_flow_from_json function in process.py now accepts an optional tweaks parameter. The return type of the build method in the Graph class has been changed from List[Vertex] to Chain. A new test case has been added to loading.py to test loading a flow from a JSON file and applying tweaks. An unused import statement has been removed from loading.py.
2023-06-19 11:36:43 -03:00
Gabriel Luiz Freitas Almeida
7b165ad5d2 🐛 fix(Dockerfile): remove unnecessary files after installing dependencies
🚀 chore(pyproject.toml): rename dev-dependencies to dev.dependencies
The Dockerfile now removes unnecessary files after installing dependencies to reduce the image size. The pyproject.toml file now uses the correct naming convention for dev dependencies, which is dev.dependencies instead of dev-dependencies.
2023-06-19 11:24:03 -03:00
Gabriel Luiz Freitas Almeida
899b0b13f0
dockerfile update (#497) 2023-06-19 14:22:35 +00:00
Gabriel Luiz Freitas Almeida
5ea20aa2f0 🔨 refactor(constants.tsx): remove unnecessary indentation in getPythonCode function
The indentation of the commented line in the getPythonCode function was unnecessary and has been removed to improve code readability.
2023-06-19 10:55:18 -03:00
Gustavo Schaedler
8b71af9848
Fix to launching on Windows (#511)
Fallback to previous launch if on Windows.

Fixes #502
2023-06-19 14:09:06 +01:00
Gabriel Luiz Freitas Almeida
a3f902d479 🔖 chore(pyproject.toml): bump version to 0.1.3
The version number has been updated from 0.1.2 to 0.1.3 to reflect the changes made in the package. This is a chore commit as it does not add any new features or fix any bugs, but rather updates the version number.
2023-06-19 09:59:10 -03:00
Gabriel Luiz Freitas Almeida
e01993b7f1 🐛 fix(__main__.py): add support for running Langflow on Windows
 feat(__main__.py): add support for running Langflow on MacOS and Linux using gunicorn
The changes add support for running Langflow on Windows by using uvicorn instead of gunicorn. This is because Windows doesn't support gunicorn. The changes also add support for running Langflow on MacOS and Linux using gunicorn. This is because MacOS requires an env variable to be set to use gunicorn.
2023-06-19 09:55:29 -03:00
Gabriel Luiz Freitas Almeida
422b922a71 Merge remote-tracking branch 'origin/main' into dev 2023-06-18 10:02:50 -03:00
Gabriel Luiz Freitas Almeida
5e1ff76118
🔼 chore(pyproject.toml): update dependencies to latest versions (#509) 2023-06-18 12:32:01 +00:00
Gabriel Luiz Freitas Almeida
dfb7d2db7f 🔼 chore(pyproject.toml): update dependencies to latest versions
This commit updates the dependencies in the pyproject.toml file to their latest versions. Specifically, fastapi is updated to version 0.97.0, uvicorn is updated to version 0.22.0, typer is updated to version 0.9.0, rich is updated to version 13.4.2, llama-cpp-python is updated to version ~0.1.0, pyarrow is updated to version 12.0.0, and weaviate-client is updated to version 3.21.0.
2023-06-18 09:30:12 -03:00
Gabriel Luiz Freitas Almeida
b383934946
build(deps-dev): bump vite from 4.3.5 to 4.3.9 in /src/frontend (#508) 2023-06-18 12:15:45 +00:00
dependabot[bot]
7111bee8db
build(deps-dev): bump vite from 4.3.5 to 4.3.9 in /src/frontend
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.3.5 to 4.3.9.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.3.9/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-18 12:05:35 +00:00
Gabriel Luiz Freitas Almeida
74278ba1c7 Merge remote-tracking branch 'origin/main' into dev 2023-06-18 08:44:23 -03:00
Rodrigo Nader
663c5c0ed4
Update README.md (#506) 2023-06-18 02:32:18 -03:00
Rodrigo Nader
6038bbee6a
Update README.md 2023-06-18 02:31:26 -03:00
Gabriel Luiz Freitas Almeida
262a74f5d6
Update README.md
Added discord badge.
2023-06-17 17:58:38 -03:00
Gustavo Schaedler
ce24e27d68
HotFix 0.1.1: Prediction was not caching correctly (#504)
The prediction still required an old chat_history attirbute. This should
fix it.

Tested with Buffer Memory and achieved the correct results.

A more robust approach should be considered, though.

Fixes #500

This script was used to test it:
```python

import requests
from typing import Optional

BASE_API_URL = "http://127.0.0.1:7860/api/v1/predict"
FLOW_ID = "245e1a54-86f9-4934-bf89-bea2c7ab863d" # you should change this to your id
# You can tweak the flow by adding a tweaks dictionary
# e.g {"OpenAI-XXXXX": {"model_name": "gpt-4"}}
TWEAKS = {
    "ConversationBufferMemory-pixS4": {},
    "ConversationChain-IxmJV": {},
    "ChatOpenAI-7AcF4": {},
}


def run_flow(message: str, flow_id: str, tweaks: Optional[dict] = None) -> dict:
    """
    Run a flow with a given message and optional tweaks.

    :param message: The message to send to the flow
    :param flow_id: The ID of the flow to run
    :param tweaks: Optional tweaks to customize the flow
    :return: The JSON response from the flow
    """
    api_url = f"{BASE_API_URL}/{flow_id}"

    payload = {"message": message}

    if tweaks:
        payload["tweaks"] = tweaks

    response = requests.post(api_url, json=payload)
    return response.json()


# Setup any tweaks you want to apply to the flow
response = run_flow("Hello, I'm Gabriel", flow_id=FLOW_ID, tweaks=TWEAKS)
print(response["result"])
response = run_flow("What is my name?", flow_id=FLOW_ID, tweaks=TWEAKS)
print(response["result"])
```
2023-06-17 20:16:07 +01:00
gustavoschaedler
a87ddf9187 Stream Build test case temporarily disabled 2023-06-17 20:10:05 +01:00
Gabriel Luiz Freitas Almeida
b93d5020b3 🐛 fix(process.py): caching objects does not depend on is_first_message anymore 2023-06-17 13:34:35 -03:00
Gabriel Luiz Freitas Almeida
7d7986c5bd 🔥 chore(frontend): remove prepare-commit-msg git hook
The prepare-commit-msg git hook was removed from the frontend directory. This hook was not being used and was not necessary for the project's development workflow.
2023-06-16 19:57:33 -03:00
Gabriel Luiz Freitas Almeida
f71e7d1f7a 🔥 chore(frontend): remove prepare-commit-msg git hook
The prepare-commit-msg git hook was removed from the frontend directory. This hook was not being used and was not necessary for the project's development workflow.
2023-06-16 19:56:09 -03:00
Gabriel Luiz Freitas Almeida
8cb9df212e
Adding API improvements, HomePage and validation improvements (0.1.0) 2023-06-16 19:46:39 -03:00
Gabriel Luiz Freitas Almeida
3a324ed45a Merge remote-tracking branch 'origin/main' into dev 2023-06-16 19:28:47 -03:00
Gabriel Luiz Freitas Almeida
a5079b39f3 🔼 chore(pyproject.toml): increase package version from 0.0.88 to 0.1.0
The langchain dependency was updated to version 0.0.202 to ensure compatibility with the latest version of the package. The package version was increased from 0.0.88 to 0.1.0 to reflect the addition of new features and improvements.
🔼 chore(pyproject.toml): update langchain dependency to version 0.0.202
2023-06-16 19:23:33 -03:00
Gabriel Luiz Freitas Almeida
0f59382704
Adding API improvements, HomePage and validation improvements (#493) 2023-06-16 19:17:13 -03:00
Gabriel Luiz Freitas Almeida
f658d62c51 🔥 chore(test_database.py): remove unused test_stress_create_flow function
The test_stress_create_flow function is not used in the codebase and is therefore removed to improve code readability and maintainability.
2023-06-16 19:12:45 -03:00
Gabriel Luiz Freitas Almeida
ad552d7add 🔨 refactor(test_database.py): remove unnecessary line breaks and whitespace
This commit removes unnecessary line breaks and whitespace in the test_database.py file to improve code readability and consistency.
2023-06-16 19:11:13 -03:00
gustavoschaedler
beea12934b Merge branch 'db' of github.com:logspace-ai/langflow into db 2023-06-16 23:07:55 +01:00
gustavoschaedler
96b3331573 Tests fix 2023-06-16 23:07:23 +01:00
Gabriel Luiz Freitas Almeida
fee54b817b 🐛 fix(process.py): fix conditional statement to check if "nodes" is in graph_data
The conditional statement was checking if "nodes" is in "graph_data['data']" instead of checking if "nodes" is in "graph_data". This fix ensures that the correct data is processed and avoids potential errors.
2023-06-16 19:06:46 -03:00
Gabriel Luiz Freitas Almeida
9ff68eef82 🔥 chore(main.py): remove unnecessary newline at the beginning of the file
The only change in this commit is the removal of an unnecessary newline at the beginning of the file. This improves the code's readability and consistency.
2023-06-16 19:01:41 -03:00