Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions promptlayer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ async def _post_workflow_id_run(
_url_template: str = WORKFLOW_RUN_URL_TEMPLATE,
):
url = _url_template.format(base_url=base_url, workflow_id=workflow_id)
prompt_name = urllib.parse.quote(prompt_name)
payload = {
"input_variables": input_variables,
"metadata": metadata,
Expand Down Expand Up @@ -893,6 +894,7 @@ async def apromptlayer_track_prompt(
throw_on_error: bool = True,
) -> bool:
url = f"{base_url}/library-track-prompt"
prompt_name = urllib.parse.quote(prompt_name)
payload = {
"request_id": request_id,
"prompt_name": prompt_name,
Expand Down Expand Up @@ -974,6 +976,7 @@ async def apromptlayer_track_metadata(
metadata: Dict[str, Any],
) -> bool:
url = f"{base_url}/library-track-metadata"
prompt_name = urllib.parse.quote(prompt_name)
payload = {
"request_id": request_id,
"metadata": metadata,
Expand Down Expand Up @@ -1052,6 +1055,7 @@ async def apromptlayer_track_score(
score_name: Optional[str],
) -> bool:
url = f"{base_url}/library-track-score"
prompt_name = urllib.parse.quote(prompt_name)
data = {
"request_id": request_id,
"score": score,
Expand Down Expand Up @@ -1152,6 +1156,7 @@ def __init__(self, generator, api_request_arguments, api_key, base_url):
self.api_request_arugments = api_request_arguments
self.api_key = api_key
self.base_url = base_url
prompt_name = urllib.parse.quote(prompt_name)

def __iter__(self):
return self
Expand Down Expand Up @@ -1571,7 +1576,7 @@ def get_prompt_template(
if params:
json_body = {**json_body, **params}
response = _get_requests_session().post(
f"{base_url}/prompt-templates/{quote(prompt_name, safe='')}",
f"{base_url}/prompt-templates/{quote(urllib.parse.quote(prompt_name), safe='')}",
headers={"X-API-KEY": api_key},
json=json_body,
)
Expand Down Expand Up @@ -1623,7 +1628,7 @@ async def aget_prompt_template(
json_body.update(params)
async with _make_httpx_client() as client:
response = await client.post(
f"{base_url}/prompt-templates/{quote(prompt_name, safe='')}",
f"{base_url}/prompt-templates/{quote(urllib.parse.quote(prompt_name), safe='')}",
headers={"X-API-KEY": api_key},
json=json_body,
)
Expand Down Expand Up @@ -2364,6 +2369,7 @@ def anthropic_bedrock_request(
aws_region = function_kwargs.pop("aws_region", None)
aws_session_token = function_kwargs.pop("aws_session_token", None)
base_url = function_kwargs.pop("base_url", None)
prompt_name = urllib.parse.quote(prompt_name)

cache_key = f"anthropic_bedrock:{aws_access_key or ''}:{aws_region or ''}:{base_url or ''}"
client = _get_cached_client(
Expand Down Expand Up @@ -2398,6 +2404,7 @@ async def aanthropic_bedrock_request(
aws_region = function_kwargs.pop("aws_region", None)
aws_session_token = function_kwargs.pop("aws_session_token", None)
base_url = function_kwargs.pop("base_url", None)
prompt_name = urllib.parse.quote(prompt_name)

cache_key = f"async_anthropic_bedrock:{aws_access_key or ''}:{aws_region or ''}:{base_url or ''}"
client = _get_cached_client(
Expand Down