[GH-ISSUE #7852] Manifold functions don't preserve value of valves when executed #14910

Closed
opened 2026-04-19 21:09:32 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @reecelikesramen on GitHub (Dec 14, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/7852

Bug Report

Installation Method

Standard Docker installation found in "Quick Start" section of the docs.

Environment

  • Open WebUI Version: [v0.4.8]

  • Ollama (if applicable): [N/A]

  • Operating System: [Ubuntu 20.04 x64]

  • Browser (if applicable): [Arc Browser (Chromium Engine Version 131.0.6778.140)]

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

When using a model provided by a manifold function, in def pipe, the value of self.valves should be equal the value of self.valves during construction.

Actual Behavior:

For a Valves class with a single string field, that field is populated during construction, but if checked during def pip that field is an empty string.

Description

Bug Summary:
I am using the Anthropic function. The Valve for the Anthropic API key in the constructor is set properly using the environment variables, but then when the def pipe function is executed by using an Anthropic model, printing the value of the Anthropic API key Valve is empty.

Reproduction Details

Steps to Reproduce:

  • Install the Anthropic function linked above.
  • Set environment variable ANTHROPIC_API_KEY to any value, or leave it unset and edit this line: self.valves = self.Valves(**{"ANTHROPIC_API_KEY": os.getenv("ANTHROPIC_API_KEY", "<put some value here>")}).
  • Add a print("CONSTRUCTOR", self.valves) after that in the constructor.
  • Add print("PIPE", self.valves) anywhere in the def pipe function.
  • Observe the open-webui output and notice that the print shows a value for ANTHROPIC_API_KEY in the constructor, and shows no value for it in the def pipe function.

Logs and Screenshots

Docker Container Logs:

Log section after saving the function. You can see ANTHROPIC_API_KEY='sk-ant-<omitted>' is where I call print(self.valves) in the constructor:

...
INFO:     153.33.238.21:0 - "POST /api/v1/functions/id/anthropic/update HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "GET /api/v1/functions/ HTTP/1.0" 200 OK
INFO  [open_webui.apps.openai.main] get_all_models()
INFO:     153.33.238.21:0 - "GET /api/models HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "GET /ws/socket.io/?EIO=4&transport=polling&t=PF4zoF8.0&sid=EmEV1PjG_3rb7mVoAAAo HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "POST /ws/socket.io/?EIO=4&transport=polling&t=PF4zuMZ&sid=EmEV1PjG_3rb7mVoAAAo HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "GET /ws/socket.io/?EIO=4&transport=polling&t=PF4zoW6.0&sid=ZpMmIVWc3r7I34jTAAAq HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "POST /ws/socket.io/?EIO=4&transport=polling&t=PF4zudV&sid=ZpMmIVWc3r7I34jTAAAq HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "POST /api/v1/utils/code/format HTTP/1.0" 200 OK
INFO  [open_webui.apps.webui.utils] No requirements found in frontmatter.
INFO  [open_webui.apps.webui.utils] Loaded module: function_anthropic
ANTHROPIC_API_KEY='sk-ant-<omitted>'
{'name': 'Anthropic', 'content': '"""\ntitle: Anthropic Manifold Pipe\nauthors: justinh-rahb and christian-taillon\nauthor_url: https://github.com/justinh-rahb\nfunding_url: https://github.com/open-webui\nversion: 0.2.4\nrequired_open_webui_version: 0.3.17\nlicense: MIT\n"""\n\nimport os\nimport requests\nimport json\nimport time\nfrom typing import List, Union, Generator, Iterator\nfrom pydantic import BaseModel, Field\nfrom open_webui.utils.misc import pop_system_message\n\n\nclass Pipe:\n    class Valves(BaseModel):\n        ANTHROPIC_API_KEY: str = Field(default="")\n\n    def __init__(self):\n        self.type = "manifold"\n
...

Log section after the previous log and trying to send a chat message to an Anthropic model. You can see ANTHROPIC_API_KEY='' after the line valves is where I call print(self.valves) in the def pipe function.

...
INFO:     153.33.238.21:0 - "GET /api/v1/chats/?page=1 HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "GET /api/v1/folders/ HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "GET /ollama/api/version HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "POST /api/v1/memories/query HTTP/1.0" 200 OK
INFO  [open_webui.apps.openai.main] get_all_models()
valves
ANTHROPIC_API_KEY=''
General error in stream_response method: HTTP Error 401: {"type":"error","error":{"type":"authentication_error","message":"x-api-key header is required"}}
INFO:     153.33.238.21:0 - "POST /api/chat/completions HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "POST /api/v1/chats/ce7f63a1-4c62-41a8-88fd-7cb639680799 HTTP/1.0" 200 OK
INFO:     153.33.238.21:0 - "POST /ws/socket.io/?EIO=4&transport=polling&t=PF4-BqE&sid=GaXV3OmlnLpTX_NPAAAs HTTP/1.0" 200 OK
...

Browser logs:

FunctionEditor.svelte:279 Code formatted successfully
+page.svelte:21 {id: 'anthropic', name: 'Anthropic', meta: {…}, content: '"""\ntitle: Anthropic Manifold Pipe\nauthors: justin… request: {e}")\n            return f"Error: {e}"\n'}
Chat.svelte:337 mounted
RichTextInput.svelte:129 
RichTextInput.svelte:160 [tiptap warn]: Duplicate extension names found: ['codeBlock']. This can lead to issues.
resolve @ index.js:1158
un @ index.js:1144
createExtensionManager @ index.js:4470
_g @ index.js:4302
(anonymous) @ RichTextInput.svelte:160
await in (anonymous)
J @ utils.js:41
(anonymous) @ Component.js:47
_t @ scheduler.js:99
Promise.then
ut @ scheduler.js:20
ht @ Component.js:81
(anonymous) @ Component.js:139
s.$$set @ root.svelte:69
$set @ Component.js:507
W @ client.js:1422
await in W
et @ client.js:382
en @ client.js:1751
Ie @ Sidebar.svelte:425
Chat.svelte:837 submitPrompt test claude message 
MessageInput.svelte:257 destroy
RichTextInput.svelte:129 
Chat.svelte:155 saveSessionSelectedModels ['anthropic.claude-3-5-haiku-latest'] ["anthropic.claude-3-5-haiku-latest"]
RichTextInput.svelte:160 [tiptap warn]: Duplicate extension names found: ['codeBlock']. This can lead to issues.
resolve @ index.js:1158
un @ index.js:1144
createExtensionManager @ index.js:4470
_g @ index.js:4302
(anonymous) @ RichTextInput.svelte:160
await in (anonymous)
J @ utils.js:41
(anonymous) @ Component.js:47
_t @ scheduler.js:99
Promise.then
ut @ scheduler.js:20
ht @ Component.js:81
(anonymous) @ Component.js:139
gt @ Chat.svelte:899
await in gt
On @ Chat.svelte:2353
await in On
(anonymous) @ lifecycle.js:105
(anonymous) @ lifecycle.js:104
D @ Placeholder.svelte:207
(anonymous) @ lifecycle.js:105
(anonymous) @ lifecycle.js:104
Vt @ MessageInput.svelte:725
(anonymous) @ lifecycle.js:105
(anonymous) @ lifecycle.js:104
keydown @ RichTextInput.svelte:274
(anonymous) @ index.js:3092
someProp @ index.js:5484
da @ index.js:3090
t.dom.addEventListener.t.input.eventHandlers.<computed> @ index.js:3059
Chat.svelte:1005 modelId anthropic.claude-3-5-haiku-latest
index.ts:63 {id: 'anthropic.claude-3-5-haiku-latest-3a01c514-d8f7-4f43-a19e-a47bbc1c017f', created: 1734181221, model: 'anthropic.claude-3-5-haiku-latest', choices: Array(1), object: 'chat.completion.chunk'}
index.ts:63 {id: 'anthropic.claude-3-5-haiku-latest-0336c28a-dca7-4c0a-b610-ab45b5f597e6', created: 1734181221, model: 'anthropic.claude-3-5-haiku-latest', choices: Array(1), object: 'chat.completion.chunk'}
+layout.svelte:82 usage {models: Array(1)}
+layout.svelte:82 usage {models: Array(1)}
+layout.svelte:82 usage {models: Array(1)}
Chat.svelte:2021 (3) ['Technology', 'Computing', 'Error Messages']
+layout.svelte:82 usage {models: Array(1)}
+layout.svelte:82 usage {models: Array(0)}
Originally created by @reecelikesramen on GitHub (Dec 14, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/7852 # Bug Report ## Installation Method Standard Docker installation found in "Quick Start" section of the docs. ## Environment - **Open WebUI Version:** [v0.4.8] - **Ollama (if applicable):** [N/A] - **Operating System:** [Ubuntu 20.04 x64] - **Browser (if applicable):** [Arc Browser (Chromium Engine Version 131.0.6778.140)] **Confirmation:** - [x] I have read and followed all the instructions provided in the README.md. - [x] I am on the latest version of both Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior: When using a model provided by a manifold function, in `def pipe`, the value of `self.valves` should be equal the value of `self.valves` during construction. ## Actual Behavior: For a Valves class with a single string field, that field is populated during construction, but if checked during `def pip` that field is an empty string. ## Description **Bug Summary:** I am using the [Anthropic function](https://openwebui.com/f/justinrahb/anthropic). The Valve for the Anthropic API key in the constructor is set properly using the environment variables, but then when the `def pipe` function is executed by using an Anthropic model, printing the value of the Anthropic API key Valve is empty. ## Reproduction Details **Steps to Reproduce:** - Install the Anthropic function linked above. - Set environment variable ANTHROPIC_API_KEY to any value, or leave it unset and edit this line: `self.valves = self.Valves(**{"ANTHROPIC_API_KEY": os.getenv("ANTHROPIC_API_KEY", "<put some value here>")})`. - Add a `print("CONSTRUCTOR", self.valves)` after that in the constructor. - Add `print("PIPE", self.valves)` anywhere in the `def pipe` function. - Observe the open-webui output and notice that the print shows a value for ANTHROPIC_API_KEY in the constructor, and shows no value for it in the `def pipe` function. ## Logs and Screenshots **Docker Container Logs:** Log section after saving the function. You can see `ANTHROPIC_API_KEY='sk-ant-<omitted>'` is where I call `print(self.valves)` in the constructor: ```log ... INFO: 153.33.238.21:0 - "POST /api/v1/functions/id/anthropic/update HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "GET /api/v1/functions/ HTTP/1.0" 200 OK INFO [open_webui.apps.openai.main] get_all_models() INFO: 153.33.238.21:0 - "GET /api/models HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "GET /ws/socket.io/?EIO=4&transport=polling&t=PF4zoF8.0&sid=EmEV1PjG_3rb7mVoAAAo HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "POST /ws/socket.io/?EIO=4&transport=polling&t=PF4zuMZ&sid=EmEV1PjG_3rb7mVoAAAo HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "GET /ws/socket.io/?EIO=4&transport=polling&t=PF4zoW6.0&sid=ZpMmIVWc3r7I34jTAAAq HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "POST /ws/socket.io/?EIO=4&transport=polling&t=PF4zudV&sid=ZpMmIVWc3r7I34jTAAAq HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "POST /api/v1/utils/code/format HTTP/1.0" 200 OK INFO [open_webui.apps.webui.utils] No requirements found in frontmatter. INFO [open_webui.apps.webui.utils] Loaded module: function_anthropic ANTHROPIC_API_KEY='sk-ant-<omitted>' {'name': 'Anthropic', 'content': '"""\ntitle: Anthropic Manifold Pipe\nauthors: justinh-rahb and christian-taillon\nauthor_url: https://github.com/justinh-rahb\nfunding_url: https://github.com/open-webui\nversion: 0.2.4\nrequired_open_webui_version: 0.3.17\nlicense: MIT\n"""\n\nimport os\nimport requests\nimport json\nimport time\nfrom typing import List, Union, Generator, Iterator\nfrom pydantic import BaseModel, Field\nfrom open_webui.utils.misc import pop_system_message\n\n\nclass Pipe:\n class Valves(BaseModel):\n ANTHROPIC_API_KEY: str = Field(default="")\n\n def __init__(self):\n self.type = "manifold"\n ... ``` Log section after the previous log and trying to send a chat message to an Anthropic model. You can see `ANTHROPIC_API_KEY=''` after the line `valves` is where I call `print(self.valves)` in the `def pipe` function. ```log ... INFO: 153.33.238.21:0 - "GET /api/v1/chats/?page=1 HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "GET /api/v1/folders/ HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "GET /ollama/api/version HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "POST /api/v1/memories/query HTTP/1.0" 200 OK INFO [open_webui.apps.openai.main] get_all_models() valves ANTHROPIC_API_KEY='' General error in stream_response method: HTTP Error 401: {"type":"error","error":{"type":"authentication_error","message":"x-api-key header is required"}} INFO: 153.33.238.21:0 - "POST /api/chat/completions HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "POST /api/v1/chats/ce7f63a1-4c62-41a8-88fd-7cb639680799 HTTP/1.0" 200 OK INFO: 153.33.238.21:0 - "POST /ws/socket.io/?EIO=4&transport=polling&t=PF4-BqE&sid=GaXV3OmlnLpTX_NPAAAs HTTP/1.0" 200 OK ... ``` Browser logs: ``` FunctionEditor.svelte:279 Code formatted successfully +page.svelte:21 {id: 'anthropic', name: 'Anthropic', meta: {…}, content: '"""\ntitle: Anthropic Manifold Pipe\nauthors: justin… request: {e}")\n return f"Error: {e}"\n'} Chat.svelte:337 mounted RichTextInput.svelte:129 RichTextInput.svelte:160 [tiptap warn]: Duplicate extension names found: ['codeBlock']. This can lead to issues. resolve @ index.js:1158 un @ index.js:1144 createExtensionManager @ index.js:4470 _g @ index.js:4302 (anonymous) @ RichTextInput.svelte:160 await in (anonymous) J @ utils.js:41 (anonymous) @ Component.js:47 _t @ scheduler.js:99 Promise.then ut @ scheduler.js:20 ht @ Component.js:81 (anonymous) @ Component.js:139 s.$$set @ root.svelte:69 $set @ Component.js:507 W @ client.js:1422 await in W et @ client.js:382 en @ client.js:1751 Ie @ Sidebar.svelte:425 Chat.svelte:837 submitPrompt test claude message MessageInput.svelte:257 destroy RichTextInput.svelte:129 Chat.svelte:155 saveSessionSelectedModels ['anthropic.claude-3-5-haiku-latest'] ["anthropic.claude-3-5-haiku-latest"] RichTextInput.svelte:160 [tiptap warn]: Duplicate extension names found: ['codeBlock']. This can lead to issues. resolve @ index.js:1158 un @ index.js:1144 createExtensionManager @ index.js:4470 _g @ index.js:4302 (anonymous) @ RichTextInput.svelte:160 await in (anonymous) J @ utils.js:41 (anonymous) @ Component.js:47 _t @ scheduler.js:99 Promise.then ut @ scheduler.js:20 ht @ Component.js:81 (anonymous) @ Component.js:139 gt @ Chat.svelte:899 await in gt On @ Chat.svelte:2353 await in On (anonymous) @ lifecycle.js:105 (anonymous) @ lifecycle.js:104 D @ Placeholder.svelte:207 (anonymous) @ lifecycle.js:105 (anonymous) @ lifecycle.js:104 Vt @ MessageInput.svelte:725 (anonymous) @ lifecycle.js:105 (anonymous) @ lifecycle.js:104 keydown @ RichTextInput.svelte:274 (anonymous) @ index.js:3092 someProp @ index.js:5484 da @ index.js:3090 t.dom.addEventListener.t.input.eventHandlers.<computed> @ index.js:3059 Chat.svelte:1005 modelId anthropic.claude-3-5-haiku-latest index.ts:63 {id: 'anthropic.claude-3-5-haiku-latest-3a01c514-d8f7-4f43-a19e-a47bbc1c017f', created: 1734181221, model: 'anthropic.claude-3-5-haiku-latest', choices: Array(1), object: 'chat.completion.chunk'} index.ts:63 {id: 'anthropic.claude-3-5-haiku-latest-0336c28a-dca7-4c0a-b610-ab45b5f597e6', created: 1734181221, model: 'anthropic.claude-3-5-haiku-latest', choices: Array(1), object: 'chat.completion.chunk'} +layout.svelte:82 usage {models: Array(1)} +layout.svelte:82 usage {models: Array(1)} +layout.svelte:82 usage {models: Array(1)} Chat.svelte:2021 (3) ['Technology', 'Computing', 'Error Messages'] +layout.svelte:82 usage {models: Array(1)} +layout.svelte:82 usage {models: Array(0)} ```
Author
Owner

@reecelikesramen commented on GitHub (Dec 14, 2024):

For now I get around this by just calling os.getenv("ANTHROPIC_API_KEY") inside the def pipe method.

<!-- gh-comment-id:2543101827 --> @reecelikesramen commented on GitHub (Dec 14, 2024): For now I get around this by just calling os.getenv("ANTHROPIC_API_KEY") inside the `def pipe` method.
Author
Owner

@reecelikesramen commented on GitHub (Dec 14, 2024):

I tested adding an additional field to the Valves class and populating it in the constructor. Its value was also emptied by the time it was printed in def pipe

<!-- gh-comment-id:2543102759 --> @reecelikesramen commented on GitHub (Dec 14, 2024): I tested adding an additional field to the Valves class and populating it in the constructor. Its value was also emptied by the time it was printed in `def pipe`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#14910