Update main()

Call chat_loop at the end of main() to hand off to the interactive session

💻

Writing code and entering commands is only available on desktop. Open this page on a larger screen to complete this chapter.

Two phases, one program

main() now has two distinct phases:

  • Setup — parse the folder argument, resolve the cache path, create the client, and either load embeddings from cache or index the folder and save a new cache.
  • Run — hand off to chat_loop, which stays alive until the user quits.

One line at the end of main() connects the two phases. The loop runs until Ctrl+C or until you add an explicit quit command in a later lesson.

Instructions

  1. At the end of main(), after the if cached / else block, call chat_loop(client, chunks, embeddings).