Repository navigation
Expand file tree
/
Copy pathtest_server.py
More file actions
43 lines (36 loc) · 1.54 KB
/
Copy pathtest_server.py
File metadata and controls
43 lines (36 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import asyncio
import os
import json
from dotenv import load_dotenv
# Mocking the MCP server calls for a quick test without spinning up the full server process yet,
# or better yet, importing the functions directly to test logic.
# Since FastMCP uses decorators, we can often call the functions directly if we import them.
from server import instant_improve, deep_optimize, TaskType
async def main():
print("Testing SimplePromptOptimizer...")
test_prompt = "Make a landing page for my dog walking business"
print(f"\n--- Test Prompt: '{test_prompt}' ---")
# Test 1: Instant Improve
print("\n[Testing instant_improve]...")
try:
result_json = instant_improve(prompt=test_prompt, task_type=TaskType.CODING)
result = json.loads(result_json)
print("SUCCESS")
print(f"Original: {result['original']}")
print(f"Optimized (preview): {result['optimized'][:100]}...")
except Exception as e:
print(f"FAILED: {e}")
# Test 2: Deep Optimize
print("\n[Testing deep_optimize]...")
try:
# Note: deep_optimize is synchronous in the server code (OpenAI client is sync)
result_json = deep_optimize(prompt=test_prompt, critique=True)
result = json.loads(result_json)
print("SUCCESS")
if "analysis" in result:
print(f"Critique (preview): {result['analysis'][:100]}...")
print(f"Final Prompt (preview): {result['final_prompt'][:100]}...")
except Exception as e:
print(f"FAILED: {e}")
if __name__ == "__main__":
asyncio.run(main())