(feat) completion:debugging - show raw POST request

This commit is contained in:
ishaan-jaff 2023-11-27 10:13:37 -08:00
parent 90687d51f1
commit 26938f697e
2 changed files with 32 additions and 11 deletions

View file

@ -389,17 +389,24 @@ def completion(
"textGenerationConfig": inference_params,
})
## LOGGING
logging_obj.pre_call(
input=prompt,
api_key="",
additional_args={"complete_input_dict": data},
)
## COMPLETION CALL
accept = 'application/json'
contentType = 'application/json'
if stream == True:
## LOGGING
request_str = f"""
response = client.invoke_model_with_response_stream(
body={data},
modelId={model},
accept=accept,
contentType=contentType
)
"""
logging_obj.pre_call(
input=prompt,
api_key="",
additional_args={"complete_input_dict": data, "request_str": request_str},
)
response = client.invoke_model_with_response_stream(
body=data,
modelId=model,
@ -410,6 +417,20 @@ def completion(
return response
try:
## LOGGING
request_str = f"""
response = client.invoke_model(
body={data},
modelId={model},
accept=accept,
contentType=contentType
)
"""
logging_obj.pre_call(
input=prompt,
api_key="",
additional_args={"complete_input_dict": data, "request_str": request_str},
)
response = client.invoke_model(
body=data,
modelId=model,

View file

@ -920,7 +920,7 @@ def test_completion_sagemaker():
print(response)
except Exception as e:
pytest.fail(f"Error occurred: {e}")
test_completion_sagemaker()
# test_completion_sagemaker()
def test_completion_chat_sagemaker():
try:
@ -934,7 +934,7 @@ def test_completion_chat_sagemaker():
print(response)
except Exception as e:
pytest.fail(f"Error occurred: {e}")
test_completion_chat_sagemaker()
# test_completion_chat_sagemaker()
def test_completion_bedrock_titan():
try:
@ -991,7 +991,7 @@ def test_completion_bedrock_cohere():
pass
except Exception as e:
pytest.fail(f"Error occurred: {e}")
# test_completion_bedrock_cohere()
test_completion_bedrock_cohere()
def test_completion_bedrock_claude_completion_auth():
@ -1028,7 +1028,7 @@ def test_completion_bedrock_claude_completion_auth():
pass
except Exception as e:
pytest.fail(f"Error occurred: {e}")
# test_completion_bedrock_claude_completion_auth()
test_completion_bedrock_claude_completion_auth()
# def test_completion_bedrock_claude_external_client_auth():
# print("calling bedrock claude external client auth")