Passing context to the model

#16
by Mahendranath - opened

How to pass the context to the model along with the input text? What should be the structure of messages?

Google org

Hi @Mahendranath -

Thanks for reaching out to us!

For google/translategemma-4b-it , the model expects a structured message format with only user and assistant roles and a fixed schema. Each user message must include a single content entry with fields such as type where the property where the value must be either text or image, source_lang_code, target_lang_code.

The content list entry should provide either a url property, if the entry's type is image, from which the image will be loaded or a text property, if the entry's type is text, containing only the text to translate.

Example:

messages = [
    {
        "role": "user",
        "content": [
         {
                "type": "text",
                "source_lang_code": "cs",
                "target_lang_code": "de-DE",
                "text": "V nejhorším případě i k prasknutí čočky.",
            }
       ],
    }
]

Update: it's a vLLM issue.

Hello @sonali-kumari11 ,

When using the same format, I get the following error:

{"error":{"message":"User role must provide `content` as an iterable with exactly one item. That item must be a `mapping(type:'text' | 'image', source_lang_code:string, target_lang_code:string, text:string | none, image:string | none)`.","type":"BadRequestError","param":null,"code":400}}

Sign up or log in to comment