parent
140cf890e3
commit
f96f2eaf8a
67 changed files with 421 additions and 361 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import pytest
|
||||
from langflow.schema.message import Message
|
||||
|
||||
from tests.api_keys import get_openai_api_key
|
||||
from tests.integration.utils import download_flow_from_github, run_json_flow
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from langchain_core.documents import Document
|
|||
from langflow.components.embeddings import OpenAIEmbeddingsComponent
|
||||
from langflow.components.vectorstores import AstraVectorStoreComponent
|
||||
from langflow.schema.data import Data
|
||||
|
||||
from tests.api_keys import get_astradb_api_endpoint, get_astradb_application_token, get_openai_api_key
|
||||
from tests.integration.components.mock_components import TextToData
|
||||
from tests.integration.utils import ComponentInputHandle, run_single_component
|
||||
|
|
@ -27,7 +28,7 @@ ALL_COLLECTIONS = [
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def astradb_client(request):
|
||||
def astradb_client():
|
||||
client = AstraDB(api_endpoint=get_astradb_api_endpoint(), token=get_astradb_application_token())
|
||||
yield client
|
||||
for collection in ALL_COLLECTIONS:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import pytest
|
|||
from langflow.components.helpers.ParseJSONData import ParseJSONDataComponent
|
||||
from langflow.components.inputs import ChatInput
|
||||
from langflow.schema import Data
|
||||
|
||||
from tests.integration.components.mock_components import TextToData
|
||||
from tests.integration.utils import ComponentInputHandle, run_single_component
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import pytest
|
|||
from langflow.components.inputs import ChatInput
|
||||
from langflow.memory import get_messages
|
||||
from langflow.schema.message import Message
|
||||
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
from langflow.components.inputs import TextInputComponent
|
||||
from langflow.schema.message import Message
|
||||
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import pytest
|
|||
from langflow.components.models.OpenAIModel import OpenAIModelComponent
|
||||
from langflow.components.output_parsers.OutputParser import OutputParserComponent
|
||||
from langflow.components.prompts.Prompt import PromptComponent
|
||||
|
||||
from tests.integration.utils import ComponentInputHandle, run_single_component
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import pytest
|
|||
from langflow.components.outputs import ChatOutput
|
||||
from langflow.memory import get_messages
|
||||
from langflow.schema.message import Message
|
||||
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
from langflow.components.outputs import TextOutputComponent
|
||||
from langflow.schema.message import Message
|
||||
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
from langflow.components.prompts import PromptComponent
|
||||
from langflow.schema.message import Message
|
||||
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,18 +4,19 @@ from langflow.components.outputs import ChatOutput
|
|||
from langflow.components.prompts import PromptComponent
|
||||
from langflow.graph import Graph
|
||||
from langflow.schema.message import Message
|
||||
|
||||
from tests.integration.utils import run_flow
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_simple_no_llm():
|
||||
graph = Graph()
|
||||
input = graph.add_component(ChatInput())
|
||||
output = graph.add_component(ChatOutput())
|
||||
flow_input = graph.add_component(ChatInput())
|
||||
flow_output = graph.add_component(ChatOutput())
|
||||
component = PromptComponent(template="This is the message: {var1}", var1="")
|
||||
prompt = graph.add_component(component)
|
||||
graph.add_component_edge(input, ("message", "var1"), prompt)
|
||||
graph.add_component_edge(prompt, ("prompt", "input_value"), output)
|
||||
graph.add_component_edge(flow_input, ("message", "var1"), prompt)
|
||||
graph.add_component_edge(prompt, ("prompt", "input_value"), flow_output)
|
||||
outputs = await run_flow(graph, run_input="hello!")
|
||||
assert isinstance(outputs["message"], Message)
|
||||
assert outputs["message"].text == "This is the message: hello!"
|
||||
|
|
|
|||
|
|
@ -12,26 +12,26 @@ from langflow.graph import Graph
|
|||
from langflow.processing.process import run_graph_internal
|
||||
|
||||
|
||||
def check_env_vars(*vars):
|
||||
def check_env_vars(*env_vars):
|
||||
"""Check if all specified environment variables are set.
|
||||
|
||||
Args:
|
||||
*vars (str): The environment variables to check.
|
||||
*env_vars (str): The environment variables to check.
|
||||
|
||||
Returns:
|
||||
bool: True if all environment variables are set, False otherwise.
|
||||
"""
|
||||
return all(os.getenv(var) for var in vars)
|
||||
return all(os.getenv(var) for var in env_vars)
|
||||
|
||||
|
||||
def valid_nvidia_vectorize_region(api_endpoint: str) -> bool:
|
||||
"""Check if the specified region is valid.
|
||||
|
||||
Args:
|
||||
region (str): The region to check.
|
||||
api_endpoint: The API endpoint to check.
|
||||
|
||||
Returns:
|
||||
bool: True if the region is contains hosted nvidia models, False otherwise.
|
||||
True if the region contains hosted nvidia models, False otherwise.
|
||||
"""
|
||||
parsed_endpoint = parse_api_endpoint(api_endpoint)
|
||||
if not parsed_endpoint:
|
||||
|
|
@ -63,12 +63,12 @@ class JSONFlow:
|
|||
json: dict
|
||||
|
||||
def get_components_by_type(self, component_type):
|
||||
result = []
|
||||
for node in self.json["data"]["nodes"]:
|
||||
if node["data"]["type"] == component_type:
|
||||
result.append(node["id"])
|
||||
result = [node["id"] for node in self.json["data"]["nodes"] if node["data"]["type"] == component_type]
|
||||
if not result:
|
||||
msg = f"Component of type {component_type} not found, available types: {', '.join({node['data']['type'] for node in self.json['data']['nodes']})}"
|
||||
msg = (
|
||||
f"Component of type {component_type} not found, "
|
||||
f"available types: {', '.join({node['data']['type'] for node in self.json['data']['nodes']})}"
|
||||
)
|
||||
raise ValueError(msg)
|
||||
return result
|
||||
|
||||
|
|
@ -97,7 +97,8 @@ class JSONFlow:
|
|||
|
||||
def download_flow_from_github(name: str, version: str) -> JSONFlow:
|
||||
response = requests.get(
|
||||
f"https://raw.githubusercontent.com/langflow-ai/langflow/v{version}/src/backend/base/langflow/initial_setup/starter_projects/{name}.json"
|
||||
f"https://raw.githubusercontent.com/langflow-ai/langflow/v{version}/src/backend/base/langflow/initial_setup/starter_projects/{name}.json",
|
||||
timeout=10,
|
||||
)
|
||||
response.raise_for_status()
|
||||
as_json = response.json()
|
||||
|
|
@ -151,7 +152,7 @@ async def run_single_component(
|
|||
raw_inputs[key] = value
|
||||
if isinstance(value, Component):
|
||||
msg = "Component inputs must be wrapped in ComponentInputHandle"
|
||||
raise ValueError(msg)
|
||||
raise TypeError(msg)
|
||||
component = clazz(**raw_inputs, _user_id=user_id)
|
||||
component_id = graph.add_component(component)
|
||||
if inputs:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue