Commit graph

2,162 commits

Author SHA1 Message Date
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
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
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
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
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
Gabriel Luiz Freitas Almeida
e58d626068 📦 chore(pyproject.toml): add types-cachetools to dev dependencies
The types-cachetools package was added to the dev dependencies to provide type annotations for the cachetools package. This improves the codebase's maintainability and readability by providing better type hints.
2023-06-16 18:54:45 -03:00
Gabriel Luiz Freitas Almeida
c7cbb40c36 format: run make format 2023-06-16 18:54:18 -03:00
Gabriel Luiz Freitas Almeida
08f04d11d0 🔨 refactor(tests): fix formatting and remove unnecessary lines
The changes in this commit are purely cosmetic. The code has been reformatted to improve readability and consistency. Unnecessary lines have been removed to make the code more concise.
2023-06-16 18:53:42 -03:00
Gabriel Luiz Freitas Almeida
b06e7a058a 🐛 fix(chat.py): add type hint to flow_data_store variable
🔥 chore(main.py): remove unused imports and variables
The `flow_data_store` variable in `chat.py` was missing a type hint, which was added to improve code readability and maintainability. In `main.py`, unused imports and variables were removed to improve code cleanliness.
2023-06-16 18:52:55 -03:00
Gabriel Luiz Freitas Almeida
28a902ec15 🚀 chore(MainPage): use constant for header text in user projects section
The changes in headerComponent remove unused imports and update the header text to use a constant instead of a hardcoded string. The constant is added in constants.tsx. The MainPage component is updated to use the constant for the header text in the user projects section. This improves code readability and maintainability.
🎨 style(headerComponent): remove unused imports and update header text to use constant
 feat(constants.tsx): add constant for header text in user projects section
2023-06-16 18:39:06 -03:00
Gabriel Luiz Freitas Almeida
bf621c78b4 🐛 fix(__main__.py): fix issue where app was not serving the index.html file when a 404 error occurred
 feat(main.py): remove static_path argument from create_app function
The fix to the issue where the app was not serving the index.html file when a 404 error occurred was done by adding an exception handler to the app that returns the index.html file when a 404 error occurs. The create_app function was modified to remove the static_path argument as it was not being used in the function.
2023-06-16 18:36:06 -03:00
anovazzi1
e1e5fb14c9 refactor(typesContext.tsx): reverse the order of keys in the types object to avoid overlap with tool world
The keys in the types object were reversed to avoid overlap with the tool world. This was done by modifying the reduce function in the TypesProvider component.
2023-06-16 18:20:06 -03:00
anovazzi1
20b19967da Merge branch 'db' of personal:logspace-ai/langflow into db 2023-06-16 17:52:43 -03:00
anovazzi1
ad6756c06c refactor(chatModal): replace react-icons with lucide-react icons for better performance and smaller bundle size 2023-06-16 17:52:21 -03:00
Gabriel Luiz Freitas Almeida
319a57eb19 🐛 fix(__main__.py): check if port is in use and get a free port if it is
 feat(__main__.py): add support for health check endpoint and use it to check server status
The `serve` function now checks if the specified port is in use and gets a free port if it is. This ensures that the server can run on a free port and avoids conflicts with other running applications. The `serve` function also now uses a health check endpoint to check the status of the server. The `setup_static_files` function now takes a `Path` object instead of a string for the static files directory. The `create_app` function now takes a `Path` object instead of a string for the static files directory.
2023-06-16 17:39:52 -03:00
Gabriel Luiz Freitas Almeida
0686626303 Merge branch 'db' of https://github.com/logspace-ai/langflow into db 2023-06-16 17:25:20 -03:00
Rodrigo Nader
73ee476663 Merge branch 'db' of https://github.com/logspace-ai/langflow into db 2023-06-16 17:23:56 -03:00
Rodrigo Nader
c9c226f464 Refactor the search placeholder and update the collections description
Update the search placeholder to be more general, from 'Search Nodes' to 'Search', in the extra sidebar component, and update the collection description from 'Download or upload your complete project collection' to 'Download or upload your collection' in the main page.
2023-06-16 17:23:29 -03:00
Gabriel Luiz Freitas Almeida
4d209ca21f 🐛 fix(constants.tsx): correct typo in API URL path
The API URL path was incorrectly spelled as "/ap1/v1/predict" instead of "/api/v1/predict". This commit fixes the typo to ensure that the correct API endpoint is used.
2023-06-16 17:23:01 -03:00
gustavoschaedler
69944b6e46 Merge branch 'db' of github.com:logspace-ai/langflow into db 2023-06-16 21:19:55 +01:00
Rodrigo Nader
39707f9f80 Refactor error message for build trigger component
Changed the error message in the build trigger component to clarify which components need to be checked before retrying. Updated the list to include instructions on how to inspect the component status.
2023-06-16 17:19:49 -03:00
gustavoschaedler
78588ba260 Tests fix 2023-06-16 21:19:29 +01:00
anovazzi1
cad24f1f88 fix(chatComponent): add isBuilt dependency to useEffect hook to avoid stale closure and improve performance 2023-06-16 17:16:36 -03:00
Gabriel Luiz Freitas Almeida
b476d0dd74 🐛 fix(endpoints.py): add try-except block when processing tweaks to catch and log exceptions
🐛 fix(process.py): fix KeyError when processing tweaks on graph_data with missing "data" key
The try-except block added in endpoints.py catches any exceptions that occur when processing tweaks and logs them to the logger. This helps with debugging and identifying issues with the processing of tweaks. In process.py, a KeyError was fixed by checking if the "data" key exists in the graph_data dictionary before accessing the "nodes" key.
2023-06-16 16:35:49 -03:00
anovazzi1
eed33f490c feat(App.tsx, FlowPage/index.tsx): add version number to the footer of the app to show the current version of LangFlow
refactor(App.tsx): remove redundant code that initializes the version state variable and fetches the version number from the API in FlowPage component instead
2023-06-16 16:27:13 -03:00
anovazzi1
ecaa0613d5 Merge branch 'db' of personal:logspace-ai/langflow into db 2023-06-16 16:23:46 -03:00
anovazzi1
036118011b comment projects on dropdown component 2023-06-16 16:23:35 -03:00
gustavoschaedler
13d52e4987 Tests fix 2023-06-16 20:22:45 +01:00
Gabriel Luiz Freitas Almeida
46c998be33 🎨 style(menuBar): refactor menu bar to improve readability and add new option
The menu bar has been refactored to improve readability and make it easier to add new options in the future. A new option has been added to create a new flow. The "Edit" label has been changed to "Options" to better reflect the purpose of the dropdown menu.
2023-06-16 16:10:54 -03:00
anovazzi1
31ee0c7609 fix(exportModal): set initial state of checked to false instead of true
refactor(utils.ts): remove console.log statement and simplify if statement in removeApiKeys function
2023-06-16 16:05:19 -03:00
anovazzi1
8fd94f0298 Merge branch 'db' of personal:logspace-ai/langflow into db 2023-06-16 15:54:30 -03:00
anovazzi1
cb5b58b7e4 update remove api key function 2023-06-16 15:54:25 -03:00
gustavoschaedler
ceb6fda4c6 Tests fix 2023-06-16 19:47:35 +01:00