mirror of
https://github.com/tiennm99/litellm.git
synced 2026-06-18 00:48:01 +00:00
4d941c914e
* rename ResponsesSessionHandler * use ResponsesSessionHandler * test session handler * refactor ResponsesSessionHandler * fix get_proxy_server_request_from_spend_log * use constant for LITELLM_TRUNCATED_PAYLOAD_FIELD * add _should_check_cold_storage_for_full_payload * add get_class_type_for_custom_logger_name * get_active_custom_logger_for_callback_name * add get_proxy_server_request_from_cold_storage to CustomLogger * add ColdStorageHandler * start using cold storage integration * add get_proxy_server_request_from_cold_storage * fixes from manual testing * s3 v2 fix getting region name * ChatCompletionImageUrlObject * use _get_configured_cold_storage_custom_logger * fixes for _should_check_cold_storage_for_full_payload * fix _download_object_from_s3 * test_s3_v2_with_cold_storage * add cold_storage_object_key to StandardLoggingMetadata * use get_proxy_server_request_from_cold_storage_with_object_key * add cold_storage_object_key to SpendLogsMetadata * add cold_storage_object_key * get_proxy_server_request_from_cold_storage_with_object_key * use get_proxy_server_request_from_cold_storage_with_object_key * test responses API * add get_proxy_server_request_from_cold_storage_with_object_key * session handler fixes * test session handler * fix ruff checks * _download_object_from_s3 * cleanup * test * lint fix * test_e2e_cold_storage_successful_retrieval * test_e2e_generate_cold_storage_object_key_successful * test_async_gcs_pub_sub_v1 * test fix * test fix * test fix * test_standard_logging_metadata_has_cold_storage_object_key_field * test_sanitize_request_body_for_spend_logs_payload_basic * test_transform_input_image_item_to_image_item_with_image_data
54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
import base64
|
|
from openai import OpenAI
|
|
import time
|
|
client = OpenAI(
|
|
base_url="http://0.0.0.0:4001",
|
|
api_key="sk-1234"
|
|
)
|
|
|
|
# Function to encode the image
|
|
def encode_image(image_path):
|
|
with open(image_path, "rb") as image_file:
|
|
return base64.b64encode(image_file.read()).decode("utf-8")
|
|
|
|
|
|
# Path to your image
|
|
image_path = "litellm/proxy/logo.jpg"
|
|
|
|
# Getting the Base64 string
|
|
base64_image = encode_image(image_path)
|
|
|
|
|
|
response = client.responses.create(
|
|
model="bedrock/us.anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
input=[
|
|
{
|
|
"role": "user",
|
|
"content": [
|
|
{ "type": "input_text", "text": "what color is the image"},
|
|
{
|
|
"type": "input_image",
|
|
"image_url": f"data:image/jpeg;base64,{base64_image}",
|
|
},
|
|
],
|
|
}
|
|
],
|
|
)
|
|
|
|
|
|
|
|
print(response.output_text)
|
|
print("response1 id===", response.id)
|
|
print("sleeping for 20 seconds...")
|
|
time.sleep(20)
|
|
print("making follow up request for existing id")
|
|
response2 = client.responses.create(
|
|
model="bedrock/us.anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
previous_response_id=response.id,
|
|
input="ok, and what objects are in the image?"
|
|
)
|
|
|
|
print(response2.output_text)
|
|
|
|
|