From 256630961b4b4490cf3b172871d6771b312accc7 Mon Sep 17 00:00:00 2001 From: Farouk Adeleke Date: Sun, 19 Oct 2025 19:39:57 -0400 Subject: [PATCH] Complete Migration --- README.md | 84 ++++++------------ agent/__pycache__/__init__.cpython-310.pyc | Bin 171 -> 171 bytes agent/__pycache__/agent.cpython-310.pyc | Bin 4080 -> 4080 bytes agent/__pycache__/constants.cpython-310.pyc | Bin 2398 -> 2398 bytes agent/__pycache__/helpers.cpython-310.pyc | Bin 2501 -> 2501 bytes .../__pycache__/hill_climbing.cpython-310.pyc | Bin 2379 -> 2379 bytes agent/__pycache__/models.cpython-310.pyc | Bin 3268 -> 3268 bytes agent/__pycache__/modules.cpython-310.pyc | Bin 5095 -> 5095 bytes agent/__pycache__/utils.cpython-310.pyc | Bin 5557 -> 5557 bytes agent/agent.py | 7 +- 10 files changed, 30 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index c57dff7..ad44693 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ A composable DSPy agent that optimizes tweets using a reflective generate-evalua - **Customizable Categories**: Define evaluation criteria (engagement, clarity, tone, etc.) - **Multiple Usage Modes**: Single generation, full optimization, or standalone evaluation - **Structured Evaluation**: 1-9 scoring with detailed reasoning per category -- **CLI Compatibility**: Same functionality as the original CLI tool - **Easy Configuration**: Flexible model, iteration, and patience settings ## Installation @@ -48,22 +47,10 @@ from tweet_optimizer_agent import TweetOptimizerAgent, TweetOptimizerConfig # Create agent with default settings config = TweetOptimizerConfig() -agent = TweetOptimizerAgent(config) +tweet_optimizer = TweetOptimizerAgent(config) -# Single tweet generation -tweet = agent( - input_text="Create a tweet about HuggingFace transformers", - current_tweet="", - previous_evaluation=None -) -print(f"Generated: {tweet}") -``` - -### Full Optimization Process - -```python -# Run complete optimization (like CLI) -results = agent.optimize( +# run complete optimization +results = tweet_optimizer( input_text="Create a tweet about HuggingFace transformers", iterations=10, patience=5 @@ -75,6 +62,12 @@ print(f"Score: {results['best_score']:.2f}") print(f"Iterations: {results['iterations_run']}") ``` +### Full Optimization Process + +```python + +``` + ### Custom Configuration ```python @@ -94,20 +87,6 @@ config = TweetOptimizerConfig( agent = TweetOptimizerAgent(config) ``` -### Tweet Evaluation - -```python -# Evaluate a specific tweet -evaluation = agent.evaluate_tweet( - tweet_text="Excited to share our new AI model!", - original_text="We released a new AI model", - current_best_tweet="" -) - -for eval in evaluation.evaluations: - print(f"{eval.category}: {eval.score}/9 - {eval.reasoning}") -``` - ### Deploy to Modaic Hub ```python @@ -122,38 +101,27 @@ agent.push_to_hub( ### Load from Hub ```python -# Load a pre-trained agent from Modaic Hub -agent = TweetOptimizerAgent.from_precompiled("your-username/tweet-optimizer") +# Load this pre-trained agent from Modaic Hub +from modaic import AutoAgent + +tweet_optimizer = AutoAgent.from_precompiled("farouk1/tweet-optimizer-v2") # Use immediately -optimized = agent("Your tweet content here") +results = tweet_optimizer( + input_text="Your tweet content here", + iterations=20, + patience=7 +) + +print(f"Original: {results['initial_text']}") +print(f"Optimized: {results['final_tweet']}") +print(f"Score: {results['best_score']:.2f}") +print(f"Iterations: {results['iterations_run']}") ``` -## CLI Tool +### Configuration Options -The original CLI functionality is still available: - -```bash -# Basic usage -python cli.py "Create a tweet about AI breakthroughs" - -# With custom settings -python cli.py "Product launch announcement" \ - --model "Claude Sonnet 4.5" \ - --iterations 15 \ - --patience 8 \ - --categories "Excitement" "Clarity" "Call-to-action" - -# List available models -python cli.py --list-models - -# Quiet mode (output only final tweet) -python cli.py "Content here" --quiet -``` - -## Configuration Options - -### TweetOptimizerConfig +#### TweetOptimizerConfig | Parameter | Type | Default | Description | |------------------|-----------|----------------------------------------|---------------------------------------------| @@ -202,7 +170,6 @@ This Modaic agent implementation is based on the original DSPy Tweet Optimizer b - Core DSPy modules (TweetGeneratorModule, TweetEvaluatorModule) - Hill-climbing optimization algorithm -- CLI interface and utilities - Comprehensive testing framework **Original Author**: Tom Doerr ([@tom-doerr](https://github.com/tom-doerr)) @@ -213,5 +180,4 @@ This Modaic agent implementation is based on the original DSPy Tweet Optimizer b - Packaged as a Modaic PrecompiledAgent - Added hub deployment functionality - Enhanced configuration options -- Maintained CLI compatibility - Extended usage examples \ No newline at end of file diff --git a/agent/__pycache__/__init__.cpython-310.pyc b/agent/__pycache__/__init__.cpython-310.pyc index 992044a3f79d05b6054fd4e71ab99e0c7ac4b1bc..260d9c74f5a1e25b98902451d5dbf73b880b953c 100644 GIT binary patch delta 18 YcmZ3@xSEkGpO=@50SJ~APUKn$045LwNdN!< delta 18 YcmZ3@xSEkGpO=@50SI`5Cvq(W03w?Mk^lez diff --git a/agent/__pycache__/agent.cpython-310.pyc b/agent/__pycache__/agent.cpython-310.pyc index 0af2856bc61267f5d545e989f0725be364850fd7..251de634f64719215ff3b3cb7d8769196d196320 100644 GIT binary patch delta 18 Ycmew$|3RKJpO=@50SK0Db%7 diff --git a/agent/__pycache__/constants.cpython-310.pyc b/agent/__pycache__/constants.cpython-310.pyc index 05184b208b2d002ed71ee3a4a837174bc4104280..46f0c3e91257818a196ea8cf84e7b24c595cdda3 100644 GIT binary patch delta 19 Zcmca7bWeyYpO=@50SJ~AZsZE#1OPL(1g!u7 delta 19 Zcmca7bWeyYpO=@50SMO0ZR85!1OPHY1YrOG diff --git a/agent/__pycache__/helpers.cpython-310.pyc b/agent/__pycache__/helpers.cpython-310.pyc index fbc935494c13c7b471dee0fb887b4de5c7d4bf4c..212e7bd0e33696c7bc471410ba5bbd2b9189ca35 100644 GIT binary patch delta 19 ZcmX>qd{me#pO=@50SJ~AZsgj{2>>x71mpk! delta 19 ZcmX>qd{me#pO=@50SKlgZ{*s|2>>vB1jYaW diff --git a/agent/__pycache__/hill_climbing.cpython-310.pyc b/agent/__pycache__/hill_climbing.cpython-310.pyc index f66105c94857ea9afa637178076f538290d45305..93468391604c611c554987eaa815fe08284437bc 100644 GIT binary patch delta 19 ZcmX>tbXtfjpO=@50SJ~AZsc<01OPDP1atrZ delta 19 ZcmX>tbXtfjpO=@50SNk%H*z_00st@$1Wo_| diff --git a/agent/__pycache__/models.cpython-310.pyc b/agent/__pycache__/models.cpython-310.pyc index f2dbae892a678eda29d650fd2ccb99f78c1f5d55..d6f8f20408b439d5931964b07d2104569063d6dd 100644 GIT binary patch delta 19 ZcmX>ic|?*cpO=@50SJ~AZsgj<0{}701n>X= delta 19 ZcmX>ic|?*cpO=@50SMZXH*)Rb0RS+?1i}CS diff --git a/agent/__pycache__/modules.cpython-310.pyc b/agent/__pycache__/modules.cpython-310.pyc index 1de1ab06d195c95e56dc5c7b48d0642c240fa494..04a7d291aca11a1073486e98d99e96be2b6fce6e 100644 GIT binary patch delta 19 ZcmaE^{#>0apO=@50SJ~AZsfWv3;;Ob1$+Pi delta 19 ZcmaE^{#>0apO=@50SIc6H*(z-1^_pn1w;S< diff --git a/agent/__pycache__/utils.cpython-310.pyc b/agent/__pycache__/utils.cpython-310.pyc index ae3d1174f22395ac5ed8c5b595511ee5e75ef8ad..d5d51f00c4529ed64812ca80a33dc29e9aab12bc 100644 GIT binary patch delta 19 Zcmdn0y;YklpO=@50SJ~AZsb}m3IH+w1n>X= delta 19 Zcmdn0y;YklpO=@50SFqCH*&2O1pqMG1ib(N diff --git a/agent/agent.py b/agent/agent.py index c88cdb3..d5cf78b 100644 --- a/agent/agent.py +++ b/agent/agent.py @@ -37,6 +37,9 @@ class TweetOptimizerAgent(PrecompiledAgent): self.lm = config.lm self.eval_lm = config.eval_lm + self.categories = config.categories + self.max_iterations = config.max_iterations + self.patience = config.patience # initialize DSPy with the specified model self.tweet_generator.set_lm(get_dspy_lm(config.lm)) @@ -49,8 +52,8 @@ class TweetOptimizerAgent(PrecompiledAgent): patience: Optional[int] = None ) -> str: """Run full optimization process.""" - max_iterations = iterations or self.config.max_iterations - patience_limit = patience or self.config.patience + max_iterations = iterations or self.max_iterations + patience_limit = patience or self.patience results = { 'initial_text': input_text,