Coder Social home page Coder Social logo

shamspias / customizable-gpt-chatbot Goto Github PK

View Code? Open in Web Editor NEW
341.0 11.0 82.0 235 KB

A dynamic, scalable AI chatbot built with Django REST framework, supporting custom training from PDFs, documents, websites, and YouTube videos. Leveraging OpenAI's GPT-3.5, Pinecone, FAISS, and Celery for seamless integration and performance.

Python 99.56% HTML 0.44%
artificial-intelligence chatbot data-preprocessing django django-rest-framework gpt-3 machine-learning nlp python conversational-ai

customizable-gpt-chatbot's People

Contributors

shamspias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

customizable-gpt-chatbot's Issues

get_user_model

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\gptchat-env\Lib\site-packages\django\apps\config.py", line 235, in get_model
    return self.models[model_name.lower()]
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
KeyError: 'user'

django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'users.User' that has not been installed

Question about db and os.env

For database, did you build it with Postgres?
and for OS system environment path, do you have a list for it? What should I add?

Thanks,

ValueError: Dependency on app with no migrations: users

Still trying this is my .env

ENV_NAME='local'

# TEMPORARY SECRET - DO NOT USE THIS
DJANGO_SETTINGS_MODULE=config.settings.local
DJANGO_SECRET_KEY='django-insecure-z#p-sa90q*k(n9xh632k@rgo=sd3@589=(%l8xpn=c-+yr&q=0'
DJANGO_DEBUG=True

# Database
DB_NAME=dbname
DB_USER=mysuer
DB_PASSWORD=mypass
DB_HOST=localhost
DB_PORT=5432

# Celery
CELERY_BROKER_URL = 'redis://localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'

# Email
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=''
EMAIL_PORT=587
EMAIL_FROM=""

SITE_URL=http://localhost:8000
SITE_ID=1


# CORS
CSRF_COOKIE_SECURE=True
SESSION_COOKIE_SECURE=True
CSRF_COOKIE_HTTPONLY=False
SESSION_COOKIE_HTTPONLY=True
SESSION_COOKIE_SAMESITE="None"
CSRF_COOKIE_SAMESITE="None"
CORS_ALLOW_CREDENTIALS=True
CORS_ORIGIN_ALLOW_ALL=False
CSRF_COOKIE_NAME="csrftoken"
CORS_ALLOWED_ORIGINS=http://127.0.0.1:3000,http://localhost:3000
CSRF_TRUSTED_ORIGINS=http://127.0.0.1:3000,http://localhost:3000

# Security

X_FRAME_OPTIONS='DENY'
SECURE_BROWSER_XSS_FILTER=True

# GENERALS
AUTH_USER_MODEL=users.CustomUser
LANGUAGE_CODE="en-us"
APPEND_SLASH=True
TIME_ZONE='UTC'
USE_I18N=True
USE_TZ=True
USE_L10N=True

# Social
FACEBOOK_KEY=''
FACEBOOK_SECRET=''
GOOGLE_KEY=''
GOOGLE_SECRET=''

# Other API
OPEN_AI_KEY='sk-****************************************'
PINECONE_API_KEY='****************************************'
PINECONE_ENVIRONMENT='asia-northeast1-gcp'
PINECONE_INDEX_NAME='customchat'
PINECONE_NAMESPACE_NAME=''
SENTRY_DSN=''

# AWS
AWS_ACCESS_KEY=''
AWS_SECRET_KEY=''
REGION_NAME=''
QUEUE_NAME=''

DJANGO_AWS_STORAGE_BUCKET_NAME=''


# Admin Site Config
ADMIN_SITE_HEADER="Chatbot"
ADMIN_SITE_TITLE="Chatbot Dashboard"
ADMIN_SITE_INDEX="Chatbot Dashboard"

# RASA

RASA_API_URL = "http://localhost:5005/model/parse"

# OAuth2 settings
APPLICATION_NAME = "Chatbot"


