1
0

files.py 627 B

123456789101112131415161718192021
  1. from open_webui.routers.images import (
  2. load_b64_image_data,
  3. upload_image,
  4. )
  5. def get_image_url_from_base64(request, base64_image_string, metadata, user):
  6. if "data:image/png;base64" in base64_image_string:
  7. image_url = ""
  8. # Extract base64 image data from the line
  9. image_data, content_type = load_b64_image_data(base64_image_string)
  10. if image_data is not None:
  11. image_url = upload_image(
  12. request,
  13. image_data,
  14. content_type,
  15. metadata,
  16. user,
  17. )
  18. return image_url
  19. return None