🐛 fix(base.py): add type hint for 'template' attribute in FrontendNodeRequest class
🐛 fix(utils.py): add input validation for 'chat_inputs.message' to prevent errors when no message is provided 🐛 fix(loading.py): add type hint for 'format_kwargs' variable in instantiate_prompt function 🐛 fix(base.py): add type hint for 'inputs' parameter in get_result_and_steps function The changes in `base.py` and `utils.py` are bug fixes that address potential issues in the code. The type hint for the 'template' attribute in the `FrontendNodeRequest` class is added to improve code clarity and maintainability. The input validation for 'chat_inputs.message' in the `process_graph` function ensures that an error is raised when no message is provided, preventing potential issues down the line. In `loading.py`, the type hint for the 'format_kwargs' variable in the `instantiate_prompt` function improves type safety. Lastly, in `base.py`, the type hint for the 'inputs' parameter in the `get_result_and_steps` function ensures proper type checking.
This commit is contained in:
parent
4e078d7de5
commit
6f9520d620
4 changed files with 8 additions and 3 deletions
|
|
@ -14,7 +14,7 @@ class Code(BaseModel):
|
|||
|
||||
|
||||
class FrontendNodeRequest(FrontendNode):
|
||||
template: dict
|
||||
template: dict # type: ignore
|
||||
|
||||
|
||||
class ValidatePromptRequest(BaseModel):
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ async def process_graph(
|
|||
|
||||
# Generate result and thought
|
||||
try:
|
||||
if not chat_inputs.message:
|
||||
logger.debug("No message provided")
|
||||
raise ValueError("No message provided")
|
||||
|
||||
logger.debug("Generating result and thought")
|
||||
result, intermediate_steps = await get_result_and_steps(
|
||||
langchain_object, chat_inputs.message, websocket=websocket
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ def instantiate_prompt(node_type, class_object, params: Dict):
|
|||
|
||||
prompt = class_object(**params)
|
||||
|
||||
format_kwargs = {}
|
||||
format_kwargs: Dict[str, Any] = {}
|
||||
for input_variable in prompt.input_variables:
|
||||
if input_variable in params:
|
||||
variable = params[input_variable]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from typing import Union
|
||||
from langflow.api.v1.callback import (
|
||||
AsyncStreamingLLMCallbackHandler,
|
||||
StreamingLLMCallbackHandler,
|
||||
|
|
@ -6,7 +7,7 @@ from langflow.processing.process import fix_memory_inputs, format_actions
|
|||
from langflow.utils.logger import logger
|
||||
|
||||
|
||||
async def get_result_and_steps(langchain_object, inputs: dict, **kwargs):
|
||||
async def get_result_and_steps(langchain_object, inputs: Union[dict, str], **kwargs):
|
||||
"""Get result and thought from extracted json"""
|
||||
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue