Delete neural_network/chatbot/main.py

This commit is contained in:
Pritam Das 2024-10-20 11:41:49 +05:30 committed by GitHub
parent f8510d702e
commit fb102e6ef2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,44 +0,0 @@
from db import Database, ChatDatabase
from llm_service import LLMService
from chatbot import Chatbot
from typing import NoReturn
def main() -> NoReturn:
"""
Main function to initialize and start the chatbot application.
This function initializes the database and LLM service, creates necessary tables, and starts
the chatbot for user interaction.
"""
# Initialize and configure the database
db = Database()
chat_db = ChatDatabase(db)
chat_db.create_tables()
# Set the API service to either "Together" or "Groq"
api_service = (
"Groq" # Can be set dynamically based on user preference or environment
)
llm_service = LLMService(api_service)
# Initialize the Chatbot with the database and LLM service
chatbot = Chatbot(chat_db, llm_service)
print("Welcome to the chatbot! Type '/stop' to end the conversation.")
chatbot.start_chat()
# Chat loop to handle user input
while True:
user_input = input("\nYou: ")
if user_input.strip().lower() == "/stop":
chatbot.end_chat() # End the conversation if user types "/stop"
break
chatbot.handle_user_message(
user_input
) # Process user input and generate response
chatbot.continue_chat() # Handle long conversations (trim history if necessary)
if __name__ == "__main__":
main()