def generate_llm()

in genai-design-marketing-studio/generative.py [0:0]


def generate_llm(model_name: str, system_instruction: str, prompt: str) -> tuple:
    """
    Generic interface for LLM 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
    :return: (generated output as string, grounding information)
    """
  
    # Init the model
    model = GenerativeModel(
        model_name,
        system_instruction=[system_instruction]
    )

    # Get the response
    response = model.generate_content(
        [prompt],
        generation_config = GenerationConfig(
            temperature=0.0,
        ),
        safety_settings=safety_settings,
        tools=tools,
        stream=False
    )

    return (response.text, response.candidates[0].grounding_metadata.search_entry_point.rendered_content)