How to setup system_instruction=" " dynamicly?!

i want to dynamicly change system_instruction after model initialisation but, i can’t find any examples, Help

This code does not work :frowning:

model = genai.GenerativeModel(
    system_instruction="You are a helpful assistant. Never use emojis. You can save files using functions!",
    model_name='gemini-1.5-flash-latest',  # Choose your desired Gemini model
    safety_settings={'HARASSMENT': 'block_none'},
)
def main():
    from GEMINI_IMPROVED import tool_manager as tool_manager
    system_instruction= """
        You are a helpful assistant. Never use emojis. You can save files using functions! 
        Always remember the user's first request and use it to guide your actions and responses. 
        You should never use emojis in your responses. "
        You have access to the following tools: directory_report, execute_script, save_to_file. 
        Use these tools appropriately to assist the user."""

    chat_session = model.start_chat(history=[],system_instruction=system_instruction)

Hi @Dev_DevFuFu, I don’t think you can update the system instructions once the chat session is defined. If you want to update the system instructions you have to define a new chat session if you want previous chat session history you can pass that history to this new chat session. Please refer to this gist for code example. Thank You.