chatbot-webraft


Namechatbot-webraft JSON
Version 1.0.2 PyPI version JSON
download
home_page
SummaryA package for building chatbots easily without needing of any high system resources.
upload_time2024-01-15 06:07:20
maintainer
docs_urlNone
author
requires_python>=3.6
licenseMIT License Copyright (c) 2024 Webraft_ChatBot Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords artificial intelligence ai ai code ai code generator ai writer bot chat bot chat bot library chatbot chatbotwebraft chatgpt chatter code generator code writer generator transformer webraft
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # WebraftChatBot
The "chatbot-webraft" Python module is a powerful tool that allows users to create their own chatbots with custom datasets in an easy and efficient manner. 
It is designed to work with CSV datasets and provides a variety of model types to choose from, ensuring that users can select the best model for their specific needs. 
The module requires no high-end servers and can be used with or without training, making it a flexible and cost-effective solution for chatbot development. 
With the "chatbot-webraft" module, users can quickly and easily develop their own chatbots, customizing the dataset and model type to fit their specific requirements. 
Whether you're a beginner or an experienced developer, the "chatbot-webraft" module provides a simple and intuitive way to create custom chatbots with Python due to its easy to use syntax.

One of the best features of Chatbot-Webraft is its ability to generate code scripts in specific programming languages from text. This means that you can use your preferred programming language, 
or even write your own code, and Chatbot-Webraft will convert it into a script that is ready to use. Whether you are an experienced developer or just starting out, this feature makes it easy to 
build chatbots quickly and efficiently.

In summary, Chatbot-Webraft is a must-have tool for anyone looking to create chatbots. With its wide range of features, including multiple model types, easy customization, and code generation capabilities,
Chatbot-Webraft is the perfect tool for anyone looking to build chatbots with ease and efficiency.

**PLEASE NOTE THAT THIS MODULE IS IN BETA AND CHATBOTS CREATED WITH IT MAY RESPOND WITH UNEXPECTED ANSWERS**

### **USAGE:**
#### Import library
```from chatbot_webraft import chatbot```

##### Create Model
```chatbot.create_model("my-model")```

##### Load  CSV DATASET (here 'input' needs to be replaced with the column in dataset that has the fields containing the data to be inputted same to be done with 'label' but with fields containing the data to be outputted. )
```chatbot.dataset(CSV_FILE_NAME,'input','label',"my-model"") ```

##### Add more data to chatbot(OPTIONAL)
```chatbot.add_data("my-model"",["input1","input2"],["output1","output2"]) ```

##### Specify Input
```input = "hi"``` / ```input = input("Enter: ")```
##### Run chatbot (for default set MODEL_TYPE to "spimx")
```print(chatbot.model_load(MDDEL_TYPE,input,"my-model",MDDEL_TYPE))```/```chatbot.model_load(MDDEL_TYPE,input,"my-model",MDDEL_TYPE)``` 
##### Use codewriter (currently python supported)
```print(codewriter("python",input,"my-model","pywriter")``` / ```chatbot.model_load("pywriter",input,"my-model","pywriter")```

### **Model Types:**
Inbuilt model types: nlpm (Generative, Best) , spimx (better), spimxr (more good), spim (good), rasv (not that good)

You can use other model types by downloading them from [here]("https://models.chatbot.webraft.in") and define path where modeltype (.wrmodel) file is stored to MODEL_TYPE

NLPM: A generative model type (framework) , works best for generative bots . (BETA)
NLPM USAGE: ```chatbot.model_load("nlpm",input,"my-model",MODELTYPE)``` - Replace `MODELTYPE` with the other modeltype that suites you the best , i.e - spim , spimx , rasv , spim (do not replace MODELTYPE with 'nlpm' rather replace with others)

