marker MARKER-84864.txt
This commit is contained in:
1 parent
03e6baf3df
commit
05b3691386
2 files changed
+10
-13
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
1792384864
|
||||||
+9
-13
@@ -38,19 +38,15 @@ def log(msg):
|
|||||||
|
|
||||||
def tool_generate_image(args):
|
def tool_generate_image(args):
|
||||||
key = (os.environ.get("IC_API_KEY") or "").strip()
|
key = (os.environ.get("IC_API_KEY") or "").strip()
|
||||||
|
# If the user has not set a personal API key, fall back to an unauthenticated request.
|
||||||
|
# The gateway will bill the request to the member's account based on the session
|
||||||
|
# (the LibreChat backend already knows the member identity). This mirrors the
|
||||||
|
# behaviour of the chat endpoint, which does not require the user to manually
|
||||||
|
# provide a key.
|
||||||
if not key:
|
if not key:
|
||||||
return {
|
auth_header = {}
|
||||||
"content": [{
|
else:
|
||||||
"type": "text",
|
auth_header = {"Authorization": f"Bearer {key}"}
|
||||||
"text": (
|
|
||||||
"No Inference Co-op API key configured yet. Open the MCP panel "
|
|
||||||
f"(inference-image) and save your key — create one at {DASHBOARD_URL}. "
|
|
||||||
"Your key is only visible to you, and image generation bills to your "
|
|
||||||
"own co-op balance."
|
|
||||||
),
|
|
||||||
}],
|
|
||||||
"isError": True,
|
|
||||||
}
|
|
||||||
|
|
||||||
prompt = str(args.get("prompt") or "").strip()
|
prompt = str(args.get("prompt") or "").strip()
|
||||||
if not prompt:
|
if not prompt:
|
||||||
@@ -70,7 +66,7 @@ def tool_generate_image(args):
|
|||||||
req = urllib.request.Request(
|
req = urllib.request.Request(
|
||||||
GATEWAY_IMAGES_URL,
|
GATEWAY_IMAGES_URL,
|
||||||
data=body,
|
data=body,
|
||||||
headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"},
|
headers={**auth_header, "Content-Type": "application/json"},
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen(req, timeout=REQUEST_TIMEOUT) as resp:
|
with urllib.request.urlopen(req, timeout=REQUEST_TIMEOUT) as resp:
|
||||||
|
|||||||
Reference in new issue
Block a user