-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RC1 : Python API : Circular API import #2308
Comments
To resolve the circular import issue when calling send a message using the 1.0.0.RC1 build of the Python API, you can use the Here's the relevant part of the code that handles this: from typing import Any
from .constants import (
AgentExecutor,
BaseChatMemory,
BaseLanguageModel,
BaseLLM,
BaseLoader,
BaseMemory,
BaseOutputParser,
BasePromptTemplate,
BaseRetriever,
Callable,
Chain,
ChatPromptTemplate,
Data,
Document,
Embeddings,
NestedDict,
Object,
Prompt,
PromptTemplate,
TextSplitter,
Tool,
VectorStore,
)
from .range_spec import RangeSpec
def _import_template_field():
from langflow.template.field.base import TemplateField
return TemplateField
def __getattr__(name: str) -> Any:
# This is to avoid circular imports
if name == "TemplateField":
return _import_template_field()
elif name == "RangeSpec":
return RangeSpec
# The other names should work as if they were imported from constants
# Import the constants module langflow.field_typing.constants
from . import constants
return getattr(constants, name)
__all__ = [
"NestedDict",
"Data",
"Tool",
"PromptTemplate",
"Chain",
"BaseChatMemory",
"BaseLLM",
"BaseLanguageModel",
"BaseLoader",
"BaseMemory",
"BaseOutputParser",
"BaseRetriever",
"VectorStore",
"Embeddings",
"TextSplitter",
"Document",
"AgentExecutor",
"Object",
"Callable",
"BasePromptTemplate",
"ChatPromptTemplate",
"Prompt",
"RangeSpec",
"TemplateField",
] This code ensures that the |
This has been fixed in the latest releases. 1.0.5 doesn't have the problem |
Hello, I am currently encountering this issue while using the latest release. Are there any fixes for this? Many thanks. |
Also experiencing this issue with 1.0.5. |
@yuchieh8968 @Nitewriter you need to remove and re-add all the broken components after the upgrade |
@nicoloboschi are you referring to components in the flow or python packages? I'm using the from langflow.load import run_flow_from_json
TWEAKS = {
"Memory-hzITR": {},
"Prompt-viXZL": {},
"ChatInput-tgsUe": {},
"OpenAIModel-J2hiT": {},
"ChatOutput-LH91h": {}
}
result = run_flow_from_json(flow="Memory Chatbot.json",
input_value="message",
fallback_to_env_vars=True, # False by default
tweaks=TWEAKS) |
OK it wasn't clear you were using |
@nicoloboschi Oh shoot, ok I think I'm connecting the dots. The components have the imports that are causing the cycle and the template may have outdated components that I used as an example. I'll try recreating that flow from a blank template. |
@nicoloboschi Ok, I did try with a clean start on the flow. I'm still seeing the cycle issue. Let me know if there is anything I can provide to help track down the issue. |
Hi there :
Im using the 1.0.0.RC1 build : if I make a call to send a message I get :
2024-06-24 14:17:20 - Error running graph: Error building Component Empty Prompt:
cannot import name 'process_prompt_template' from partially initialized module 'langflow.base.prompts.api_utils' (most likely due to a circular import) (/home/koni/.local/lib/python3.10/site-packages/langflow/base/prompts/api_utils.py)
Thanks,
Arron
The text was updated successfully, but these errors were encountered: