/Personal-Chatbot

A simple personal chatbot using OpenAI's GPT-3.5-turbo and Gradio. It allows for interactive conversations, logs chat history to a text file, and features a customizable UI. Easy setup with Python, ideal for experimenting with AI-driven dialogue systems.

Primary LanguagePython

Personal Chatbot

This repository contains a simple personal chatbot built using OpenAI's GPT-3.5-turbo model and Gradio for the user interface. The chatbot allows for interactive conversations and saves the conversation history to a text file.

Features

  • Interactive Chat: Engage in conversations with the chatbot using OpenAI's language model.
  • Conversation History: Automatically saves the conversation history in a text file.
  • Customizable UI: Simple user interface built with Gradio.

Setup

Prerequisites

  • Python 3.7+
  • Install the required packages:
    pip install openai gradio

Configuration

  1. OpenAI API Setup:
    Replace "add base" with your OpenAI API base URL and "add your key" with your OpenAI API key in the script.

    openai.api_base = "https://api.openai.com/v1"
    openai.api_key = "your-api-key"
  2. Run the Chatbot:

    python your_script.py

    Replace your_script.py with the filename of your Python script.

How It Works

  • Message Handling: The chatbot saves the first message as the filename (limited to the first 20 characters) to store the conversation.
  • Conversation Logging: Each message and its corresponding response are logged in a text file named after the first message.

Usage

  • Launch the chatbot UI:
    • After running the script, a Gradio UI will open in your browser where you can start chatting with the bot.
    • The chat history is displayed, and you can interact by typing messages.

Example Usage

  1. Start a conversation: Type your message in the textbox and click "Send."
  2. View conversation history: The conversation history is stored in a .txt file with the filename based on the first message you typed.

Acknowledgments

  • OpenAI for providing the GPT-3.5-turbo model.
  • Gradio for creating an easy-to-use interface for machine learning models.