Skip to content

Commit 4c30fb7

Browse files
committed
Add Promptathon script and update related configurations
- Introduced a new script for running a virtual prompt hackathon, including participant and judge management, submission processes, and feedback mechanisms. - Updated `README.md` to include instructions for the new `promptathon` command. - Modified `cli.py` to register the new command and its description. - Added dependencies for the `promptathon` script in `_script_dependencies.py`. - Enhanced `config_wizard.py` to include configuration options for the promptathon. - Created a new file `.cursorrules` detailing guidelines for adding new scripts to the repository.
1 parent bd1c2d1 commit 4c30fb7

File tree

7 files changed

+575
-0
lines changed

7 files changed

+575
-0
lines changed

.cursorrules

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Tool-Use Repository Development Guidelines
2+
3+
## Creating a New Script
4+
5+
To add a new script to the tool-use repository, you need to modify several files:
6+
7+
1. Create a new script file in `src/tool_use/scripts/`:
8+
9+
Example: src/tool_use/scripts/my_script.py
10+
from ..utils.ai_service import AIService
11+
from ..config_manager import config_manager
12+
def main(args):
13+
config_values = config_manager.get_tool_config("script_name")
14+
# Your script implementation
15+
pass
16+
if __name__ == "__main__":
17+
try:
18+
main()
19+
except KeyboardInterrupt:
20+
console.print("\n[yellow]Operation cancelled by user.[/yellow]")
21+
sys.exit(0)
22+
except Exception as e:
23+
console.print(f"\n[red]An unexpected error occurred: {e}[/red]")
24+
sys.exit(1)
25+
26+
2. Add dependencies to `src/tool_use/scripts/_script_dependencies.py`:
27+
28+
SCRIPT_DEPENDENCIES = {
29+
# ... existing dependencies ...
30+
"my-script": ["required-package1", "required-package2"]
31+
}
32+
33+
3. Add configuration in `src/tool_use/utils/config_wizard.py`:
34+
SCRIPT_INFO = {
35+
# ... existing scripts ...
36+
"my-script": {
37+
"name": "My Script",
38+
"description": "What your script does",
39+
"config_keys": [
40+
{
41+
"key": "my_config_key",
42+
"prompt": "Enter configuration value:",
43+
"description": "What this config value does",
44+
"required": True
45+
}
46+
]
47+
}
48+
}
49+
50+
4. Update `src/tool_use/cli.py`:
51+
- Add to `all_scripts` dictionary
52+
- Add to `script_modules` mapping
53+
54+
5. Add script to `README.md`
55+
56+
## Using AIService
57+
58+
The AIService utility (`src/tool_use/utils/ai_service.py`) provides a standardized way to interact with AI models. Example usage from prioritize.py:
59+
60+
from ..utils.ai_service import AIService
61+
# Initialize the service
62+
ai = AIService()
63+
# Simple completion
64+
response = ai.query("Your prompt here")
65+
66+
67+
#Structured output
68+
69+
class Example(BaseModel):
70+
example: str = Field(description="example")
71+
72+
class StructuredOutput(BaseModel):
73+
"""Example description for the structured output, keys can be any pydantic supported field"""
74+
field1: str = Field(description="First field for the output")
75+
field2: List[Example] = Field(description="List of examples")
76+
77+
# Structured outputs only supported by openai
78+
ai_service = AIService(service_type="openai")
79+
response = ai_service.query_structured(prompt, StructuredOutput, system_prompt)
80+
81+
field1, field2 = response
82+
83+
## Script Best Practices
84+
85+
1. Use config_manager for settings:
86+
87+
from ..config_manager import config_manager
88+
config_values = config_manager.get_tool_config("script_name")
89+
90+
2. Handle arguments properly:
91+
def main(args):
92+
print("Usage: tool-use my-script [args]")
93+
return
94+
95+
3. Provide clear error messages and user feedback
96+
97+
4. Follow existing patterns for consistency:
98+
- Use relative imports
99+
- Handle dependencies through SCRIPT_DEPENDENCIES
100+
- Provide configuration through config_wizard
101+
- Document usage in script's docstring
102+
103+
104+
# Error Handling
105+
Make sure to handle errors gracefully and provide clear error messages to the user.
106+
107+
108+
# Formatting
109+
- Use Rich when possible to display print statements in a visually appealing way
110+
111+
## Common Patterns
112+
113+
1. AI Integration:
114+
- Use AIService for AI interactions
115+
- Structure prompts clearly
116+
- Handle API errors gracefully
117+
118+
2. Configuration:
119+
- Use config_wizard for user settings
120+
- Validate config values
121+
- Provide clear configuration prompts
122+
123+
3. CLI Integration:
124+
- Follow existing argument patterns
125+
- Provide help text
126+
- Handle invalid inputs gracefully

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ Use the webcam and a tiny vision model to analyze your posture and focus.
100100
ai posture
101101
```
102102

103+
### 9. Promptathon (`ai promptathon`)
104+
105+
Create a virtual prompt hackathon with AI judges and mentors.
106+
107+
```bash
108+
ai promptathon
109+
```
110+
103111
## Tool Use Tools (`tooluse` command)
104112

105113
### 1. Podcast RSS Reader (`tooluse`)

src/tool_use/cli.py

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def main():
4444
"log": "Track your activities",
4545
"marketing-plan": "Use a marketing agency of AI agents to create a marketing plan",
4646
"posture": "Use the webcam and a tiny vision model to analyze your posture and focus",
47+
"promptathon": "Run a virtual prompt hackathon"
4748
}
4849

4950
for name, help_text in all_scripts.items():
@@ -80,6 +81,7 @@ def main():
8081
"log": "activity_tracker",
8182
"marketing-plan": "marketing_agency",
8283
"posture": "posture",
84+
"promptathon": "promptathon"
8385
}
8486

8587
# Dynamic import of only the needed module

src/tool_use/scripts/_script_dependencies.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@
4444
"llama-index",
4545
"llama-index-llms-ollama",
4646
],
47+
"promptathon": ["rich"]
4748
}

0 commit comments

Comments
 (0)