LLM blueprints¶
LLM blueprints define how large language models are configured and used in your generative AI applications. You can use pre-configured LLMs provided by DataRobot or create custom model LLMs from your own deployments. LLM blueprints allow you to configure system prompts, temperature settings, and other parameters that control how the LLM behaves in your applications.
List available LLMs¶
To see all available LLMs, use datarobot.LLMDefinition.list():
import datarobot as dr
llms = dr.genai.LLMDefinition.list()
for llm in llms:
print(f"{llm.name}: {llm.description}")
print(f" Vendor: {llm.vendor}")
print(f" Context size: {llm.context_size}")
print(f" Active: {llm.is_active}")
You can also filter LLMs by Use Case:
use_case = dr.UseCase.get(use_case_id)
llms = dr.genai.LLMDefinition.list(use_case=use_case)
Create a playground¶
Playgrounds are required to create LLM blueprints. A playground is a workspace where you can experiment with different LLM configurations. When creating a playground, you should specify the following:
name: A user-friendly name for the playground.description: An optional description of the playground's purpose.use_case: A Use Case to link the playground to.playground_type: The type of playground, defaults todr.enums.PlaygroundType.RAG.
import datarobot as dr
playground = dr.genai.Playground.create(
name="My GenAI Playground",
use_case=use_case.id
)
playground
You can also create a playground in a Use Case:
use_case = dr.UseCase.get(use_case_id)
playground = dr.genai.Playground.create(
name="Use Case Playground",
use_case=use_case.id
)
Create an LLM blueprint¶
Create a new LLM blueprint with custom settings. When creating an LLM blueprint, you should specify the following:
playground: The playground ID or Playground object to associate the blueprint with.name: A user-friendly name for the LLM blueprint.llm: The LLM definition ID or LLMDefinition object to use.llm_settings: A dictionary containing LLM configuration settings such as system prompts, temperature, and max completion length.description: An optional description of the blueprint.prompt_type: The prompting strategy, defaults todr.enums.PromptType.CHAT_HISTORY_AWARE.
import datarobot as dr
llms = dr.genai.LLMDefinition.list()
gpt4 = [llm for llm in llms if 'gpt-4' in llm.name.lower()][0]
playground = dr.genai.Playground.create(name="Customer Support Playground")
blueprint = dr.genai.LLMBlueprint.create(
playground=playground.id,
name="Customer Support Assistant",
description="LLM for customer support queries",
llm=gpt4.id,
llm_settings={
"system_prompt": "You are a helpful customer support assistant. Be concise and professional.",
"temperature": 0.7,
"max_completion_length": 500
}
)
blueprint
Retrieve and list LLM blueprints¶
Get a specific blueprint or list all available blueprints using datarobot.LLMBlueprint.get() and datarobot.LLMBlueprint.list().
To retrieve a specific blueprint:
blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
blueprint
To list all blueprints:
all_blueprints = dr.genai.LLMBlueprint.list()
print(f"Found {len(all_blueprints)} LLM blueprint(s):")
for bp in all_blueprints:
print(f" - {bp.name} (ID: {bp.id})")
To filter blueprints by playground:
playground_blueprints = dr.genai.LLMBlueprint.list(playground=playground.id)
To filter by LLM type:
gpt_blueprints = dr.genai.LLMBlueprint.list(llms=[gpt4.id])
Update an LLM blueprint¶
Modify blueprint settings using datarobot.LLMBlueprint.update():
blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
blueprint.update(
name="Updated Customer Support Assistant",
llm_settings={
"system_prompt": "You are an expert customer support assistant.",
"temperature": 0.5
}
)
Save the blueprint to lock settings:
blueprint.update(is_saved=True)
Star the blueprint for easy access:
blueprint.update(is_starred=True)
Create a blueprint from an existing blueprint¶
Create a copy of an existing blueprint to experiment with variations using datarobot.LLMBlueprint.create_from_llm_blueprint():
original_blueprint = dr.genai.LLMBlueprint.get(blueprint_id)
new_blueprint = dr.genai.LLMBlueprint.create_from_llm_blueprint(
llm_blueprint=original_blueprint,
name="Experimental Variant",
description="Testing different temperature settings"
)
new_blueprint