-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_test.py
More file actions
86 lines (71 loc) · 2.95 KB
/
quick_test.py
File metadata and controls
86 lines (71 loc) · 2.95 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env python3
"""Quick production test with ONE simple requirement to verify API integration"""
import os
import asyncio
from dotenv import load_dotenv
load_dotenv()
def test_single_api_call():
"""Test ONE real API call with minimal cost"""
print("🧪 Testing Single API Call (Production Mode)")
print("-" * 45)
try:
# Test OpenAI first (usually faster)
if os.getenv("OPENAI_API_KEY"):
print("Testing OpenAI with minimal prompt...")
import openai
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-3.5-turbo", # Cheapest model
messages=[{
"role": "system",
"content": "You are a product analyst. Be concise."
}, {
"role": "user",
"content": "Is 'add search functionality' a good feature? One sentence."
}],
max_tokens=30, # Limit cost
temperature=0.7
)
print(f"✅ OpenAI Response: {response.choices[0].message.content}")
print(f"💰 Tokens used: ~{response.usage.total_tokens}")
return True
except Exception as e:
print(f"❌ OpenAI test failed: {e}")
# Try Anthropic as backup
try:
if os.getenv("ANTHROPIC_API_KEY"):
print("Testing Anthropic...")
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-3-haiku-20240307", # Cheapest Claude model
max_tokens=30,
messages=[{
"role": "user",
"content": "Is 'add search functionality' a good feature? One sentence."
}]
)
print(f"✅ Anthropic Response: {response.content[0].text}")
return True
except Exception as e2:
print(f"❌ Anthropic test failed: {e2}")
return False
return False
def main():
print("🛡️ ReqDefender Production Test")
print("=" * 35)
print("Testing with ONE simple API call first...")
print()
if test_single_api_call():
print("\n✅ SUCCESS! API integration working!")
print("\n🎯 Next Steps:")
print("1. Run web interface: python launcher.py web")
print("2. Test with simple requirement: 'Add search functionality'")
print("3. Use 'Quick' mode to minimize API usage")
print("4. Monitor costs in your API provider dashboard")
print("\n💡 Start with simple requirements before testing complex ones!")
else:
print("\n❌ API integration failed. Check your API keys in .env file")
if __name__ == "__main__":
main()
#built with love