Closed axnsantana closed 3 months ago
@jzaldi
We were expecting a multipart message, but it makes sense to support string context for this model so I'll add the support in #393.
In the meanwhile this snippet works:
from langchain_google_vertexai.vision_models import VertexAIImageGeneratorChat
from langchain_core.prompts import ChatPromptTemplate, HumanMessagePromptTemplate
model = VertexAIImageGeneratorChat()
prompt = ChatPromptTemplate.from_messages(
[
HumanMessagePromptTemplate.from_template(template=[
{"type": "text", "text": "I want an image of {img_object} in {img_context}."}
])
]
)
chain = prompt | model
response = chain.invoke(dict(img_object="cat", img_context="beach"))
print(response)
I am replicating the code in langchain docs but using a chain.
Code to replicate error
Traceback
BUG
The bug is in a validation point in this code
In the chain, the message content is a string and not a list as in the example from langchain docs. Thus, any usable prompt string will have length greater more than 1
Library versions
platform: macOS 12.7 python version: 3.9.16