11import asyncio
2- from pgml import Collection ,Model ,Splitter ,Pipeline
2+ from pgml import Collection ,Model ,Splitter ,Pipeline , migrate , init_logger
33import logging
44from rich .logging import RichHandler
55from rich .progress import track
@@ -121,6 +121,7 @@ async def generate_response(
121121messages ,openai_api_key ,temperature = 0.7 ,max_tokens = 256 ,top_p = 0.9
122122):
123123openai .api_key = openai_api_key
124+ log .debug ("Generating response from OpenAI API: " + str (messages ))
124125response = openai .ChatCompletion .create (
125126model = "gpt-3.5-turbo" ,
126127messages = messages ,
@@ -170,7 +171,7 @@ async def chat_cli():
170171response = await generate_response (
171172messages ,openai_api_key ,max_tokens = 512 ,temperature = 0.0
172173 )
173- print ("PgBot: " + response )
174+ log . info ("PgBot: " + response )
174175
175176user_input = input ("User (Ctrl-C to exit): " )
176177except KeyboardInterrupt :
@@ -241,8 +242,8 @@ async def run():
241242 The `main` function connects to a database, ingests documents from a specified folder, generates
242243 chunks, and logs the total number of documents and chunks.
243244 """
244- print ("Starting pgml-chat.... " )
245-
245+ log . info ("Starting pgml-chat.... " )
246+ # await migrate()
246247if stage == "ingest" :
247248root_dir = args .root_dir
248249await ingest_documents (root_dir )
@@ -255,6 +256,7 @@ async def run():
255256
256257
257258def main ():
259+ init_logger ()
258260if (
259261stage == "chat"
260262and chat_interface == "discord"