diff --git a/backend/apps/webui/main.py b/backend/apps/webui/main.py
index f092da7ad..8255cd393 100644
--- a/backend/apps/webui/main.py
+++ b/backend/apps/webui/main.py
@@ -116,6 +116,13 @@ async def get_pipe_models():
else:
function_module = app.state.FUNCTIONS[pipe.id]
+ if hasattr(function_module, "valves") and hasattr(function_module, "Valves"):
+ print(f"Getting valves for {pipe.id}")
+ valves = Functions.get_function_valves_by_id(pipe.id)
+ function_module.valves = function_module.Valves(
+ **(valves if valves else {})
+ )
+
# Check if function is a manifold
if hasattr(function_module, "type"):
if function_module.type == "manifold":
diff --git a/backend/apps/webui/utils.py b/backend/apps/webui/utils.py
index 8bcda539e..545120835 100644
--- a/backend/apps/webui/utils.py
+++ b/backend/apps/webui/utils.py
@@ -16,12 +16,16 @@ def extract_frontmatter(file_path):
try:
with open(file_path, "r", encoding="utf-8") as file:
+ first_line = file.readline()
+ if first_line.strip() != '"""':
+ # The file doesn't start with triple quotes
+ return {}
+
+ frontmatter_started = True
+
for line in file:
if '"""' in line:
- if not frontmatter_started:
- frontmatter_started = True
- continue # skip the line with the opening triple quotes
- else:
+ if frontmatter_started:
frontmatter_ended = True
break
@@ -30,6 +34,7 @@ def extract_frontmatter(file_path):
if match:
key, value = match.groups()
frontmatter[key.strip()] = value.strip()
+
except FileNotFoundError:
print(f"Error: The file {file_path} does not exist.")
return {}
diff --git a/src/lib/components/workspace/Functions.svelte b/src/lib/components/workspace/Functions.svelte
index afb9ae1c1..b3572a087 100644
--- a/src/lib/components/workspace/Functions.svelte
+++ b/src/lib/components/workspace/Functions.svelte
@@ -4,7 +4,7 @@
const { saveAs } = fileSaver;
import { WEBUI_NAME, functions, models } from '$lib/stores';
- import { onMount, getContext } from 'svelte';
+ import { onMount, getContext, tick } from 'svelte';
import { createNewPrompt, deletePromptByCommand, getPrompts } from '$lib/apis/prompts';
import { goto } from '$app/navigation';
@@ -387,7 +387,15 @@
-
+ {
+ await tick();
+ models.set(await getModels(localStorage.token));
+ }}
+/>