forked from phoenix/litellm-mirror
fix(proxy_server.py): fix /key/update
endpoint to update key duration
also adds a test for this to our ci/cd
This commit is contained in:
parent
68a1fa36cf
commit
af2eabba91
2 changed files with 8 additions and 1 deletions
|
@ -4189,6 +4189,13 @@ async def update_key_fn(request: Request, data: UpdateKeyRequest):
|
||||||
0,
|
0,
|
||||||
): # models default to [], spend defaults to 0, we should not reset these values
|
): # models default to [], spend defaults to 0, we should not reset these values
|
||||||
non_default_values[k] = v
|
non_default_values[k] = v
|
||||||
|
|
||||||
|
if "duration" in non_default_values:
|
||||||
|
duration = non_default_values.pop("duration")
|
||||||
|
duration_s = _duration_in_seconds(duration=duration)
|
||||||
|
expires = datetime.utcnow() + timedelta(seconds=duration_s)
|
||||||
|
non_default_values["expires"] = expires
|
||||||
|
|
||||||
response = await prisma_client.update_data(
|
response = await prisma_client.update_data(
|
||||||
token=key, data={**non_default_values, "token": key}
|
token=key, data={**non_default_values, "token": key}
|
||||||
)
|
)
|
||||||
|
|
|
@ -65,7 +65,7 @@ async def update_key(session, get_key):
|
||||||
"Authorization": f"Bearer sk-1234",
|
"Authorization": f"Bearer sk-1234",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
data = {"key": get_key, "models": ["gpt-4"]}
|
data = {"key": get_key, "models": ["gpt-4"], "duration": "120s"}
|
||||||
|
|
||||||
async with session.post(url, headers=headers, json=data) as response:
|
async with session.post(url, headers=headers, json=data) as response:
|
||||||
status = response.status
|
status = response.status
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue