Skip to content

Commit

Permalink
[send.py][logging]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Mar 10, 2024
1 parent 46dad48 commit 3250cb7
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions scripts/send.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import requests
import base64
import json
from PIL import Image
from io import BytesIO
from swarms.utils.loguru_logger import logger

# Convert image to Base64
def image_to_base64(image_path):
Expand All @@ -26,7 +24,7 @@ def image_to_base64(image_path):
"content": [
{
"type": "text",
"text": "What’s in this image?"
"text": "Whats in this image?"
},
{
"type": "image_url",
Expand All @@ -42,21 +40,15 @@ def image_to_base64(image_path):
"max_tokens": 1024,
}
except Exception as error:
logger.error(f"Error in sending image to base64: {error}")
raise Exception(f"Error in sending image to base64: {error}")


raise Exception(f"Error in constructing request data: {error}")
# Specify the URL of your FastAPI application
url = 'http://18.208.184.237:8000/v1/chat/completions'

# Send the request
try:
response = requests.post(url, json=request_data)
except Exception as error:
logger.error(f"Error in sending request to the server: {error}")
raise Exception(f"Error in sending request to the server: {error}")

# Print the response from the server
print(response.text)
logger.info(response)
logger.info(response.text)

0 comments on commit 3250cb7

Please sign in to comment.