Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(platform): UI fixes; Fix default value on input fields & fix enum custom fields (#8182)

Zamil Majdy53a0ee252319
diff --git a/autogpt_platform/backend/backend/blocks/llm.py b/autogpt_platform/backend/backend/blocks/llm.py
index 09cf8af3f9..bafbaba0fb 100644
--- a/autogpt_platform/backend/backend/blocks/llm.py
+++ b/autogpt_platform/backend/backend/blocks/llm.py
@@ -92,7 +92,12 @@ class AIStructuredResponseGeneratorBlock(Block):
description="Expected format of the response. If provided, the response will be validated against this format. "
"The keys should be the expected fields in the response, and the values should be the description of the field.",
)
- model: LlmModel = LlmModel.GPT4_TURBO
+ model: LlmModel = SchemaField(
+ title="LLM Model",
+ default=LlmModel.GPT4_TURBO,
+ description="The language model to use for answering the prompt.",
+ advanced=False,
+ )
api_key: BlockSecret = SecretField(value="")
sys_prompt: str = ""
retry: int = 3
@@ -307,7 +312,12 @@ class AIStructuredResponseGeneratorBlock(Block):
class AITextGeneratorBlock(Block):
class Input(BlockSchema):
prompt: str
- model: LlmModel = LlmModel.GPT4_TURBO
+ model: LlmModel = SchemaField(
+ title="LLM Model",
+ default=LlmModel.GPT4_TURBO,
+ description="The language model to use for answering the prompt.",
+ advanced=False,
+ )
api_key: BlockSecret = SecretField(value="")
sys_prompt: str = ""
retry: int = 3
@@ -355,7 +365,11 @@ class AITextGeneratorBlock(Block):
class AITextSummarizerBlock(Block):
class Input(BlockSchema):
text: str
- model: LlmModel = LlmModel.GPT4_TURBO
+ model: LlmModel = SchemaField(
+ title="LLM Model",
+ default=LlmModel.GPT4_TURBO,
+ description="The language model to use for summarizing the text.",
+ )
api_key: BlockSecret = SecretField(value="")
# TODO: Make this dynamic
max_tokens: int = 4000 # Adjust based on the model's context window
@@ -492,6 +506,7 @@ class AIConversationBlock(Block):
description="List of messages in the conversation.", min_length=1
)
model: LlmModel = SchemaField(
+ title="LLM Model",
default=LlmModel.GPT4_TURBO,
description="The language model to use for the conversation.",
)
diff --git a/autogpt_platform/frontend/src/components/node-input-components.tsx b/autogpt_platform/frontend/src/components/node-input-components.tsx
index 4841e3358a..cec4ee1e50 100644
--- a/autogpt_platform/frontend/src/components/node-input-components.tsx
+++ b/autogpt_platform/frontend/src/components/node-input-components.tsx
@@ -49,7 +49,7 @@ const NodeObjectInputTree: FC<NodeObjectInputTreeProps> = ({
className,
displayName,
}) => {
- object ??= ("default" in schema ? schema.default : null) ?? {};
+ object ||= ("default" in schema ? schema.default : null) ?? {};
return (
<div className={cn(className, "w-full flex-col")}>
{displayName && <strong>{displayName}</strong>}
@@ -105,7 +105,7 @@ export const NodeGenericInputField: FC<{
className,
displayName,
}) => {
- displayName ??= propSchema.title || beautifyString(propKey);
+ displayName ||= propSchema.title || beautifyString(propKey);
if ("allOf" in propSchema) {
// If this happens, that is because Pydantic wraps $refs in an allOf if the
@@ -573,6 +573,7 @@ const NodeStringInput: FC<{
className,
displayName,
}) => {
+ value ||= schema.default || "";
return (
<div className={className}>
{schema.enum ? (
@@ -642,6 +643,7 @@ export const NodeTextBoxInput: FC<{
className,
displayName,
}) => {
+ value ||= schema.default || "";
return (
<div className={className}>
<div
@@ -686,8 +688,8 @@ const NodeNumberInput: FC<{
className,
displayName,
}) => {
- value ??= schema.default;
- displayName ??= schema.title || beautifyString(selfKey);
+ value ||= schema.default;
+ displayName ||= schema.title || beautifyString(selfKey);
return (
<div className={className}>
<div className="nodrag flex items-center justify-between space-x-3">
@@ -723,7 +725,7 @@ const NodeBooleanInput: FC<{
className,
displayName,
}) => {
- value ??= schema.default ?? false;
+ value ||= schema.default ?? false;
return (
<div className={className}>
<div className="nodrag flex items-center">
@@ -757,6 +759,7 @@ const NodeFallbackInput: FC<{
className,
displayName,
}) => {
+ value ||= (schema as BlockIOStringSubSchema)?.default;
return (
<NodeStringInput
selfKey={selfKey}