Files
wehub-resource-sync 85742ab165
Deploy Documentation / deploy (push) Has been cancelled
CPU Test / Test (Utilities, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (LLM proxy, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Others, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Store, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Utilities, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Weave, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (AgentOps, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (LLM proxy, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (Others, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (Weave, latest, Python 3.13) (push) Has been cancelled
Dashboard / Chromatic (push) Has been cancelled
CPU Test / Lint - fast (push) Has been cancelled
CPU Test / Lint - next (push) Has been cancelled
CPU Test / Lint - slow (push) Has been cancelled
CPU Test / Lint - JavaScript (push) Has been cancelled
CPU Test / Build documentation (push) Has been cancelled
CPU Test / Test (AgentOps, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (LLM proxy, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (Others, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (Store, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (Weave, legacy, Python 3.10) (push) Has been cancelled
CPU Test / Test (AgentOps, stable, Python 3.11) (push) Has been cancelled
CPU Test / Test (Store, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (Utilities, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (Weave, stable, Python 3.12) (push) Has been cancelled
CPU Test / Test (AgentOps, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (LLM proxy, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (Others, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (Store, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (Utilities, latest, Python 3.13) (push) Has been cancelled
CPU Test / Test (JavaScript) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:44:17 +08:00

54 lines
1.8 KiB
Python

# Copyright (c) Microsoft. All rights reserved.
import argparse
import pandas as pd
from aoai_finetune import AzureOpenAIFinetune
from capital_agent import capital_agent
from rich.console import Console
from agentlightning import TraceToMessages, Trainer, setup_logging
console = Console()
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Train Capital Agent with Azure OpenAI Finetuning")
parser.add_argument("--n-iterations", type=int, default=3, help="Number of finetuning iterations")
parser.add_argument("--cleanup", action="store_true", help="Cleanup finetuned deployments after training")
return parser.parse_args()
def main():
setup_logging()
args = parse_args()
finetune_algo = AzureOpenAIFinetune(
base_deployment_name="gpt-4.1-mini",
finetuned_deployment_name="gpt-4.1-mini-ft",
base_model_name="gpt-4.1-mini-2025-04-14",
finetune_every_n_rollouts=24,
data_filter_ratio=0.6,
n_iterations=args.n_iterations,
)
trainer = Trainer(n_runners=2, algorithm=finetune_algo, adapter=TraceToMessages())
dataset = pd.read_csv("capital_samples.csv") # type: ignore
train_dataset = dataset.sample(frac=0.8, random_state=42) # 80% for training # type: ignore
val_dataset = dataset.drop(train_dataset.index) # Remaining 20% for validation # type: ignore
console.print(f"Training on {len(train_dataset)} samples, validating on {len(val_dataset)} samples.") # type: ignore
try:
trainer.fit(
capital_agent,
train_dataset=train_dataset.to_dict(orient="records"), # type: ignore
val_dataset=val_dataset.to_dict(orient="records"), # type: ignore
)
finally:
if args.cleanup:
finetune_algo.cleanup_deployments()
if __name__ == "__main__":
main()