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.

    Args:
        file_path (str): The path to the file.

    Returns:
        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",
                                     type=["pdf"])

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:
            w.write(uploaded_file.getvalue())

        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(
                    messages=[
                        {"role": "system", "content": base_prompt},
                        {
                            "role": "user",
                            "content": (
                                f"{prompt}\nBase64 representation of pdf: {pdf_data}"[: 100000]
                            ),
                        },
                    ],
                    model="gpt-4o",
                )
            print(chat_completion.choices[0].message.content)

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