-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
81 lines (65 loc) · 2.74 KB
/
main.py
File metadata and controls
81 lines (65 loc) · 2.74 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
#!/usr/bin/env python3
"""
Interview Preparation Agentic Tool
Uses FunctionCallingAgent with tools for flexible, intelligent interview preparation.
"""
from agent import InterviewPrepAgent
import asyncio
from llama_index.core.workflow import (
InputRequiredEvent,
HumanResponseEvent
)
import warnings
from pydantic.warnings import PydanticDeprecatedSince20
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20)
async def interactive_chat():
"""Run an interactive chat session with the agent."""
print("🚀 Starting Interview Prep Agent...")
print("=" * 50)
# Create agent instance
prep_agent = InterviewPrepAgent()
# After agent initialization, re-apply warning filters
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20)
print("\n🤖 Agent: Hello! I'm your interview preparation assistant.")
print("Let me check what context information we have...")
# Check initial status
status = prep_agent.get_context_status()
print(f"\n{status}")
print("\nI can help you with:")
print("- Loading your CV (PDF file)")
print("- Loading job description (text file)")
print("- Loading interviewer information (text file)")
print("- Generating interview questions")
print("\nJust tell me what you'd like to do in natural language!")
print("(Type 'quit' to exit)")
while True:
user_input = input("\n👤 You: ").strip()
if user_input.lower() in ['quit', 'exit', 'bye']:
print("🤖 Agent: Goodbye! Good luck with your interview preparation!")
break
# Let the agent handle everything through natural language
try:
handler = prep_agent.agent.run(user_input)
async for event in handler.stream_events():
if isinstance(event, InputRequiredEvent):
response = input(f"{event.prefix}: ")
handler.ctx.send_event(
HumanResponseEvent(response=response)
)
result = await handler
print(f"\n🤖 Agent: {result}")
except Exception as e:
print(f"\n🤖 Agent: I encountered an error: {str(e)}")
print("Please try again or rephrase your request.")
async def main():
"""Main function to run the interactive agent."""
try:
await interactive_chat()
except KeyboardInterrupt:
print("\n\n🤖 Agent: Session interrupted. Goodbye!")
except Exception as e:
print(f"❌ Error: {str(e)}")
if __name__ == "__main__":
asyncio.run(main())