-
-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with anthropic_manifold_pipeline #166
Comments
We often experience the same thing. |
I'll have a look when I've got time, but I've been mostly using my Anthropic Function nowadays. I haven't noticed this issue in that, but then it's just using |
Any solution yet? Today I have the same problem.
|
401 Authentication error. Have you checked your keys work if you do a request manually with cURL? |
See my initial post. |
Your logs are either at odds with the reality, or your key is bad. You didn't answer the question of whether you've tried that key with anything else. You're certain your account is in good-standing, and adequately funded ($5 minimum balance required IIRC)? If I deliberately set an incorrect key I get this error, same as you:
|
25$ Balance Here is the cURL Example with output
|
Well, I'm truly at a loss then, I've been unable to reproduce this by any easy means, and I don't wish to push the issue too much further for fear of affecting my own access to their API. |
If I create a second API key and use it, it works. The first API key, however, functions flawlessly via cURL. |
Strange... is it possible they're using a weird character in your first key that isn't being escaped properly? |
Sometimes it's working with the key and after some time the same key won't work anymore. |
I occasionally see the same issue with a working key. Seems reproducible when I restart the pipelines container. If I go into Open WebUI/Pipelines and select the anthropic_manifold_pipeline (manifold), the saved API key loads up. After pressing save without changing anything, it starts working as it should. The mounted appdata folder has the correct file/folder permissions and ownership. PS: I have to do the same steps for openai_manifold_pipeline (manifold) for OpenAI models to load up and be usable. |
Now there's a clue I can work on. Thanks @realies, I'll see if this new information uncovers anything. |
I am also experiencing this same error. With curl, the key works fine before I use it with Pipelines, but after I use it in Open WebUI, like a banshee, the key is marked for death (figuratively speaking) and will unceremoniously expire in <24 hours. After this, not even curl can revive the key. I have made dozens of new keys trying to get around this issue and I have not been banned from the API or anything, but my keys are dropping like flies. This is the error that happens after a key has been cursed: {
"type": "error",
"error": {
"type": "authentication_error",
"message": "invalid x-api-key"
}
} |
If you're paying customers, have any of you tried contacting Anthropic's support to inquire as to the reason your keys are being revoked? |
I have, and Anthropic took the entirety of the month to respond (Thanks, Claude 3.5). Today, they're asking for what the header sent from the app looks like and I don't really know how to find that out. |
Thanks for the additional datapoint @Digit404. I've no intention of closing this until I figure out what the heck is going on 😅 |
While this issue is being looked at, anyone who wants to temporarily bypass this problem can use the following working anthropic pipeline which uses the HTTP API directly and is currently working without any errors (no invalid x-api-key error):
|
@sriparashiva ironically that's exactly what I was planning to do to "resolve" this if I had to, since using |
Hi, thank you. I have downloaded your script and uploaded it through the OpenWebUI interface. Afterwards, the file is immediately moved to the "failed" subfolder within the pipeline folder. In the pipeline docker Logs, I see the following:
|
@dannykorpan Since the pipeline has an additional dependency I am using a Docker setup for pipelines, so I just executed the command Or alternatively, you can use the code snippet from @justinh-rahb's linked custom function which does not use any external dependencies. |
Your workaround works :-) Thank you! |
@dannykorpan @Digit404 @sriparashiva please give this PR a try: If you install it by putting the raw URL into your
|
Thank you, but still get the following error after importing into pipelines:
|
@dannykorpan as noted, the dependency only installs on server startup if it is already in the |
Thank you, but I think it represents a potential source of error. If I restart the server, the sseclient module still won't be installed automatically. I always have to install it manually, even after a restart. Or am I misunderstanding something? |
You are misunderstanding something, yes. The frontmatter at the top of the file specifies what depends it uses:
When the server is started (or restarted) with Lines 85 to 105 in cd6c092
|
But I start the pipelines server via docker. |
Two options:Bind mount the docker run -d \
-p 9099:9099 \
--add-host=host.docker.internal:host-gateway \
-v /home/your-username/pipelines:/app/pipelines \
--name pipelines \
--restart always \
ghcr.io/open-webui/pipelines:main You can then drop the Alternatively, use the docker run -d \
-p 9099:9099 \
--add-host=host.docker.internal:host-gateway \
-v pipelines:/app/pipelines \
-e PIPELINES_URLS="github_raw_urls;separated_by_semicolons"
--name pipelines \
--restart always \
ghcr.io/open-webui/pipelines:main This should install the depends immediately after downloading the pipeline when the container starts. |
Works, thank you! |
After installing the new pipeline, it's been a while and my key still works. Thanks for the fix! |
@justinh-rahb, for some reason I still have to re-submit API keys for each pipeline for the service to continue to work after a restart; this is the compose file:
here's a log of starting the container, trying to use anthropic and failing to do so because
going to the settings page for anthropic_manifold_pipeline and pressing save can be seen to fix it further down the logs any idea why this is happening?
|
Today getting the same error as @realies. After resaving the API-Key in the UI under Pipelines it works for a while.
|
Sonnet 3.5 said this could help: index 81fa910..43d261e 100644
--- a/examples/pipelines/providers/anthropic_manifold_pipeline.py
+++ b/examples/pipelines/providers/anthropic_manifold_pipeline.py
@@ -2,23 +2,22 @@
title: Anthropic Manifold Pipeline
author: justinh-rahb, sriparashiva
date: 2024-06-20
-version: 1.4
+version: 1.5
license: MIT
description: A pipeline for generating text and processing images using the Anthropic API.
requirements: requests, sseclient-py
-environment_variables: ANTHROPIC_API_KEY
"""
-import os
-import requests
import json
+import os
from typing import List, Union, Generator, Iterator
from pydantic import BaseModel
+import requests
import sseclient
+import threading
from utils.pipelines.main import pop_system_message
-
class Pipeline:
class Valves(BaseModel):
ANTHROPIC_API_KEY: str = ""
@@ -28,18 +27,27 @@ class Pipeline:
self.id = "anthropic"
self.name = "anthropic/"
- self.valves = self.Valves(
- **{"ANTHROPIC_API_KEY": os.getenv("ANTHROPIC_API_KEY", "your-api-key-here")}
- )
+ self.valves = self.Valves()
self.url = 'https://api.anthropic.com/v1/messages'
+ self._lock = threading.Lock()
+ self.headers = {}
+ self.load_valves()
+
+ def load_valves(self):
+ valves_path = os.path.join(os.path.dirname(__file__), 'valves.json')
+ if os.path.exists(valves_path):
+ with open(valves_path, 'r') as f:
+ valves_data = json.load(f)
+ self.valves = self.Valves(**valves_data)
self.update_headers()
def update_headers(self):
- self.headers = {
- 'anthropic-version': '2023-06-01',
- 'content-type': 'application/json',
- 'x-api-key': self.valves.ANTHROPIC_API_KEY
- }
+ with self._lock:
+ self.headers = {
+ 'anthropic-version': '2023-06-01',
+ 'content-type': 'application/json',
+ 'x-api-key': self.valves.ANTHROPIC_API_KEY
+ }
def get_anthropic_models(self):
return [
@@ -51,14 +59,14 @@ class Pipeline:
async def on_startup(self):
print(f"on_startup:{__name__}")
- pass
+ self.load_valves()
async def on_shutdown(self):
print(f"on_shutdown:{__name__}")
- pass
async def on_valves_updated(self):
- self.update_headers()
+ self.load_valves()
+ print(f"Anthropic API key updated: {self.valves.ANTHROPIC_API_KEY[:5]}...")
def pipelines(self) -> List[dict]:
return self.get_anthropic_models()
@@ -85,6 +93,9 @@ class Pipeline:
self, user_message: str, model_id: str, messages: List[dict], body: dict
) -> Union[str, Generator, Iterator]:
try:
+ # Ensure we're using the most up-to-date API key
+ self.load_valves()
+
# Remove unnecessary keys
for key in ['user', 'chat_id', 'title']:
body.pop(key, None)
@@ -141,12 +152,14 @@ class Pipeline:
else:
return self.get_completion(payload)
except Exception as e:
+ print(f"Error in pipe: {e}")
return f"Error: {e}"
def stream_response(self, payload: dict) -> Generator:
- response = requests.post(self.url, headers=self.headers, json=payload, stream=True)
+ try:
+ response = requests.post(self.url, headers=self.headers, json=payload, stream=True)
+ response.raise_for_status()
- if response.status_code == 200:
client = sseclient.SSEClient(response)
for event in client.events():
try:
@@ -162,13 +175,16 @@ class Pipeline:
except KeyError as e:
print(f"Unexpected data structure: {e}")
print(f"Full data: {data}")
- else:
- raise Exception(f"Error: {response.status_code} - {response.text}")
+ except requests.exceptions.RequestException as e:
+ print(f"Error in stream_response: {e}")
+ yield f"Error: {e}"
def get_completion(self, payload: dict) -> str:
- response = requests.post(self.url, headers=self.headers, json=payload)
- if response.status_code == 200:
+ try:
+ response = requests.post(self.url, headers=self.headers, json=payload)
+ response.raise_for_status()
res = response.json()
return res["content"][0]["text"] if "content" in res and res["content"] else ""
- else:
- raise Exception(f"Error: {response.status_code} - {response.text}")
+ except requests.exceptions.RequestException as e:
+ print(f"Error in get_completion: {e}")
+ return f"Error: {e}"
|
wait, you're supposed to provide the key via ANTHROPIC_API_KEY? can keys be fetched from valves.json as a fallback? |
Intended to be optional with ability to set via valves as well, but if this is not working it'll need refac. Will look into when my time allows. For now, yes, setting an |
Will try it. |
The day after... same problem today. |
For what it's worth, I’ve been using my own pipeline since I created it and haven’t personally encountered any of the reported errors or issues. All my troubleshooting and debugging has been based on these reports, but I haven’t been able to fully reproduce them. This means I’m essentially working in the dark. I would greatly appreciate any additional information, such as logs or detailed accounts of the exact sequence of events that led to these outcomes, even if it feels excessive or "too much detail", let me decide that. |
How do I enable debugging, so that I can see the the used API key? |
I'm also having to save api key manually (for both Anthropic and Dall-E) manifold pipelines every time the docker container restarts. What is more Strange is that api keys are there and correct, I just have press save button. |
Bug Report
Description
Bug Summary:
When using Claude 3.5 via anthropic_manifold_pipeline.py from https://github.com/open-webui/pipelines/blob/main/examples/pipelines/providers/anthropic_manifold_pipeline.py, I get the following error after a while. The API Key is correct.
Steps to Reproduce:
I deployed Pipelines via docker and set up the API Key via the admin interface.
After using Claude 3.5 the pipelines container prints the following error after 2-3 uses.
Environment
Open WebUI Version: [e.g., 0.1.120]
v0.3.10
Operating System: [e.g., Windows 10, macOS Big Sur, Ubuntu 20.04]
Server: Latest Docker, x64
Client: Latest macOS Sonoma, ARM64
Browser (if applicable): [e.g., Chrome 100.0, Firefox 98.0]
Latest Firefox, ARM64
Confirmation:
The text was updated successfully, but these errors were encountered: