33User registration and management for Stackademy.
44"""
55
6+ from typing import Optional , Tuple
7+
68from .logging_config import get_logger , setup_logging
79from .prompt import completion
810
1113logger = get_logger (__name__ )
1214
1315
14- def main () :
16+ def main (prompts : Optional [ Tuple [ str , ...]] = None ) -> None :
1517 """Main function to demonstrate user registration."""
18+ print ("=" * 50 )
1619 print ("Stackademy User Registration Demo" )
1720 print ("=" * 50 )
1821
19- user_prompt = input ("Welcome to Stackademy! How can I assist you today? " )
22+ i = 0
23+ user_prompt = prompts [i ] if prompts else input ("Welcome to Stackademy! How can I assist you today? " )
2024
2125 response , functions_called = completion (prompt = user_prompt )
2226 while response .choices [0 ].message .content != "Goodbye!" :
27+ i += 1
2328 message = response .choices [0 ].message
2429 response_message = message .content or ""
2530 logger .info ("ChatGPT: %s" , response_message .strip ())
@@ -34,9 +39,17 @@ def main():
3439 followup_question = None
3540
3641 if "get_courses" in functions_called :
37- user_prompt = input (followup_question or "Would you like to register for a course? " )
42+ user_prompt = (
43+ prompts [i ]
44+ if prompts and len (prompts ) >= i
45+ else input (followup_question or "Would you like to register for a course? " )
46+ )
3847 elif "register_course" in functions_called :
39- user_prompt = input (followup_question or "Can I help you with anything else? " )
48+ user_prompt = (
49+ prompts [i ]
50+ if prompts and len (prompts ) >= i
51+ else input (followup_question or "Can I help you with anything else? " )
52+ )
4053
4154 response , functions_called = completion (prompt = user_prompt )
4255
0 commit comments