There is also a transformer modified framework that uses Tokenizers from prebuilt transfomer model i.e - BERT . Note that it needs very high system for running and takes a lot of time to load. USE - ```chatbot.model_load("bert",input,"my-model","bert)``` (It doesnt need training)
### **Basic BOT Usage:**
 ```
 #Import library
from chatbot_webraft import chatbot

#set model name
model = "my-model" 

#create model
chatbot.create_model(model)

#load CSV dataset , Mention input column (question) and label column (answer)
chatbot.dataset(CSV_FILE_NAME,INPUT_COLUMN,LABEL_COLUMN,model) 


#run in loop
while True:
  prompt = input("You: ")    
  #run model and parse input
  print("Bot: ",chatbot.model_load("spimx",prompt,model,"spimx")) 

 ```

 ### **Bot usage for discord:**
```
#Import libraries
from chatbot_webraft import chatbot
import discord 
client = discord.Client(intents=discord.Intents.all())


model = "my-model" #set model name
chatbot.create_model(model) #create model
chatbot.dataset(CSV_FILE_NAME,INPUT_COLUMN,LABEL_COLUMN,model) #load CSV dataset .. Mention input column (question) and label column (answer)
chatbot.add_data(model,["hey","what about you"],["hello bro","im fine ,you?"]) #add more data to model (Not saved , only in memory). Data that you may want to add later.
@client.event
async def on_message(message):
    if message.author == client.user:
        return

    prompt = message.content
    
    await message.reply(chatbot.model_load("spim",prompt,model,"spim")) #run model and parse output
client.run(BOT_TOKEN)
```
### **Basic codewriter usage:**
```
 #Import library
from chatbot_webraft import chatbot

#set model name
model = "my-model" 

#create model
chatbot.create_model(model)

#load CSV dataset , Mention input column (question) and label column (answer)
chatbot.dataset(CSV_FILE_NAME,INPUT_COLUMN,LABEL_COLUMN,model) 


#run in loop
while True:
  prompt = input("You: ")    
  #run model and parse input
  print("Bot: ",chatbot.model_load("pywriter",prompt,model,"pywriter")) #Or codewriter("python",prompt,model,"pywriter")
```
### **Train Your own Model**

In versions < 1.0.0 you can now train / finetune your own language models through minimal code.

Here is a basic example of pre training on chat data (using language data is advised):
**Before trying, download the sample dataset given below. (after the code)**

```
from chatbot_webraft.yourmodel import TransformerModel
import torch

d_model = 128 # Adjust according to your needs and system specs

dataset_name = "sample.csv"  # Replace with your correct dataset path

input_set = "input"

label_set = "label"

batch_size = 16 # Adjust according to your needs and system specs

heads = 16 # Adjust according to your needs and system specs

num_layers = 6 # Adjust according to your needs and system specs

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

epochs = 40  

path = "path/to/folder/" # Eg. D:/Softwares/AI/Trainer/

model_name= path+"yourmodelname" # Eg. chatllm
transformer_model = TransformerModel(d_model, dataset_name, input_set, label_set, batch_size, heads, num_layers, device, epochs, model_name, max_len=256)
transformer_model.train() # Finally training

question = "hi"

print(transformer_model.inference(question)) # Doing Inference
```

You can also do inference already trained model but you require to initialise transformer model with that checkpoint and use same parameters (i.e. d_model, heads, num_layers, max_len)

```
checkpoint = torch.load(path+model_name+"_final.pth",map_location=device)
transformer = checkpoint['transformer']
transformer_model = TransformerModel(d_model, dataset_name, input_set, label_set, batch_size, heads, num_layers, device, epochs, model_name, max_len=256,transformer=transfromer)
```

You can also fine tune the model by just changing the dataset_name at initialising of new model and doing `transformer_model.finetune()`.


