Giter Site home page Giter Site logo

truonganhhoang / friendlychatbotassistant Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zainabzaman/friendlychatbotassistant

0.0 0.0 0.0 249 KB

A friendly chatbot assistant developed through gpt-3.5-turbo. It can talk to you as a friend, a mentor, a sister and many other roles each made specific and based on the context of that particular user through the user class defined in the code.

Python 100.00%

friendlychatbotassistant's Introduction

FriendlyChatbotAssistant

This Python script implements an enhanced chatbot using the OpenAI gpt-3.5-turbo model. The chatbot features user management, context storage, keyword detection, fetching results from google search, multiple roles interaction and response modifications for a more engaging conversation.

Features

  • User Class: Manages user contexts, creates new users, saves/loads existing conversation contexts and history, and handles token limits.
  • Multiple Roles: The uer can select from multiple roles that include friend, mentor, sister and a few others which make the chatbot interact in a way that particular role would interact.
  • Context Storage: Utilizes pickle for saving and loading conversation contexts.
  • Token Management: Tracks the number of tokens and if the number of tokens exceede 15500 the context and history for that particular ID is reset and the chatbot suggests the user to continue the conversation later.
  • Keyword Detection: Identifies specific keywords to trigger actions like people_also_ask to get search results directly from google.
  • Response Modifications: Adjusts responses based on triggers for a more interactive conversation.
  • Error Handling: Addresses cases with empty responses or no matches to predefined patterns.

Usage

  1. Set Up OpenAI API Key: Replace 'YOUR_OPENAI_API_KEY' with your actual OpenAI GPT-3.5 Turbo API key.
  2. Run the Script: Execute the script and interact with the chatbot by providing the user_ID, chatbot name you want to set, chatbot role you want to set and message.

Dependencies

  • openai: OpenAI Python library for API integration.
  • tiktoken: Python library for counting tokens in a text string.
  • people_also_ask: External API for fetching results from the people also ask section from google search results.
  • nltk: Natural Language Toolkit for tokenization.
  • datetime: Python module for working with dates and times.
  • pickle: Python module for object serialization.

Example

Below are a few examples of the chatbot interacting as a friend!

alt text

alt text

alt text

Implementation

Before executing any of the coe files run the following command to install the required packages

pip install -r requirements.txt

Execute the following command to implement chatbot with multiple roles

python chatbot_function_withCharacter_roles.py

To implement a chatbot that can fetch results from google search's people also ask section execute the following command

python chatbot_user_google_search.py

Acknowledgments

  • The Openai gpt-3.5-turbo is used for chatbot's response generations.
  • The people_also_ask library is used to fetch results from Google search.

friendlychatbotassistant's People

Contributors

zainabzaman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.