Upload pdf file containing text, image & source code

How can I upload a PDF file of text, image & source code and get an answer out of it?

i am reading a pdf file from streamlit then converting it into base64 but I am not sure if its taking those images as well

def convert_pdf_to_base64(file_path):
    Converts a file to base64 encoding.

        file_path (str): The path to the file.

        str: The base64 encoded string of the file.
    with open(file_path, "rb") as pdf_file:
        encoded_string = base64.b64encode(pdf_file.read())
    return encoded_string

uploaded_file = st.file_uploader("Choose a pdf/doc file",

if uploaded_file is not None:
        # read the doc/pdf file & reference file
        save_path = Path(uploaded_file.name)
        with open(save_path, mode='wb') as w:

        if submitted:
            with st.spinner("Please wait..."):

                pdf_data = convert_pdf_to_base64(save_path)
                base_prompt = "generate test scripts & automation script for given data"
                chat_completion = client.chat.completions.create(
                        {"role": "system", "content": base_prompt},
                            "role": "user",
                            "content": (
                                f"{prompt}\nBase64 representation of pdf: {pdf_data}"[: 100000]

Also, it takes around 100000 tokens so I am truncating but that’s a big disadvantage for me.

Is there any method to do this better?

Could you please provide me complete flow