### **SAMPLE CSV DATASET:**
Download Sample csv dataset from [here](https://webraft.in/sample.csv) , Dont forget to put the file in your project directory
<br>
Change `CSV_FILE_NAME` to "sample.csv" , `INPUT_COLUMN` to "input" , `LABEL_COLUMN` to "label" in the code

### **Errors:**
Error 1 - This error indicates that the model name used in specific function is not same as the modelname set with chatbot.createmodel() 
<br>
Error 2 - This error indicates that the codewriter couldn't convert specific text to code due to lack of resources 
<br>
Error 3 - This error indicates that the file being set in any of these functions: chatbot.dataset() , chatbot.model_load() doesn't exist 
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "chatbot-webraft",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "Artificial intelligence,ai,ai code,ai code generator,ai writer,bot,chat bot,chat bot library,chatbot,chatbotwebraft,chatgpt,chatter,code generator,code writer,generator,transformer,webraft",
    "author": "",
    "author_email": "Webraft <team@webraft.in>",
    "download_url": "https://files.pythonhosted.org/packages/c7/37/bd7cab1c4bbed5ef6afab03f696d85dd01ef73cdc00c59c549b860d2b7b7/chatbot_webraft-1.0.2.tar.gz",
    "platform": null,
    "description": "# WebraftChatBot\nThe \"chatbot-webraft\" Python module is a powerful tool that allows users to create their own chatbots with custom datasets in an easy and efficient manner. \nIt is designed to work with CSV datasets and provides a variety of model types to choose from, ensuring that users can select the best model for their specific needs. \nThe module requires no high-end servers and can be used with or without training, making it a flexible and cost-effective solution for chatbot development. \nWith the \"chatbot-webraft\" module, users can quickly and easily develop their own chatbots, customizing the dataset and model type to fit their specific requirements. \nWhether you're a beginner or an experienced developer, the \"chatbot-webraft\" module provides a simple and intuitive way to create custom chatbots with Python due to its easy to use syntax.\n\nOne of the best features of Chatbot-Webraft is its ability to generate code scripts in specific programming languages from text. This means that you can use your preferred programming language, \nor even write your own code, and Chatbot-Webraft will convert it into a script that is ready to use. Whether you are an experienced developer or just starting out, this feature makes it easy to \nbuild chatbots quickly and efficiently.\n\nIn summary, Chatbot-Webraft is a must-have tool for anyone looking to create chatbots. With its wide range of features, including multiple model types, easy customization, and code generation capabilities,\nChatbot-Webraft is the perfect tool for anyone looking to build chatbots with ease and efficiency.\n\n**PLEASE NOTE THAT THIS MODULE IS IN BETA AND CHATBOTS CREATED WITH IT MAY RESPOND WITH UNEXPECTED ANSWERS**\n\n### **USAGE:**\n#### Import library\n```from chatbot_webraft import chatbot```\n\n##### Create Model\n```chatbot.create_model(\"my-model\")```\n\n##### Load  CSV DATASET (here 'input' needs to be replaced with the column in dataset that has the fields containing the data to be inputted same to be done with 'label' but with fields containing the data to be outputted. )\n```chatbot.dataset(CSV_FILE_NAME,'input','label',\"my-model\"\") ```\n\n##### Add more data to chatbot(OPTIONAL)\n```chatbot.add_data(\"my-model\"\",[\"input1\",\"input2\"],[\"output1\",\"output2\"]) ```\n\n##### Specify Input\n```input = \"hi\"``` / ```input = input(\"Enter: \")```\n##### Run chatbot (for default set MODEL_TYPE to \"spimx\")\n```print(chatbot.model_load(MDDEL_TYPE,input,\"my-model\",MDDEL_TYPE))```/```chatbot.model_load(MDDEL_TYPE,input,\"my-model\",MDDEL_TYPE)``` \n##### Use codewriter (currently python supported)\n```print(codewriter(\"python\",input,\"my-model\",\"pywriter\")``` / ```chatbot.model_load(\"pywriter\",input,\"my-model\",\"pywriter\")```\n\n### **Model Types:**\nInbuilt model types: nlpm (Generative, Best) , spimx (better), spimxr (more good), spim (good), rasv (not that good)\n\nYou can use other model types by downloading them from [here](\"https://models.chatbot.webraft.in\") and define path where modeltype (.wrmodel) file is stored to MODEL_TYPE\n\nNLPM: A generative model type (framework) , works best for generative bots . (BETA)\nNLPM USAGE: ```chatbot.model_load(\"nlpm\",input,\"my-model\",MODELTYPE)``` - Replace `MODELTYPE` with the other modeltype that suites you the best , i.e - spim , spimx , rasv , spim (do not replace MODELTYPE with 'nlpm' rather replace with others)\n\nThere is also a transformer modified framework that uses Tokenizers from prebuilt transfomer model i.e - BERT . Note that it needs very high system for running and takes a lot of time to load. USE - ```chatbot.model_load(\"bert\",input,\"my-model\",\"bert)``` (It doesnt need training)\n### **Basic BOT Usage:**\n ```\n #Import library\nfrom chatbot_webraft import chatbot\n\n#set model name\nmodel = \"my-model\" \n\n#create model\nchatbot.create_model(model)\n\n#load CSV dataset , Mention input column (question) and label column (answer)\nchatbot.dataset(CSV_FILE_NAME,INPUT_COLUMN,LABEL_COLUMN,model) \n\n\n#run in loop\nwhile True:\n  prompt = input(\"You: \")    \n  #run model and parse input\n  print(\"Bot: \",chatbot.model_load(\"spimx\",prompt,model,\"spimx\")) \n\n ```\n\n ### **Bot usage for discord:**\n```\n#Import libraries\nfrom chatbot_webraft import chatbot\nimport discord \nclient = discord.Client(intents=discord.Intents.all())\n\n\nmodel = \"my-model\" #set model name\nchatbot.create_model(model) #create model\nchatbot.dataset(CSV_FILE_NAME,INPUT_COLUMN,LABEL_COLUMN,model) #load CSV dataset .. Mention input column (question) and label column (answer)\nchatbot.add_data(model,[\"hey\",\"what about you\"],[\"hello bro\",\"im fine ,you?\"]) #add more data to model (Not saved , only in memory). Data that you may want to add later.\n@client.event\nasync def on_message(message):\n    if message.author == client.user:\n        return\n\n    prompt = message.content\n    \n    await message.reply(chatbot.model_load(\"spim\",prompt,model,\"spim\")) #run model and parse output\nclient.run(BOT_TOKEN)\n```\n### **Basic codewriter usage:**\n```\n #Import library\nfrom chatbot_webraft import chatbot\n\n#set model name\nmodel = \"my-model\" \n\n#create model\nchatbot.create_model(model)\n\n#load CSV dataset , Mention input column (question) and label column (answer)\nchatbot.dataset(CSV_FILE_NAME,INPUT_COLUMN,LABEL_COLUMN,model) \n\n\n#run in loop\nwhile True:\n  prompt = input(\"You: \")    \n  #run model and parse input\n  print(\"Bot: \",chatbot.model_load(\"pywriter\",prompt,model,\"pywriter\")) #Or codewriter(\"python\",prompt,model,\"pywriter\")\n```\n### **Train Your own Model**\n\nIn versions < 1.0.0 you can now train / finetune your own language models through minimal code.\n\nHere is a basic example of pre training on chat data (using language data is advised):\n**Before trying, download the sample dataset given below. (after the code)**\n\n```\nfrom chatbot_webraft.yourmodel import TransformerModel\nimport torch\n\nd_model = 128 # Adjust according to your needs and system specs\n\ndataset_name = \"sample.csv\"  # Replace with your correct dataset path\n\ninput_set = \"input\"\n\nlabel_set = \"label\"\n\nbatch_size = 16 # Adjust according to your needs and system specs\n\nheads = 16 # Adjust according to your needs and system specs\n\nnum_layers = 6 # Adjust according to your needs and system specs\n\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n\nepochs = 40  \n\npath = \"path/to/folder/\" # Eg. D:/Softwares/AI/Trainer/\n\nmodel_name= path+\"yourmodelname\" # Eg. chatllm\ntransformer_model = TransformerModel(d_model, dataset_name, input_set, label_set, batch_size, heads, num_layers, device, epochs, model_name, max_len=256)\ntransformer_model.train() # Finally training\n\nquestion = \"hi\"\n\nprint(transformer_model.inference(question)) # Doing Inference\n```\n\nYou can also do inference already trained model but you require to initialise transformer model with that checkpoint and use same parameters (i.e. d_model, heads, num_layers, max_len)\n\n```\ncheckpoint = torch.load(path+model_name+\"_final.pth\",map_location=device)\ntransformer = checkpoint['transformer']\ntransformer_model = TransformerModel(d_model, dataset_name, input_set, label_set, batch_size, heads, num_layers, device, epochs, model_name, max_len=256,transformer=transfromer)\n```\n\nYou can also fine tune the model by just changing the dataset_name at initialising of new model and doing `transformer_model.finetune()`.\n\n\n### **SAMPLE CSV DATASET:**\nDownload Sample csv dataset from [here](https://webraft.in/sample.csv) , Dont forget to put the file in your project directory\n<br>\nChange `CSV_FILE_NAME` to \"sample.csv\" , `INPUT_COLUMN` to \"input\" , `LABEL_COLUMN` to \"label\" in the code\n\n### **Errors:**\nError 1 - This error indicates that the model name used in specific function is not same as the modelname set with chatbot.createmodel() \n<br>\nError 2 - This error indicates that the codewriter couldn't convert specific text to code due to lack of resources \n<br>\nError 3 - This error indicates that the file being set in any of these functions: chatbot.dataset() , chatbot.model_load() doesn't exist ",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Webraft_ChatBot  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A package for building chatbots easily without needing of any high system resources.",
    "version": "1.0.2",
    "project_urls": null,
    "split_keywords": [
        "artificial intelligence",
        "ai",
        "ai code",
        "ai code generator",
        "ai writer",
        "bot",
        "chat bot",
        "chat bot library",
        "chatbot",
        "chatbotwebraft",
        "chatgpt",
        "chatter",
        "code generator",
        "code writer",
        "generator",
        "transformer",
        "webraft"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9f2e8b6362a7edb28d5f03abbf5f23c896b387f219031dc7e7e72f7e30e4324",
                "md5": "1894d43a33cdc221d4db2bece11ddd53",
                "sha256": "b23350bf10be99c7bbb8d50b087bfe26f77ac8d74f91df80123e52ee87cbc1fd"
            },
            "downloads": -1,
            "filename": "chatbot_webraft-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1894d43a33cdc221d4db2bece11ddd53",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 127857,
            "upload_time": "2024-01-15T06:07:12",
            "upload_time_iso_8601": "2024-01-15T06:07:12.192300Z",
            "url": "https://files.pythonhosted.org/packages/c9/f2/e8b6362a7edb28d5f03abbf5f23c896b387f219031dc7e7e72f7e30e4324/chatbot_webraft-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c737bd7cab1c4bbed5ef6afab03f696d85dd01ef73cdc00c59c549b860d2b7b7",
                "md5": "7a671c76961708e442ce5395459f8e45",
                "sha256": "23696a1334309c8080797003cd60ff61f3b630c8009adba305afe93f714bdedd"
            },
            "downloads": -1,
            "filename": "chatbot_webraft-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7a671c76961708e442ce5395459f8e45",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 124250,
            "upload_time": "2024-01-15T06:07:20",
            "upload_time_iso_8601": "2024-01-15T06:07:20.709320Z",
            "url": "https://files.pythonhosted.org/packages/c7/37/bd7cab1c4bbed5ef6afab03f696d85dd01ef73cdc00c59c549b860d2b7b7/chatbot_webraft-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-15 06:07:20",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "chatbot-webraft"
}
        
Elapsed time: 0.25700s