Skip to content

Commit

Permalink
Merge branch 'main' into refactor-read-flows
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielluiz authored Dec 19, 2024
2 parents 2009313 + 81da524 commit bfd8de0
Show file tree
Hide file tree
Showing 64 changed files with 1,703 additions and 3,063 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
name: Should Run CI
runs-on: ubuntu-latest
outputs:
should-run-ci: ${{ (needs.check-nightly-status.outputs.should-proceed == 'true') && ((contains( github.event.pull_request.labels.*.name, 'lgtm') && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || github.event_name == 'merge_group')) }}
should-run-ci: ${{ (needs.check-nightly-status.outputs.should-proceed == 'true' || github.event_name == 'workflow_dispatch') && ((contains( github.event.pull_request.labels.*.name, 'lgtm') && github.event.pull_request.draft == false) || (github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || github.event_name == 'merge_group')) }}
steps:
# Do anything just to make the job run
- run: echo "Debug CI Condition"
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/codeflash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Codeflash

on:
pull_request:
paths:
- "src/backend/base/langflow/**"
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
optimize:
name: Optimize new Python code in this PR
if: ${{ github.actor != 'codeflash-ai[bot]' }}
runs-on: ubuntu-latest
env:
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
CODEFLASH_PR_NUMBER: ${{ github.event.number }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v4
with:
enable-cache: true
python-version: "3.12"
- run: uv sync --extra dev
- name: Run Codeflash Optimizer
working-directory: ./src/backend/base
run: uv run codeflash
- name: Minimize uv cache
run: uv cache prune --ci
16 changes: 7 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ repos:
args:
- --fix=lf
- id: trailing-whitespace
- repo: local
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.3
hooks:
- id: ruff-check
- id: ruff
name: ruff check
language: system
entry: bash -c "uv run ruff check"
types: [file, python]
types_or: [python, pyi]
args: [--fix]
- id: ruff-format
name: ruff format
language: system
entry: bash -c "uv run ruff format"
types: [file, python]
types_or: [python, pyi]
args: [--config, pyproject.toml]
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ all: help
######################

# Some directories may be mount points as in devcontainer, so we need to clear their
# contents rather than remove the entire directory. But we must also be mindful that
# contents rather than remove the entire directory. But we must also be mindful that
# we are not running in a devcontainer, so need to ensure the directories exist.
# See https://code.visualstudio.com/remote/advancedcontainers/improve-performance
CLEAR_DIRS = $(foreach dir,$1,$(shell mkdir -p $(dir) && find $(dir) -mindepth 1 -delete))
Expand Down Expand Up @@ -309,7 +309,6 @@ endif

build_langflow_base:
cd src/backend/base && uv build $(args)
$(call CLEAR_DIRS,src/backend/base/langflow/frontend)

build_langflow_backup:
uv lock && uv build
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ dev-dependencies = [
"pytest-codspeed>=3.0.0",
"blockbuster>=1.5.2,<1.6",
"types-aiofiles>=24.1.0.20240626",
"codeflash>=0.8.4",
]


Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/api/v1/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ async def custom_component_update(
load_from_db_fields = [
field_name
for field_name, field_dict in template.items()
if isinstance(field_dict, dict) and field_dict.get("load_from_db")
if isinstance(field_dict, dict) and field_dict.get("load_from_db") and field_dict.get("value")
]
params = await update_params_with_load_from_db_fields(cc_instance, params, load_from_db_fields)
cc_instance.set_attributes(params)
Expand Down
4 changes: 2 additions & 2 deletions src/backend/base/langflow/api/v1/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from langflow.api.utils import CurrentActiveUser, DbSession
from langflow.services.database.models.variable import VariableCreate, VariableRead, VariableUpdate
from langflow.services.deps import get_variable_service
from langflow.services.variable.constants import GENERIC_TYPE
from langflow.services.variable.constants import CREDENTIAL_TYPE
from langflow.services.variable.service import DatabaseVariableService

router = APIRouter(prefix="/variables", tags=["Variables"])
Expand Down Expand Up @@ -38,7 +38,7 @@ async def create_variable(
name=variable.name,
value=variable.value,
default_fields=variable.default_fields or [],
type_=variable.type or GENERIC_TYPE,
type_=variable.type or CREDENTIAL_TYPE,
session=session,
)
except Exception as e:
Expand Down
23 changes: 17 additions & 6 deletions src/backend/base/langflow/base/vectorstores/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
from functools import wraps
from typing import TYPE_CHECKING

from loguru import logger

from langflow.custom import Component
from langflow.field_typing import Text, VectorStore
from langflow.helpers.data import docs_to_data
from langflow.io import Output
from langflow.io import DataInput, MultilineInput, Output
from langflow.schema import Data

if TYPE_CHECKING:
Expand Down Expand Up @@ -53,6 +51,19 @@ def __init_subclass__(cls, **kwargs):
raise TypeError(msg)

trace_type = "retriever"

inputs = [
MultilineInput(
name="search_query",
display_name="Search Query",
tool_mode=True,
),
DataInput(
name="ingest_data",
display_name="Ingest Data",
),
]

outputs = [
Output(
display_name="Search Results",
Expand Down Expand Up @@ -122,9 +133,9 @@ def search_documents(self) -> list[Data]:
vector_store = self.build_vector_store()
self._cached_vector_store = vector_store

logger.debug(f"Search input: {search_query}")
logger.debug(f"Search type: {self.search_type}")
logger.debug(f"Number of results: {self.number_of_results}")
self.log(f"Search input: {search_query}")
self.log(f"Search type: {self.search_type}")
self.log(f"Number of results: {self.number_of_results}")

search_results = self.search_with_vector_store(
search_query, self.search_type, vector_store, k=self.number_of_results
Expand Down
3 changes: 3 additions & 0 deletions src/backend/base/langflow/components/langwatch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .langwatch import LangWatchComponent

__all__ = ["LangWatchComponent"]
Loading

0 comments on commit bfd8de0

Please sign in to comment.