LOGIN_REDIRECT_URL = "/"
when i run celery:
(venv) ivanvilches@MacBook-Air-de-Ivan customizable-gpt-chatbox-v2 % celery -A config worker --loglevel=info
 
 -------------- [email protected] v5.2.7 (dawn-chorus)
--- ***** ----- 
-- ******* ---- macOS-12.4-arm64-arm-64bit 2023-04-21 19:30:41
- *** --- * --- 
- ** ---------- [config]
- ** ---------- .> app:         customize_chatgpt:0x106402510
- ** ---------- .> transport:   redis://localhost:6379/0
- ** ---------- .> results:     redis://localhost:6379/0
- *** --- * --- .> concurrency: 8 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .> celery           exchange=celery(direct) key=celery
                

[tasks]
  . chatbot.tasks.generate_title_request
  . chatbot.tasks.send_gpt_request
  . users.tasks.send_forgot_password_email

[2023-04-21 19:30:42,183: INFO/MainProcess] Connected to redis://localhost:6379/0
[2023-04-21 19:30:42,185: INFO/MainProcess] mingle: searching for neighbors
[2023-04-21 19:30:43,196: INFO/MainProcess] mingle: all alone
[2023-04-21 19:30:43,217: WARNING/MainProcess] /Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/celery/fixups/django.py:203: UserWarning: Using settings.DEBUG leads to a memory
            leak, never use this setting in production environments!
  warnings.warn('''Using settings.DEBUG leads to a memory

[2023-04-21 19:30:43,217: INFO/MainProcess] [email protected] ready.
s

when i run:
mes@MacBook-Air-de-Ivan customizable-gpt-chatbox-v2 % source venv/bin/activate
(venv) me@MacBook-Air-de-Ivan customizable-gpt-chatbox-v2 % python manage.py runserver
INFO Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 187, in check_key
return self.graph.root_nodes(key[0])[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/homebrew/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/opt/homebrew/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/core/management/commands/runserver.py", line 136, in inner_run
self.check_migrations()
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/core/management/base.py", line 574, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/db/migrations/executor.py", line 18, in init
self.loader = MigrationLoader(self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 58, in init
self.build_graph()
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 250, in build_graph
self.add_external_dependencies(key, migration)
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 214, in add_external_dependencies
parent = self.check_key(parent, key[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ivanvilches/Documents/proyectos/AI/customizable-gpt-chatbox-v2/venv/lib/python3.11/site-packages/django/db/migrations/loader.py", line 194, in check_key
raise ValueError(
ValueError: Dependency on app with no migrations: users

Can't found the app

Hi,

I am following your instruction to run the source code. But here is an issue:

celery -A customizableGpt3Chatbot worker --loglevel=info
Usage: celery [OPTIONS] COMMAND [ARGS]...
Try 'celery --help' for help.

Error: Invalid value for '-A' / '--app':
Unable to load celery application.
The module customizableGpt3Chatbot was not found.

Anything wrong for me? Thank you.

License type.

Hello,

What license is this project under? Is it the MIT license?

Kind regards.

running but missing chatbot UI (seeing only the fastAPI/swagger on http://127.0.0.1:8000

  1. if helpful i had to go through a few extra steps to migrate user and other data when setting up postgres

specifically

python manage.py migrate

Operations to perform:
  Apply all migrations: admin, auth, contenttypes, django_celery_results, oauth2_provider, sessions, sites, social_django, users
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK

plus many other

and

python manage.py makemigrations users

on first setup

anyhow,

when completed and celery running on redis and manage on postgres i get the fastAPI page (swagger) on http://127.0.0.1:8000 but no chatbot or front end. is this supposed to be a chatbot API project (bring your own chatbot to hookup) or is the chatbot UI itslef included in the runtime?

i see the chat folders and many files so i assumed there would be a front end. not sure what i missed.
thanks for your help

Suggestion: Add API support

It would be great to have API support to be able pass docs/webpages via API and query it via API too, to integrate with external tools.
Great work!

Has anyone gotten this up an running

Mind you I am not a master at code, but familiar with most of python and can usually reverse engineer my way through things. I am not familiar with Django yet and having issues trying to get this even to run locally on my computer. I'm repeatedly coming across celery and django errors. Not sure what I can do to rectify and where to go from here. HELP!

issue installing pycurl

I'm getting this issue when trying to install the requirements, any help would be appreciated.

Collecting pycurl (from -r requirements.txt (line 18))
  Using cached pycurl-7.45.2.tar.gz (234 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 10
  ╰─> [1 lines of output]
      Please specify --curl-dir=/path/to/built/libcurl
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Mac m1 install fails.

debug if helpful

The error you're encountering seems to be due to Django not being able to find the 'User' model in the 'users' app. The error message AUTH_USER_MODEL refers to model 'users.User' that has not been installed suggests that Django is looking for a User model in an application named 'users', but cannot find it.

However, from the installation instructions you've followed, there doesn't seem to be any specific configuration related to the 'users' app or the User model:

Clone the repository: git clone https://github.com/shamspias/customizable-gpt-chatbot
Install the required packages: pip install -r requirements.txt
Run celery: celery -A config worker --loglevel=info
Run the Django server: python manage.py runserver
Open http://127.0.0.1:8000/ in your browser​0git clone [https://github.com/shamspias/customizable-gpt-chatbot\n](https://github.com/shamspias/customizable-gpt-chatbot%60%5Cn) * Install the required packages by running pip install -r requirements.txt\n * Run celery celery -A config worker --loglevel=info\n * Run the command python manage.py runserver\n * Open http://127.0.0.1:8000/ in your browser\n\nIn linux and mac need to install 'sudo apt install python3-dev -y","pub_date":null}}​.
Additional instructions for Linux and Mac installations involve the installation of development libraries for libcurl and the latest versions of pip and setuptools, and the installation of pycurl​0sudo apt-get install libcurl4-openssl-dev gcc libssl-dev -y\n 2. Make sure that you have the latest version of pip and setuptools installed by running the following command: pip install --upgrade pip setuptools\n 3. pip install pycurl","pub_date":null}}`​.

These instructions don't mention the creation or configuration of a 'users' app or a User model. If these are required for the project, they might be missing from the instructions or from the codebase itself.

Here are a few suggestions to troubleshoot this issue:

Check the Django settings: Django uses the AUTH_USER_MODEL setting in the settings.py file to determine which model to use for authentication. It should be in the format AppName.ModelName. If you have access to the codebase, verify that AUTH_USER_MODEL is set correctly.

Check the 'users' app: If the AUTH_USER_MODEL is set to 'users.User', verify that there is a 'users' app in the project and it contains a User model. If the 'users' app doesn't exist, you need to create it and define a User model in it. If the 'users' app exists but doesn't contain a User model, you need to create one.

Check the installed apps: In the settings.py file, there should be a list of installed apps (INSTALLED_APPS). Verify that 'users' is included in this list.

Check the database migrations: Django uses database migrations to create database tables corresponding to your models. If the 'users' app and User model exist but the corresponding database table doesn't, you might need to create a migration and apply it using the python manage.py makemigrations users and python manage.py migrate users commands.

If none of these suggestions work, there might be an issue with the codebase itself, and you might need to contact the maintainers of the project for further assistance.

Mac question about Installation libcurl4-openssl-dev gcc libssl-dev -y

Hello, in mac is the same process for? :
In linux need to install pip install pycurl' and 'sudo install python3-dev -y

Make sure that you have the development libraries for libcurl installed on your system. You can install them by running the following command: sudo apt-get install libcurl4-openssl-dev gcc libssl-dev -y

Thanks you

Ui chat?

I think i ran the deploy the project well on mac. But the only i can see is swagger on localhost:8000
No chat design or ui functionality?
Thanks

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.