Skip to content
Discussion options

You must be logged in to vote

@dionysis11 Thank you very much. This problem has been troubling me for a week.
Here's the full code. It works well.

import base64

from langchain_core.tools import tool


def image_to_base64(image_path: str) -> str:
    with open(image_path, "rb") as image_file:
        encoded_string = base64.b64encode(image_file.read())
        return encoded_string.decode('utf-8')


def do_screenshot_and_save_it_to_local_disk():
    # Pretend that this function will take a screenshot and return the path of the image.
    return "/path/to/pic.png"


@tool
def get_screenshot():
    picture_path = do_screenshot_and_save_it_to_local_disk()
    return [
        {"type": "image_url", "image_url": {"url": f"…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Harshbansal8705
Comment options

@polavishnu4444
Comment options

Answer selected by LetianYuan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants