Merge branch 'dev' of github.com:logspace-ai/langflow into dev

This commit is contained in:
cristhianzl 2023-12-11 16:54:02 -03:00
commit e7530a4ca5
3 changed files with 14 additions and 9 deletions

View file

@ -1,12 +1,12 @@
from typing import Optional, Union from typing import Optional, Union
from langflow import CustomComponent
from langchain.vectorstores import Chroma
from langchain.schema import Document
from langchain.vectorstores.base import VectorStore
from langchain.schema import BaseRetriever
from langchain.embeddings.base import Embeddings
import chromadb # type: ignore import chromadb # type: ignore
from langchain.embeddings.base import Embeddings
from langchain.schema import BaseRetriever, Document
from langchain.vectorstores import Chroma
from langchain.vectorstores.base import VectorStore
from langflow import CustomComponent
class ChromaComponent(CustomComponent): class ChromaComponent(CustomComponent):
@ -95,6 +95,10 @@ class ChromaComponent(CustomComponent):
# If documents, then we need to create a Chroma instance using .from_documents # If documents, then we need to create a Chroma instance using .from_documents
if documents is not None and embedding is not None: if documents is not None and embedding is not None:
if len(documents) == 0:
raise ValueError(
"If documents are provided, there must be at" " least one document. Got {len(documents)}."
)
return Chroma.from_documents( return Chroma.from_documents(
documents=documents, # type: ignore documents=documents, # type: ignore
persist_directory=persist_directory if persist else None, persist_directory=persist_directory if persist else None,

View file

@ -3,12 +3,13 @@ import inspect
import types import types
from typing import TYPE_CHECKING, Any, Coroutine, Dict, List, Optional from typing import TYPE_CHECKING, Any, Coroutine, Dict, List, Optional
from loguru import logger
from langflow.graph.utils import UnbuiltObject from langflow.graph.utils import UnbuiltObject
from langflow.interface.initialize import loading from langflow.interface.initialize import loading
from langflow.interface.listing import lazy_load_dict from langflow.interface.listing import lazy_load_dict
from langflow.utils.constants import DIRECT_TYPES from langflow.utils.constants import DIRECT_TYPES
from langflow.utils.util import sync_to_async from langflow.utils.util import sync_to_async
from loguru import logger
if TYPE_CHECKING: if TYPE_CHECKING:
from langflow.graph.edge.base import Edge from langflow.graph.edge.base import Edge
@ -190,7 +191,7 @@ class Vertex:
params[key] = float(val) params[key] = float(val)
except ValueError: except ValueError:
params[key] = val params[key] = val
else: elif val is not None and val != "":
params[key] = val params[key] = val
if not value.get("required") and params.get(key) is None: if not value.get("required") and params.get(key) is None:

View file

@ -208,7 +208,7 @@ export default function Page({
return () => { return () => {
clearInterval(interval); clearInterval(interval);
}; };
}, []); }, [flow, flow.data]);
const onEdgesChangeMod = useCallback( const onEdgesChangeMod = useCallback(
(change: EdgeChange[]) => { (change: EdgeChange[]) => {