-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gemini.py
More file actions
114 lines (88 loc) Β· 3.51 KB
/
Copy pathtest_gemini.py
File metadata and controls
114 lines (88 loc) Β· 3.51 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env python3
"""
Test script to verify Gemini AI integration
"""
import os
import sys
from dotenv import load_dotenv
# Add src to path
sys.path.append('src')
# Load environment variables
load_dotenv()
def test_gemini_connection():
"""Test basic Gemini connection"""
try:
from src.utils.ai_client import AIClient
print("π§ͺ Testing Gemini AI Connection...")
# Check if API key is set
api_key = os.getenv("GOOGLE_API_KEY")
if not api_key:
print("β GOOGLE_API_KEY not found in environment")
print(" Please set your Google API key in .env file")
return False
print(f"β
API Key found: {api_key[:10]}...")
# Initialize AI client
ai_client = AIClient()
print("β
AI Client initialized")
# Test simple generation
test_prompt = "What is 2+2? Answer in one word."
print(f"π Testing with prompt: {test_prompt}")
response = ai_client.generate_content(test_prompt)
print(f"π€ Gemini Response: {response}")
if response and len(response.strip()) > 0:
print("β
Gemini AI is working correctly!")
return True
else:
print("β Empty response from Gemini")
return False
except Exception as e:
print(f"β Error testing Gemini: {str(e)}")
return False
def test_agent_structure():
"""Test agent structure without AI calls"""
try:
from src.agents.data_collection_agent import DataCollectionAgent
from src.models.startup import StartupInput
print("\nπ§ͺ Testing Agent Structure...")
# Create test startup input
test_startup = StartupInput(
company_name="Test Company",
business_description="A test business for validation"
)
# Create agent
agent = DataCollectionAgent()
print(f"β
Created {agent.name}")
# Test prompt creation
prompt = agent._create_prompt(test_startup)
print(f"β
Generated prompt: {len(prompt)} characters")
# Test system instruction
system_instruction = agent._create_system_instruction()
print(f"β
Generated system instruction: {len(system_instruction)} characters")
print("β
Agent structure is working correctly!")
return True
except Exception as e:
print(f"β Error testing agent structure: {str(e)}")
return False
def main():
"""Run all tests"""
print("π Startup Analyst Platform - Gemini Integration Test\n")
# Test 1: Agent Structure
agent_ok = test_agent_structure()
# Test 2: Gemini Connection (only if API key is available)
gemini_ok = test_gemini_connection()
print("\nπ Test Results:")
print(f" Agent Structure: {'β
PASS' if agent_ok else 'β FAIL'}")
print(f" Gemini Connection: {'β
PASS' if gemini_ok else 'β FAIL'}")
if agent_ok and gemini_ok:
print("\nπ All tests passed! Ready for deployment.")
return True
elif agent_ok:
print("\nβ οΈ Agent structure works, but Gemini needs API key setup.")
print(" Set GOOGLE_API_KEY in .env file to test AI integration.")
return True
else:
print("\nβ Tests failed. Check the errors above.")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)