Merge remote-tracking branch 'origin/form_io' into python_custom_node_component

This commit is contained in:
gustavoschaedler 2023-06-28 21:05:35 +01:00
commit 78fd021f23
4 changed files with 27 additions and 4 deletions

View file

@ -128,6 +128,8 @@ async def stream_build(flow_id: str):
yield str(StreamData(event="message", data=input_keys_response))
chat_manager.set_cache(flow_id, langchain_object)
# We need to reset the chat history
chat_manager.chat_history.empty_history(flow_id)
except Exception as exc:
logger.error("Error while building the flow: %s", exc)
yield str(StreamData(event="error", data={"error": str(exc)}))

View file

@ -61,6 +61,11 @@ def post_validate_prompt(prompt: ValidatePromptRequest):
logger.exception(exc)
raise HTTPException(status_code=500, detail=str(exc)) from exc
# Now we will set the field "input_variables" to the new list of variables
# if it exists
if "input_variables" in prompt.frontend_node.template:
prompt.frontend_node.template["input_variables"]["value"] = input_variables
return PromptValidationResponse(
input_variables=input_variables,
frontend_node=prompt.frontend_node,

View file

@ -110,7 +110,21 @@ def instantiate_prompt(node_type, class_object, params):
if node_type == "ChatPromptTemplate":
return class_object.from_messages(**params)
return class_object(**params)
prompt = class_object(**params)
# Now we go through input_variables
# Check if they are in params, if so
# get their values and set them
format_kwargs = {}
for input_variable in prompt.input_variables:
if input_variable in params:
input_value = params[input_variable]
format_kwargs[input_variable] = input_value
if format_kwargs:
prompt = prompt.partial(**format_kwargs)
return prompt
def instantiate_tool(node_type, class_object, params):

View file

@ -155,7 +155,7 @@ export default function FormModal({
let newChatHistory: ChatMessageType[] = [];
data.forEach(
(chatItem: {
intermediate_steps?: "string";
intermediate_steps?: string;
is_bot: boolean;
message: string;
type: string;
@ -166,13 +166,13 @@ export default function FormModal({
chatItem.files
? {
isSend: !chatItem.is_bot,
message: chatItem.message,
message: chatItem.is_bot ? chatItem.message : formatMessage(chatItem.message),
thought: chatItem.intermediate_steps,
files: chatItem.files,
}
: {
isSend: !chatItem.is_bot,
message: chatItem.message,
message: chatItem.is_bot ? chatItem.message : formatMessage(chatItem.message),
thought: chatItem.intermediate_steps,
}
);
@ -370,6 +370,8 @@ export default function FormModal({
setChatKey(index);
}
}
console.log(chatHistory)
return (
<Dialog open={open} onOpenChange={setModalOpen}>
<DialogTrigger className="hidden"></DialogTrigger>