From 609744332d16e64c05f640dbc60436aed528f8c2 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 28 Feb 2024 09:57:41 -0300 Subject: [PATCH 1/3] Add linting and testing workflows for backend code (#1478) * Add paths to trigger workflow on specific file changes * Add linting workflow for backend code --- .github/workflows/lint.yml | 8 ++++++++ .github/workflows/test.yml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 64d06a313..d4eaafb95 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,15 @@ name: lint on: push: branches: [main] + paths: + - "poetry.lock" + - "pyproject.toml" + - "src/backend/**" pull_request: + paths: + - "poetry.lock" + - "pyproject.toml" + - "src/backend/**" env: POETRY_VERSION: "1.7.0" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93ec5bf7e..10ab9b324 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,8 +3,16 @@ name: test on: push: branches: [main] + paths: + - "poetry.lock" + - "pyproject.toml" + - "src/backend/**" pull_request: branches: [dev] + paths: + - "poetry.lock" + - "pyproject.toml" + - "src/backend/**" env: POETRY_VERSION: "1.5.0" From 43b3b082a5b9c58ae19647f4348e6bdc6938839e Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa <72977554+Cristhianzl@users.noreply.github.com> Date: Wed, 28 Feb 2024 10:01:09 -0300 Subject: [PATCH 2/3] Fix vectara resolution error (#1475) * add new vectara icon * remove console.log --- .../src/CustomNodes/GenericNode/index.tsx | 2 +- .../src/icons/VectaraIcon/Vectara.jsx | 1153 ++--------------- .../src/icons/VectaraIcon/vectara.svg | 332 ++--- 3 files changed, 162 insertions(+), 1325 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 2ddd49b8f..0d344bd65 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -186,7 +186,7 @@ export default function GenericNode({
{iconNodeRender()} diff --git a/src/frontend/src/icons/VectaraIcon/Vectara.jsx b/src/frontend/src/icons/VectaraIcon/Vectara.jsx index 0566f82eb..378dc6964 100644 --- a/src/frontend/src/icons/VectaraIcon/Vectara.jsx +++ b/src/frontend/src/icons/VectaraIcon/Vectara.jsx @@ -1,1074 +1,83 @@ -const SvgVectara = (props) => ( - <> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +export const SvgVectara = (props) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); export default SvgVectara; diff --git a/src/frontend/src/icons/VectaraIcon/vectara.svg b/src/frontend/src/icons/VectaraIcon/vectara.svg index 1faafd320..c111a3aeb 100644 --- a/src/frontend/src/icons/VectaraIcon/vectara.svg +++ b/src/frontend/src/icons/VectaraIcon/vectara.svg @@ -1,252 +1,80 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 109b5c8690b36ebb5c92e44d7ca913bbec1e01aa Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 28 Feb 2024 10:02:00 -0300 Subject: [PATCH 3/3] Remove unused chat and prompt classes (#1474) --- src/backend/langflow/utils/chat.py | 34 ---------------- src/backend/langflow/utils/prompt.py | 58 ---------------------------- 2 files changed, 92 deletions(-) delete mode 100644 src/backend/langflow/utils/chat.py delete mode 100644 src/backend/langflow/utils/prompt.py diff --git a/src/backend/langflow/utils/chat.py b/src/backend/langflow/utils/chat.py deleted file mode 100644 index e1621bdab..000000000 --- a/src/backend/langflow/utils/chat.py +++ /dev/null @@ -1,34 +0,0 @@ -from typing import Any, Callable, Optional, Union - -from langchain_core.prompts import PromptTemplate as LCPromptTemplate -from langflow.utils.prompt import GenericPromptTemplate -from llama_index.prompts import PromptTemplate as LIPromptTemplate - -PromptTemplate = Union[LCPromptTemplate, LIPromptTemplate] - - -class ChatDefinition: - def __init__( - self, - func: Callable, - inputs: list[str], - output_key: Optional[str] = None, - prompt_template: Optional[PromptTemplate] = None, - ): - self.func = func - self.input_keys = inputs - self.output_key = output_key - self.prompt_template = prompt_template - - @classmethod - def from_prompt_template(cls, prompt_template: PromptTemplate, func: Callable, output_key: Optional[str] = None): - prompt = GenericPromptTemplate(prompt_template) - return cls( - func=func, - inputs=prompt.input_keys, - output_key=output_key, - prompt_template=prompt_template, - ) - - def __call__(self, inputs: dict, callbacks: Optional[Any] = None) -> dict: - return self.func(inputs, callbacks) diff --git a/src/backend/langflow/utils/prompt.py b/src/backend/langflow/utils/prompt.py deleted file mode 100644 index 871193f45..000000000 --- a/src/backend/langflow/utils/prompt.py +++ /dev/null @@ -1,58 +0,0 @@ -from typing import Any, Union - -from langchain_core.prompts import PromptTemplate as LCPromptTemplate -from llama_index.prompts import PromptTemplate as LIPromptTemplate - -PromptTemplateTypes = Union[LCPromptTemplate, LIPromptTemplate] - - -class GenericPromptTemplate: - def __init__(self, prompt_template: PromptTemplateTypes): - object.__setattr__(self, "prompt_template", prompt_template) - - @property - def input_keys(self): - prompt_template = object.__getattribute__(self, "prompt_template") - if isinstance(prompt_template, LCPromptTemplate): - return prompt_template.input_variables - elif isinstance(prompt_template, LIPromptTemplate): - return prompt_template.template_vars - else: - raise TypeError(f"Unknown prompt template type {type(prompt_template)}") - - def to_lc_prompt(self): - prompt_template = object.__getattribute__(self, "prompt_template") - if isinstance(prompt_template, LCPromptTemplate): - return prompt_template - elif isinstance(prompt_template, LIPromptTemplate): - return LCPromptTemplate.from_template(prompt_template.get_template()) - else: - raise TypeError(f"Unknown prompt template type {type(prompt_template)}") - - def to_li_prompt(self): - prompt_template = object.__getattribute__(self, "prompt_template") - if isinstance(prompt_template, LIPromptTemplate): - return prompt_template - elif isinstance(prompt_template, LCPromptTemplate): - return LIPromptTemplate(template=prompt_template.template) - else: - raise TypeError(f"Unknown prompt template type {type(prompt_template)}") - - def __or__(self, other): - prompt_template = object.__getattribute__(self, "prompt_template") - if isinstance(prompt_template, LIPromptTemplate): - return self.to_lc_prompt() | other - else: - raise TypeError(f"Unknown prompt template type {type(other)}") - - def __getattribute__(self, name: str) -> Any: - if name in { - "input_keys", - "to_lc_prompt", - "to_li_prompt", - "__or__", - "prompt_template", - }: - return object.__getattribute__(self, name) - prompt_template = object.__getattribute__(self, "prompt_template") - return getattr(prompt_template, name)