Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi turn issue #413

Open
codeMonkey-shin opened this issue Oct 17, 2024 · 1 comment
Open

multi turn issue #413

codeMonkey-shin opened this issue Oct 17, 2024 · 1 comment

Comments

@codeMonkey-shin
Copy link

The model seems to need to transmit as many images as there are questions.

Otherwise, you just keep repeating your previous answer.

I would like to have a conversation without images, but upload images only when necessary. Is this impossible?

@gxlover0625
Copy link

Might the code below will give you some ideas about how to construct conversations about pure text, single image, multiple images

def parse_input(self, query = None, imgs = None):
        """
        Parses the input query and images into the expected format.

        Parameters
        ----------
        query : str, optional
            The query from the user.
        imgs : list or str, optional
            A list of images or a single image path.

        Returns
        -------
        list of dict
            A list containing the messages formatted for the model.
        """
        if imgs is None:
            messages = [
                {"role": "user", "content": query},
            ]
            return messages
        
        if isinstance(imgs, str):
            imgs = [imgs]
        
        content = []
        for img in imgs:
            content.append({
                "type": "image",
                "image": img
            })
        content.append({
            "type": "text",
            "text": query
        })

        messages = [
            {"role": "user", "content": content},
        ]
        return messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants