Below, you can find code snippets that show how to use PyGEAI's The Lab Module to create, retrieve, list, update, publish and delete Reasoning Strategies.
Initiate AILabManager interface to create a Reasoning Strategy. Define the strategy with a name, system_prompt, access_scope, type, localized_descriptions in multiple languages.
from pygeai.lab.models import ReasoningStrategy, LocalizedDescription
manager = AILabManager()
strategy = ReasoningStrategy(
name="RSName3",
system_prompt="Let's think step by step.",
access_scope="private",
type="addendum",
localized_descriptions=
LocalizedDescription(language="spanish", description="RSName spanish description"),
LocalizedDescription(language="english", description="RSName english description"),
LocalizedDescription(language="japanese", description="RSName japanese description")
)
result = manager.create_reasoning_strategy(
strategy=strategy,
automatic_publish=True
)
print(f"Created: {result.name}, ID: {result.id}")
Start AILabManager to Retrieve a Reasoning Strategy by its reasoning_strategy_id.
from pygeai.lab.managers import AILabManager
from pygeai.lab.models import ReasoningStrategy
manager = AILabManager()
result = manager.get_reasoning_strategy(
reasoning_strategy_id="2b757122-3e36-499d-909e-87074c3afc94"
)
print(f"Retrieved: {result.name}, ID: {result.id}")
Use AILabManager to list Reasoning Strategies in a Projectr. Apply filter_settings (start, count, allow_external, access_scope) to retrieve up to 100 strategies.
from pygeai.lab.managers import AILabManager
from pygeai.lab.models import FilterSettings, ReasoningStrategyList
manager = AILabManager()
filter_settings = FilterSettings(
# name="RSName2",
start="0",
count="100",
allow_external=True,
access_scope="private"
)
result = manager.list_reasoning_strategies(filter_settings)
print(f"Found {len(result.strategies)} strategies:")
for strategy in result.strategies:
print(f"Name: {strategy.name}, ID: {strategy.id}")
Use AILabManager to update an existing Reasoning Strategy.
Define the Reasoning Strategy with its id, name, system_prompt, access_scope, type, localized_descriptions and update it.
from pygeai.lab.managers import AILabManager
from pygeai.lab.models import ReasoningStrategy, LocalizedDescription
strategy = ReasoningStrategy(
id="2b757122-3e36-499d-909e-87074c3afc94",
name="RSName3",
system_prompt="Let's think step by step.",
access_scope="private",
type="addendum",
localized_descriptions=
LocalizedDescription(language="spanish", description="RSName spanish description"),
LocalizedDescription(language="english", description="RSName english description"),
LocalizedDescription(language="japanese", description="RSName japanese description")
)
manager = AILabManager()
strategy.system_prompt = "Updated step-by-step thinking."
result = manager.update_reasoning_strategy(
strategy=strategy,
automatic_publish=False,
upsert=False
)
print(f"Updated: {result.name}, Prompt: {result.system_prompt}")