in genai-design-marketing-studio/generative.py [0:0]
def generate_lmm(model_name: str, system_instruction: str, prompt: str, uploaded_metadata: tuple) -> str:
"""
Generic interface for LMM applications
:param model_name: name of the model to be used as string
:param system_instruction: system instruction as string
:param prompt: instructions as string
:param uploaded_metadata: (mime-type, image gcs uri)
:return: generated output as string
"""
# Init the model
model = GenerativeModel(
model_name,
system_instruction=[system_instruction]
)
mime_type, uri = uploaded_metadata
# Encode the image content
image = Part.from_uri(
mime_type=mime_type,
uri=uri
)
# Get the response
response = model.generate_content(
[image, prompt],
generation_config=generation_config,
safety_settings=safety_settings,
stream=False
)
return (response.text)