Skip to content

Commit

Permalink
Merge branch 'main' into tighten-up-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
phact authored Nov 22, 2024
2 parents 6693d44 + f440552 commit 39487ee
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .character import CharacterTextSplitterComponent
from .conversation import ConversationChainComponent
from .csv import CSVAgentComponent
from .fake_embeddings import FakeEmbeddingsComponent
from .html_link_extractor import HtmlLinkExtractorComponent
from .json import JsonAgentComponent
from .json_document_builder import JSONDocumentBuilder
Expand Down Expand Up @@ -30,6 +31,7 @@
"CharacterTextSplitterComponent",
"ConversationChainComponent",
"CSVAgentComponent",
"FakeEmbeddingsComponent",
"HtmlLinkExtractorComponent",
"JSONDocumentBuilder",
"JsonAgentComponent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class CSVAgentComponent(LCAgentComponent):
Output(display_name="Agent", name="agent", method="build_agent"),
]

def _path(self) -> str:
if isinstance(self.path, Message) and isinstance(self.path.text, str):
return self.path.text
return self.path

def build_agent_response(self) -> Message:
agent_kwargs = {
"verbose": self.verbose,
Expand All @@ -59,7 +64,7 @@ def build_agent_response(self) -> Message:

agent_csv = create_csv_agent(
llm=self.llm,
path=self.path,
path=self._path(),
agent_type=self.agent_type,
handle_parsing_errors=self.handle_parsing_errors,
**agent_kwargs,
Expand All @@ -76,7 +81,7 @@ def build_agent(self) -> AgentExecutor:

agent_csv = create_csv_agent(
llm=self.llm,
path=self.path,
path=self._path(),
agent_type=self.agent_type,
handle_parsing_errors=self.handle_parsing_errors,
**agent_kwargs,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from langchain_community.embeddings import FakeEmbeddings

from langflow.base.embeddings.model import LCEmbeddingsModel
from langflow.field_typing import Embeddings
from langflow.io import IntInput


class FakeEmbeddingsComponent(LCEmbeddingsModel):
display_name = "Fake Embeddings"
description = "Generate fake embeddings, useful for initial testing and connecting components."
icon = "LangChain"
name = "LangChainFakeEmbeddings"

inputs = [
IntInput(
name="dimensions",
display_name="Dimensions",
info="The number of dimensions the resulting output embeddings should have.",
value=5,
),
]

def build_embeddings(self) -> Embeddings:
return FakeEmbeddings(
size=self.dimensions or 5,
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const useGetBasicExamplesQuery: useQueryFunctionType<

const queryResult = query(["useGetBasicExamplesQuery"], responseFn, {
...options,
retry: 3,
});

return queryResult;
Expand Down
15 changes: 10 additions & 5 deletions src/frontend/src/pages/AppInitPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ export function AppInitPage() {
useGetConfig({ enabled: isFetched });
const { isFetched: typesLoaded } = useGetTypes({ enabled: isFetched });
useGetGlobalVariables({ enabled: typesLoaded });
useGetBasicExamplesQuery({ enabled: typesLoaded });
useGetTagsQuery({ enabled: typesLoaded });

useGetFoldersQuery({ enabled: typesLoaded });
useGetFoldersQuery({
enabled: typesLoaded,
});
const { isFetched: isExamplesFetched } = useGetBasicExamplesQuery({
enabled: typesLoaded,
});

useEffect(() => {
if (isFetched) {
Expand All @@ -49,11 +52,13 @@ export function AppInitPage() {
//need parent component with width and height
<>
{isLoaded ? (
(isLoading || !isFetched || !typesLoaded) && <LoadingPage overlay />
(isLoading || !isFetched || !isExamplesFetched || !typesLoaded) && (
<LoadingPage overlay />
)
) : (
<CustomLoadingPage />
)}
{isFetched && typesLoaded && <Outlet />}
{isFetched && isExamplesFetched && typesLoaded && <Outlet />}
</>
);
}

0 comments on commit 39487ee

Please sign in to comment.