diff --git a/docs/Deployment Run/ReadMe.md b/docs/Deployment Run/ReadMe.md deleted file mode 100644 index be40d01e..00000000 --- a/docs/Deployment Run/ReadMe.md +++ /dev/null @@ -1,54 +0,0 @@ -Because many people don't know how to run, or run an error, write a tutorial today. - -First of all, first get the code, you can download the source code through the command line or SourceTree. I mainly introduce the source code download method of SourceTree: - -![SourceTree](https://images.gitee.com/uploads/images/2019/0909/191331_59109574_130171.jpeg "1.JPG") - -Enter the form shown in the above figure by using the file ==>Clone/New or the tab bar + number. Follow the circle and operation in the circle to synchronize the source code to the local specified directory. I am in the "L:\Complete Project\Smart Chat Robot\BotSharp\Net core 2.2" folder, which will be used to demonstrate this folder path. - -Go to the BotSharp.WebHost folder and type cmd in the address bar and press Enter. The cmd window will pop up. Enter the dotnet watch run command to run the project. - -![Project operation](https://images.gitee.com/uploads/images/2019/0909/191850_a4f0fd89_130171.jpeg "2.JPG") - -Note: The red font display part in the above picture can be ignored. If there is obsessive-compulsive disorder, you can right-click BotSharp.Platform.Rasa and BotSharp.Platform.Articulate in BotSharp.WebHost, or in BotSharp.WebHost/Settings/ Remove the circle in the image below in app.json - -![Remove red item](https://images.gitee.com/uploads/images/2019/0909/192213_87385c4d_130171.jpeg "3.JPG") - -Next we open the address of the Swagger interface to see if the Swagger interface document is displayed normally. - -![Successful operation](https://images.gitee.com/uploads/images/2019/0909/192612_6aceb74e_130171.jpeg "4.JPG") - -As shown, we ran successfully. - - -Next, start importing and training and testing the agent online through the interface documentation above. - -First import the zip package required by the training agent, which contains the corpus - -![Interface operation](https://images.gitee.com/uploads/images/2019/0909/193255_897b251c_130171.jpeg "5.JPG") - -![Interface operation](https://images.gitee.com/uploads/images/2019/0909/193349_38366ca2_130171.jpeg "6.JPG") - -![Interface operation](https://images.gitee.com/uploads/images/2019/0909/194412_edf0f024_130171.jpeg "7.JPG") - -The part of the circle in the picture above is to be recorded and will be useful next. Where id is the proxy ID generated by the newly imported document, clientAccessToken is the authorization ID, and the training agent model needs this authorization ID. - -![Enter image description](https://images.gitee.com/uploads/images/2019/0909/195938_0b68c3c4_130171.jpeg "8.JPG") - -![Enter image description](https://images.gitee.com/uploads/images/2019/0909/195950_18b84a44_130171.jpeg "9.JPG") - -![Enter image description](https://images.gitee.com/uploads/images/2019/0909/200000_34596964_130171.jpeg "10.JPG") - -The operation of the above pictures is to save the authorization information required by the current interface, especially the part of the circle, and Bearer is followed by a space followed by the value of clientAccessToken, and the value of clientAccessToken is different for training different agents. . - -Fill in the proxy ID generated in the figure below and click Execute to execute. - -![Enter image description](https://images.gitee.com/uploads/images/2019/0909/200258_7ea18c61_130171.jpeg "11.JPG") - -Then follow the picture below to enter the test data to execute the output. - -![Enter image description](https://images.gitee.com/uploads/images/2019/0909/204756_99e489c3_130171.jpeg "12.JPG") - -![Enter image description](https://images.gitee.com/uploads/images/2019/0909/204939_6b75f8cd_130171.png "屏幕截图.png") - -The part in the circle in the above figure is the result of the execution. \ No newline at end of file diff --git a/docs/Deployment Run/ReadMe_cn.md b/docs/Deployment Run/ReadMe_cn.md deleted file mode 100644 index e0a321c1..00000000 --- a/docs/Deployment Run/ReadMe_cn.md +++ /dev/null @@ -1,54 +0,0 @@ -因为目前很多人不知道怎么样运行,或者运行报错,故今天写下这样一个教程。 - -首先第一步先获取代码,可以通过命令行或者SourceTree下载源码,我这里主要介绍SourceTree的下载源码方法: - -![SourceTree](https://images.gitee.com/uploads/images/2019/0909/191331_59109574_130171.jpeg "1.JPG") - -通过文件下==>克隆/新建或者是标签栏+号进入上图所示窗体,按照圈中所圈填写和操作即可将源码同步到本地指定目录。我的是在“L:\完成项目\智能聊天机器人\BotSharp\Net core 2.2”文件夹中,后面会以此文件夹路径来做演示。 - -进入BotSharp.WebHost文件夹并在地址栏里输入cmd并回车,即弹出cmd窗口,输入dotnet watch run命令会运行项目。 - -![项目运行](https://images.gitee.com/uploads/images/2019/0909/191850_a4f0fd89_130171.jpeg "2.JPG") - -注意:上图中红色字体显示部分可以不用理会,如果有强迫症的话,可以在BotSharp.WebHost右键引入BotSharp.Platform.Rasa和BotSharp.Platform.Articulate这两个项目,或者在BotSharp.WebHost/Settings/app.json中删除下图中圈中部分 - -![移除红色项目](https://images.gitee.com/uploads/images/2019/0909/192213_87385c4d_130171.jpeg "3.JPG") - -接下来我们通过第二张图片上运行之后的地址打开查看Swagger的接口文档是否正常显示。 - -![运行成功](https://images.gitee.com/uploads/images/2019/0909/192612_6aceb74e_130171.jpeg "4.JPG") - -如图所示,我们运行成功了。 - - -接下来开始通过上面的接口文档在线导入和训练并测试代理。 - -先导入训练代理所需要的压缩包,里面包含有语料库 - -![接口操作](https://images.gitee.com/uploads/images/2019/0909/193255_897b251c_130171.jpeg "5.JPG") - -![接口操作](https://images.gitee.com/uploads/images/2019/0909/193349_38366ca2_130171.jpeg "6.JPG") - -![接口操作](https://images.gitee.com/uploads/images/2019/0909/194412_edf0f024_130171.jpeg "7.JPG") - -上图中圈中的部分要记录下来,接下来会有用。其中id是刚导入文档生成的代理ID,clientAccessToken是授权ID,训练代理模型是需要这个授权ID的。 - -![输入图片说明](https://images.gitee.com/uploads/images/2019/0909/195938_0b68c3c4_130171.jpeg "8.JPG") - -![输入图片说明](https://images.gitee.com/uploads/images/2019/0909/195950_18b84a44_130171.jpeg "9.JPG") - -![输入图片说明](https://images.gitee.com/uploads/images/2019/0909/200000_34596964_130171.jpeg "10.JPG") - -上面几张图片的操作就是保存当前接口所需要授权信息的方法,尤其是要注意圈中部分,另Bearer后面跟一个空格再跟上clientAccessToken的值,且训练不同的代理这个clientAccessToken的值也不一样。 - -在下图中填入前面生成的代理ID并点击Execute执行即可 - -![输入图片说明](https://images.gitee.com/uploads/images/2019/0909/200258_7ea18c61_130171.jpeg "11.JPG") - -然后按下面图片操作输入测试数据执行输出 - -![输入图片说明](https://images.gitee.com/uploads/images/2019/0909/204756_99e489c3_130171.jpeg "12.JPG") - -![输入图片说明](https://images.gitee.com/uploads/images/2019/0909/204939_6b75f8cd_130171.png "屏幕截图.png") - -上图中圈中部分即为执行得到的结果 \ No newline at end of file diff --git a/docs/FrontCover.md b/docs/FrontCover.md deleted file mode 100644 index 8e00ec76..00000000 --- a/docs/FrontCover.md +++ /dev/null @@ -1,15 +0,0 @@ - - - - -# Hands-On Chatbot Platform - -### Build the AI chatbot platform from scratch with .NET Core - -![front-cover-image](static/front-cover.jpg) - -> Conversational Service in Natural Language Understanding - - - -#### **Haiping Chen** \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index a4714481..644d4ad0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,7 +6,7 @@ We use [Sphinx](https://www.sphinx-doc.org/en/master/) to build document, please pip install -U sphinx pip install recommonmark pip install sphinx_rtd_theme - +pip install myst-parser cd docs ./make html ``` \ No newline at end of file diff --git a/docs/agent/account.md b/docs/agent/account.md new file mode 100644 index 00000000..6aeeaf57 --- /dev/null +++ b/docs/agent/account.md @@ -0,0 +1,45 @@ +# Agent +Agent is a collection that contains prompt words and function Json Schema definitions, few-shot examples and knowledge base data. You can create multiple different Agents to perform specific operations in specific domains. BotSharp has built-in maintenance for Agents, including creating, updating and deleting, importing and exporting. + +## User Account +As a Bot construction framework, the most basic step is to integrate the user authentication function, so that the back-end API can recognize which user the current request comes from. In this way, a more complete business system can be further constructed. BotSharp can be combined with the user authentication function of ASP.NET MVC. + +### Create a user account +Use the [Account Creation](https://www.postman.com/orange-flare-634868/workspace/botsharp/request/1346299-1b868c08-c6ac-48a5-94ab-93f6f080c085) API in BotSharp to create the first platform user. + +![Alt text](assets/account-creation.png) + +### Get access token +After the platform user is created, the user token can be obtained through the [Get Token](https://www.postman.com/orange-flare-634868/workspace/botsharp/request/1346299-5d70fec4-dfa0-4b74-a4fd-8cd21009d44f) API, and this token is required in all subsequent APIs. + +![Alt text](assets/account-token.png) + +## My Agent +After creating the platform account, you can start to enter the steps of creating the Agent. + +### Agent creation +Suppose we need to write a Pizza restaurant order AI Bot. First, specify a name and description, then call the [Agent creation](https://www.postman.com/orange-flare-634868/workspace/botsharp/request/1346299-dc57eddb-a3eb-41f1-9c6c-ac65f9d8d510) API to create a new robot, and the system will return an internally used Agent Id. This Id needs to be used in subsequent interactions. + +![Alt text](assets/agent-creation.png) + +### Agent instruction +BotSharp uses the latest large language model in natural language understanding, can interact with OpenAI's ChatGPT, and also supports the most widely used open source large language model [LLaMA](https://ai.meta.com/blog/large-language-model-llama-meta-ai/) and its fine-tuning model. In this example, we use [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-services/openai-service) as the LLM engine. + +```json +"AzureOpenAi": { + "ApiKey": "", + "Endpoint": "", + "DeploymentModel": { + "ChatCompletionModel": "", + "TextCompletionModel": "" + } +} +``` + +If you use the installation package to run, please ensure that the [BotSharp.Plugin.AzureOpenAI](https://www.nuget.org/packages/BotSharp.Plugin.AzureOpenAI) plugin package is installed. + +Now we can update the prompt to the chatbot definition through the [Agent Update](https://www.postman.com/orange-flare-634868/workspace/botsharp/request/1346299-01c38741-987b-42af-850d-1b1e21b506df) API. + +![Alt text](assets/agent-update.png) + +After the update is successful, the robot will have a system prompt, and the subsequent dialogue will interact with the user based on the background knowledge of the system prompt. So far, the creation of the Agent has been completed, but the real dialogue has not yet started. The following will continue to introduce the last step, the [Agent Conversation](conversation.md) part. \ No newline at end of file diff --git a/docs/agent/assets/account-creation.png b/docs/agent/assets/account-creation.png new file mode 100644 index 00000000..20dd83ad Binary files /dev/null and b/docs/agent/assets/account-creation.png differ diff --git a/docs/agent/assets/account-token.png b/docs/agent/assets/account-token.png new file mode 100644 index 00000000..3fb09f94 Binary files /dev/null and b/docs/agent/assets/account-token.png differ diff --git a/docs/agent/assets/agent-creation.png b/docs/agent/assets/agent-creation.png new file mode 100644 index 00000000..6108fc32 Binary files /dev/null and b/docs/agent/assets/agent-creation.png differ diff --git a/docs/agent/assets/agent-update.png b/docs/agent/assets/agent-update.png new file mode 100644 index 00000000..6f7512e7 Binary files /dev/null and b/docs/agent/assets/agent-update.png differ diff --git a/docs/agent/assets/conversation-creation.png b/docs/agent/assets/conversation-creation.png new file mode 100644 index 00000000..0d35a367 Binary files /dev/null and b/docs/agent/assets/conversation-creation.png differ diff --git a/docs/agent/assets/conversation-send-message.png b/docs/agent/assets/conversation-send-message.png new file mode 100644 index 00000000..73d54e77 Binary files /dev/null and b/docs/agent/assets/conversation-send-message.png differ diff --git a/docs/agent/conversation.md b/docs/agent/conversation.md new file mode 100644 index 00000000..5be2d08a --- /dev/null +++ b/docs/agent/conversation.md @@ -0,0 +1,11 @@ +# Conversation + +## Start a conversation +Before each new dialogue with the Agent, a new Conversation needs to be created, that is, the Session. The advantage of this Conversation is that it can help users manage the dialogue context. LLM needs to generate the next conversation content based on the history of the whole conversation. + +![Alt text](assets/conversation-creation.png) + +## Send message +Congratulations, the entire Agent configuration is complete, and now you can start [Sending Messages](https://www.postman.com/orange-flare-634868/workspace/botsharp/request/1346299-6f51dfe2-0ea5-4910-bf62-f5515f46db73) to your Chatbot through the API. + +![Alt text](assets/conversation-send-message.png) \ No newline at end of file diff --git a/docs/agent/import-agent.rst b/docs/agent/import-agent.rst deleted file mode 100644 index 98c5c599..00000000 --- a/docs/agent/import-agent.rst +++ /dev/null @@ -1,45 +0,0 @@ -Import Agent -============ -Designed as a multi-platform framework, BotSharp allows developers to create their own Bot platforms and support multiple Bot platform services. It supports multiple Bot import, export and message reply formats such as Dialogflow and Rasa. -Support for importing and exporting between platforms. - -**First, export agent from other chatbot platform.** - -In general, the platform provides the ability to export to a compressed file. Different platform has different export method. - -**Second, add meta.json to zip file.** - -meta.json is used to tell BotSharp where the agent is exported from. It should looks like below: - -.. code-block:: json - - { - "Id": "YOURS", - "Name": "YOURS", - "Platform": "Dialogflow", - "ClientAccessToken": "YOURS", - "DeveloperAccessToken": "YOURS", - "Integrations": [] - } - -Extract zip file and add the meta.json to the zip file. - -1. Google Dialogflow -:: - -"Platform": "Dialogflow" - -2. RASA -:: - -"Platform": "Rasa" - -3. Microsoft LUIS - -**Last, upload updated zip file.** - -Upload zip file in REST API. - -|RestoreAgentFromZipScreenshot| - -.. |RestoreAgentFromZipScreenshot| image:: /static/screenshots/RestoreAgentFromZip.png \ No newline at end of file diff --git a/docs/agent/optimize-agent.rst b/docs/agent/optimize-agent.rst deleted file mode 100644 index 16ebbf11..00000000 --- a/docs/agent/optimize-agent.rst +++ /dev/null @@ -1,4 +0,0 @@ -Optimized Robot -=============== - -The semantic understanding ability of the robot can be improved by modifying the parameters of the training and the selection of the hyperparameters. \ No newline at end of file diff --git a/docs/agent/test-agent.rst b/docs/agent/test-agent.rst deleted file mode 100644 index b478ceab..00000000 --- a/docs/agent/test-agent.rst +++ /dev/null @@ -1,13 +0,0 @@ -Test Agent -=========== - -After the training is complete, you can start testing the Agent. Enter the robot name and the statement you want to test. - -|APITestInputScreenshot| - -After clicking the execution, you will get the result returned by the server, which contains the user intent and the entity value. - -|APITestResultScreenshot| - -.. |APITestInputScreenshot| image:: /static/screenshots/APITestInput.png -.. |APITestResultScreenshot| image:: /static/screenshots/APITestResult.png \ No newline at end of file diff --git a/docs/agent/train-agent.rst b/docs/agent/train-agent.rst deleted file mode 100644 index f0b0a302..00000000 --- a/docs/agent/train-agent.rst +++ /dev/null @@ -1,20 +0,0 @@ -Train Agent -=========== - -When you successfully import the Agent, the next step is to train your Agent and let it run according to your pre-designed process. - -Fill in your Agent name and click the "Train" button for a while (depending on the size of the data). - -|APITrainStartScreenshot| - -During the training, the console will enter the training status immediately. - -|APITrainInProgressScreenshot| - -After the training is completed, you will get the details of a model. - -|APITrainCompletedScreenshot| - -.. |APITrainStartScreenshot| image:: /static/screenshots/APITrainStart.png -.. |APITrainInProgressScreenshot| image:: /static/screenshots/APITrainInProgress.png -.. |APITrainCompletedScreenshot| image:: /static/screenshots/APITrainCompleted.png \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index fa9251db..1c247ed3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,12 +33,12 @@ # ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.mathjax', 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode'] + 'sphinx.ext.viewcode', + 'myst_parser'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -56,7 +56,7 @@ master_doc = 'index' # General information about the project. project = 'BotSharp' -copyright = '2018, Haiping Chen' +copyright = 'Since 2018, Haiping Chen' author = 'Haiping Chen' # The version info for the project you're documenting, acts as replacement for @@ -64,16 +64,16 @@ author = 'Haiping Chen' # built documents. # # The short X.Y version. -version = '0.5' +version = '0.8' # The full version, including alpha/beta/rc tags. -release = '0.5.0' +release = '0.8.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -170,7 +170,7 @@ man_pages = [ # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'BotSharp', 'BotSharp Documentation', - author, 'BotSharp', 'One line description of project.', + author, 'BotSharp', 'The LLM powered Chatbot framework.', 'Miscellaneous'), ] diff --git a/docs/development/architecture.rst b/docs/development/architecture.rst deleted file mode 100644 index bef58bda..00000000 --- a/docs/development/architecture.rst +++ /dev/null @@ -1,2 +0,0 @@ -Architecture -============ \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index f8a486cb..371c2a0e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,6 +9,9 @@ The Open Source AI Bot Platform Builder .. image:: https://img.shields.io/discord/1106946823282761851?label=Discord :target: `discord`_ +**Build the AI chatbot platform from scratch with .NET** + +> The LLM powered Conversational Service framework *"Conversation as a platform (CaaP) is the future, so it's perfect that we're already offering the whole toolkits to .NET developers using BotSharp the Bot Platform Builder to build a CaaP. It opens up as much learning power as possible for your robots and precisely control every step of the AI processing pipeline."* @@ -36,25 +39,28 @@ Indices and tables ================== The main documentation for the site is organized into the following sections: -* :ref:`User Documentation ` +* :ref:`Get Started ` * :ref:`Integration Documentation ` -* :ref:`NLP Documentation ` * :ref:`Architecture Documentation ` * :ref:`search` -.. _user-docs: +.. _get-started: .. toctree:: :maxdepth: 3 - :caption: Hands-On Chatbot Platform: + :caption: Get Started with BotSharp - FrontCover - overview - installation - agent/import-agent - agent/train-agent - agent/test-agent - agent/optimize-agent + quick-start/overview + quick-start/installation + +.. _agent-docs: + +.. toctree:: + :maxdepth: 3 + :caption: Agent & Conversation + + agent/account + agent/conversation .. _integration-docs: @@ -63,9 +69,6 @@ The main documentation for the site is organized into the following sections: :caption: Channels Integration Documentation: integrations/facebook-messenger - integrations/slack - integrations/telegram - integrations/skype .. _architecture-docs: @@ -76,19 +79,6 @@ The main documentation for the site is organized into the following sections: configuration/db configuration/platform -.. _nlp-docs: - -.. toctree:: - :maxdepth: 3 - :caption: NLP Documentation: - - models/crf - models/nb - models/ngram - models/svm - models/tfidf - models/penntreebank - If you feel that this project is helpful to you, please Star us on the project, we will be very grateful. .. _Chatbot UI: https://github.com/mckaywrigley/chatbot-ui diff --git a/docs/installation.rst b/docs/installation.rst deleted file mode 100644 index 5d2048ab..00000000 --- a/docs/installation.rst +++ /dev/null @@ -1,110 +0,0 @@ -Installation -============ -BotSharp strictly follows the modular design principle and adopts a structure in which views and logic are separated. -So you can choose the front-end Bot design and management interface. - - -Building & Run locally -^^^^^^^^^^^^^^^^^^^^^^ -If you are a .NET developer and want to develop extensions or fix bug for BotSharp, you would hit F5 to run it locally in debug mode. -Make sure the `Microsoft .NET SDK`_ 6.0+ build environment and `Node.js`_ is installed. -Building solution using dotnet CLI (preferred). - -* Build BotSharp backend API -:: - - PS D:\> git clone https://github.com/Oceania2018/BotSharp - PS D:\> cd BotSharp - PS D:\> dotnet build - -* Update `appsettings.json`, BotSharp can work with serveral LLM providers. Below config is tasking Azure OpenAI as the LLM backend -:: - - "AzureOpenAi": { - "ApiKey": "", - "Endpoint": "https://.openai.azure.com/", - "DeploymentName": "" - } - -* Run backend web project -:: - - PS D:\> dotnet run --project src/WebStarter - -|BackendServiceHomeScreenshot| - -* Open REST API in browser http://localhost:5500/swagger - -|APIHomeScreenshot| - -* Launch a chatbot UI -If you want to use the `Chatbot UI`_ as a front end. -:: - - PS D:\> git clone https://github.com/mckaywrigley/chatbot-ui - PS D:\> cd chatbot-ui - PS D:\> cd npm i - PS D:\> cd npm run dev - -Update API url in `.env.local` to your localhost BotSharp backend service. -:: - OPENAI_API_HOST=http://localhost:5500 - - -* Point your web browser at http://localhost:3000 and enjoy Chatbot with BotSharp. -|ChatbotUIHomeScreenshot| - - -Building docker image -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -If you just want to run BotSharp as a backend NLU engine, you can run it standalone in docker. - -:: - - PS D:\> git clone https://github.com/Oceania2018/BotSharp - PS D:\> cd BotSharp - -Build docker image: - -:: - - PS D:\BotSharp\> docker build -f dockerfiles/DIALOGFLOW.Dockerfile -t botsharp . - -Start a container: - -:: - - PS D:\BotSharp\> docker run --name botsharp -it -p 5000:5000 botsharp - - -Access restful APIs: http://localhost:5000 if you are using RASA response format. - -Get a bash shell if you want to update config in the container. - -:: - - PS D:\BotSharp\> docker exec -it botsharp /bin/bash - - -Install in NuGet -^^^^^^^^^^^^^^^^ - -:: - - PM> Install-Package BotSharp.Core - -Use BotSharp.NLP as a natural language processing toolkit alone. - -:: - - PM> Install-Package BotSharp.NLP - -.. _Chatbot UI: https://github.com/mckaywrigley/chatbot-ui -.. _Microsoft .NET SDK: https://www.microsoft.com/net/download -.. _Node.js: https://nodejs.org -.. _Docker: https://www.docker.com - -.. |BackendServiceHomeScreenshot| image:: /static/screenshots/BackendServiceHomeScreenshot.png -.. |APIHomeScreenshot| image:: /static/screenshots/APIHome.png -.. |ChatbotUIHomeScreenshot| image:: /static/screenshots/ChatbotUIHome.png diff --git a/docs/installation/quick_start.rst b/docs/installation/quick_start.rst deleted file mode 100644 index d7f81cb1..00000000 --- a/docs/installation/quick_start.rst +++ /dev/null @@ -1,24 +0,0 @@ -Quickstart -========== - -Installation instructions -------------------------- - -You can start BotSharp with NuGet or compile it in local development environment. - -* Install lastest release using NuGet package management: - -:: - - PM> Install-Package BotSharp.NLP - -* Build in local development: - -Make sure you have lastest .Net Core 2.x SDK installed. You can download SDK from https://www.microsoft.com/net/download . - -:: - - PS C:\> git clone https://github.com/Oceania2018/BotSharp.NLP.git - PS C:\> cd BotSharp.NLP - PS C:\> dotnet build - diff --git a/docs/integrations/skype.rst b/docs/integrations/skype.rst deleted file mode 100644 index b374a8b4..00000000 --- a/docs/integrations/skype.rst +++ /dev/null @@ -1,2 +0,0 @@ -Skype Chabot -============ diff --git a/docs/integrations/slack.rst b/docs/integrations/slack.rst deleted file mode 100644 index dcb6ef83..00000000 --- a/docs/integrations/slack.rst +++ /dev/null @@ -1,6 +0,0 @@ -Slack App -========= - -A bot is a type of Slack App designed to interact with users via conversation. - -A bot is the same as a regular app: it can access the same range of APIs and do all of the magical things that a Slack App can do. \ No newline at end of file diff --git a/docs/integrations/telegram.rst b/docs/integrations/telegram.rst deleted file mode 100644 index a84945ed..00000000 --- a/docs/integrations/telegram.rst +++ /dev/null @@ -1,4 +0,0 @@ -Telegram Bot Platform -===================== - -Bots are simply Telegram accounts operated by software – not people – and they'll often have AI features. They can do anything – teach, play, search, broadcast, remind, connect, integrate with other services, or even pass commands to the Internet of Things. \ No newline at end of file diff --git a/docs/models/crf.rst b/docs/models/crf.rst deleted file mode 100644 index e021c98d..00000000 --- a/docs/models/crf.rst +++ /dev/null @@ -1,2 +0,0 @@ -Conditional Random Field (CRF) -============================== \ No newline at end of file diff --git a/docs/models/nb.rst b/docs/models/nb.rst deleted file mode 100644 index 97417159..00000000 --- a/docs/models/nb.rst +++ /dev/null @@ -1,2 +0,0 @@ -Naive Bayes Classifier (NB) -=========================== \ No newline at end of file diff --git a/docs/models/ngram.rst b/docs/models/ngram.rst deleted file mode 100644 index 0d103430..00000000 --- a/docs/models/ngram.rst +++ /dev/null @@ -1,2 +0,0 @@ -N-Gram Model (NG) -================= \ No newline at end of file diff --git a/docs/models/penntreebank.rst b/docs/models/penntreebank.rst deleted file mode 100644 index b18671d9..00000000 --- a/docs/models/penntreebank.rst +++ /dev/null @@ -1,2 +0,0 @@ -Penn Treebank -============= diff --git a/docs/models/svm.rst b/docs/models/svm.rst deleted file mode 100644 index bce157d9..00000000 --- a/docs/models/svm.rst +++ /dev/null @@ -1,2 +0,0 @@ -Support Vector Machine (SVM) -============================ \ No newline at end of file diff --git a/docs/models/tfidf.rst b/docs/models/tfidf.rst deleted file mode 100644 index 6daa95f6..00000000 --- a/docs/models/tfidf.rst +++ /dev/null @@ -1,2 +0,0 @@ -TF-IDF -====== diff --git a/docs/quick-start/assets/APIHome.png b/docs/quick-start/assets/APIHome.png new file mode 100644 index 00000000..d0ca1ba7 Binary files /dev/null and b/docs/quick-start/assets/APIHome.png differ diff --git a/docs/quick-start/assets/APIPostman.png b/docs/quick-start/assets/APIPostman.png new file mode 100644 index 00000000..6b7ea7ce Binary files /dev/null and b/docs/quick-start/assets/APIPostman.png differ diff --git a/docs/quick-start/assets/BackendServiceHomeScreenshot.png b/docs/quick-start/assets/BackendServiceHomeScreenshot.png new file mode 100644 index 00000000..704112a0 Binary files /dev/null and b/docs/quick-start/assets/BackendServiceHomeScreenshot.png differ diff --git a/docs/static/screenshots/ChatbotUIHome.png b/docs/quick-start/assets/ChatbotUIHome.png similarity index 100% rename from docs/static/screenshots/ChatbotUIHome.png rename to docs/quick-start/assets/ChatbotUIHome.png diff --git a/docs/quick-start/installation.md b/docs/quick-start/installation.md new file mode 100644 index 00000000..6fb1a186 --- /dev/null +++ b/docs/quick-start/installation.md @@ -0,0 +1,74 @@ +# Quick Start + +BotSharp strictly follows the modular design principle and adopts a structure in which views and logic are separated. It also provides a complete Web API interface to integrate with your own system. At the architectural level, Hook and EvenT are designed for different purposes, which can expand Chatbot's dialogue capabilities without changing the kernel. + +## Run locally in development mode + +If you are a .NET developer and want to develop extensions or fix bug for BotSharp, you would hit F5 to run it locally in debug mode. +Make sure the [Microsoft .NET SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) 6.0+ build environment +Building solution using dotnet CLI (preferred). + +### Clone the source code and build +```powershell +PS D:\> git clone https://github.com/Oceania2018/BotSharp +PS D:\> cd BotSharp +PS D:\> dotnet build +``` + +### Update configuration +`BotSharp` can work with serveral LLM providers. Update `appsettings.json` in your project. Below config is tasking Azure OpenAI as the LLM backend + +```json +"AzureOpenAi": { + "ApiKey": "", + "Endpoint": "https://xxx.openai.azure.com/", + "DeploymentModel": { + "ChatCompletionModel": "", + "TextCompletionModel": "" + } +} +``` + +### Run backend web project +```powershell +PS D:\> dotnet run --project src/WebStarter +``` +![alt text](assets/BackendServiceHomeScreenshot.png "Title") + +### Open REST APIs +You can access the APIs in browser through http://localhost:5500/swagger +![alt text](assets/APIHome.png "Title") + +### Test using the Postman +We have publicly shared the API collection of [Postman](https://www.postman.com/orange-flare-634868/workspace/botsharp/overview), which is convenient for developers to develop quickly. +![alt text](assets/APIPostman.png "Title") + +So far, you have set up the Bot's running and development environment, but you can't actually test the Chatbot. The next step is about how to [Create an Agent](../agent/account) and start a conversation with the Chatbot. + +**Ignore below section if you're going to just use REST API to interact with your bot.** + +### Launch a chatbot UI (Optional) +You can use a third-party open source UI for debugging and development, or you can directly use the REST API to integrate with your system. +If you want to use the [Chatbot UI](https://github.com/mckaywrigley/chatbot-ui) as a front end. +```powershell +PS D:\> git clone https://github.com/mckaywrigley/chatbot-ui +PS D:\> cd chatbot-ui +PS D:\> cd npm i +PS D:\> cd npm run dev +``` + +Update API url in `.env.local` to your localhost BotSharp backend service. +```config +OPENAI_API_HOST=http://localhost:5500 +``` + +Point your web browser at http://localhost:3000 and enjoy Chatbot with BotSharp. + +![alt text](assets/ChatbotUIHome.png "Title") + +## Install in NuGet +If you don't want to use the source code to experience this framework, you can also directly install the [NuGet packages](https://www.nuget.org/packages?q=BotSharp) released by BotSharp, and install different function packages according to the needs of your project. Before installing, please read the documentation carefully to understand the functions that different modules can provide. + +```powershell +PS D:\> Install-Package BotSharp.Core +``` \ No newline at end of file diff --git a/docs/overview.md b/docs/quick-start/overview.md similarity index 54% rename from docs/overview.md rename to docs/quick-start/overview.md index 2b95d2ae..10a34737 100644 --- a/docs/overview.md +++ b/docs/quick-start/overview.md @@ -1,11 +1,11 @@ -# BotSharp Overview +# Overview *Haiping Chen --06/18/2023* BotSharp is an open source machine learning framework for AI Bot platform builder. This project involves natural language understanding and audio processing technologies, and aims to promote the development and application of intelligent robot assistants in information systems. Out of the box machine learning algorithms allow ordinary programmers to develop artificial intelligence applications faster and easier. BotSharp is an high compatible and high scalable platform builder. It is in accordance with components princple strictly, decouples every part that needed in the platform builder. So you can choose different UI/UX, or pick up a different NLP Tagger, or select a more advanced algrithm to do NER task. They are all modulized based on unfied interfaces. -![ ](./static/screenshots/BotSharp_arch.png "BotSharp Architecture Chart") +![ ](../static/screenshots/BotSharp_arch.png "BotSharp Architecture Chart") From the chart ahead we can see that based on botsharp you can launch your own chatbot platform with 3 components: - Storage module: Botsharp supports memory and redis DB 2 methods. @@ -26,31 +26,9 @@ However, BotSharp lets you easily achieve a conversational user experience by ha ## Agent An agent helps you process user sentences (unstructure data) into structure data that you can use to return an appropriate response. -![](./static/screenshots/Agent_sent.png) + When users say something, your agent matches the user utterance to an exactly matched intent or closely matched intent. Besides, the agent will return extra information about named entities which you need from the utterance. This can be name, location date or a host of other data categories (entities). You can define both the intent and the entities in your training data sets. You can also define what else to extact in your training phares as well.Then you can send a response to user to continue the conversation or to just end the conversation. It is very simple to create your own agent in BotSharp. The only thing you need is to assign you agent a name and a brief discription. -![](./static/screenshots/Agent_Workflow.png) -## Intent -To define how conversations work, you create intents in your agent that map user input to response. Generally an intent represents one dialog turn in a conversation. For example, you could create an music control angent recognise and responds to users. If a user said "Can you play Rihanna's Diamonds?". Your agent will do intent matching to music play intent, and responds to users a corresponding reply. It usually prompts users for another utterance which your agent will attempt to match another intent, and the conversation continues. - -### Training Phrases -Training Phrases are collections of possible utterances that users might say to match a intent. You don't have to define every possible utterance of what user say. While we recommend users could define as more expression way as possible. It will help improve the robot understanding ability a lot. - -![](./static/screenshots/articulatescreenshot.png) -From the chart above we can see: An Intent consist of four main components: - -- Intent name: The name of the intent -- Training phrases: Examples of what users can say to match a particular intent. BotSharp will automaticlly expand these phrases to match similar user utterances. -- Actions and parameters: Define how relevant information (Entities) are extracted from user utterances. You can use these parameters (entities) as input into other logic, such as looking up information, carry out a task, or returning a response. -- Response: An utterance that is spoken or displayed back to the user. -## Named Entity -Named Entity is BotSharp mechanism for identfying and extacting useful data from user utterance text inputs. The difference between intent and entity is: intents allows your agent to understand the motivation behind a particular user input, on the other hand entities are used to extract out specific pieces of information that user mentions. Any important data you want to get from a user's request have a corresponding entity. - -### Annotation Entities -Training Phrases allow your agent to successfully match user input to an intent. In order to help your agent with this matching process. You can annotate training phrases with entities. Entitty is a host of categories. For example, locations, organizations, persons and numbers are all entities. Annotation refers to the linking of words or values within training phrases to their corresponding entities. You can manually annotate you training phrases. Once a word or phrase is annotated, it will be highlight in your training phrases. - -For example, imagine that you defined a training phrase like "Can you play Rihanna's Diamond please?" You can annotate Rihanna as an artist and Diamond as a song here. This annotation tells BotSharp to match more variations. like "Can you play Beattle's Hey Jude please?", or any other variation that have an artist and a song name combination. If you didn't annotate the phrase.For "Can you play Rihanna's Diamond" speaking, the agent would match user input that contained "Rihanna" and "Diamond" exactly, but not any other artists and any other songs. We recommend users could annotation properly in order to have a impressive intent classification experience. - ## Channels When you already trained a chatbot on Botsharp, you may want it to play a really role in life. So we intergrate some popular channels in Botsharp including Twilio, facebook messenger, Telegram, WeChat and some other RPAs. These channels can make your robot "real" in life. For example, on facebook when a user visit your page and sends you a message, they can talk to your agent. You can also set a virtral assistant based on Twilio to chat with your clients for ordering, consulting, problem solving and many other business processes. \ No newline at end of file diff --git a/docs/static/front-cover.jpg b/docs/static/front-cover.jpg deleted file mode 100644 index 3d6bd7d0..00000000 Binary files a/docs/static/front-cover.jpg and /dev/null differ diff --git a/docs/static/screenshots/APIHome.png b/docs/static/screenshots/APIHome.png deleted file mode 100644 index 75360eef..00000000 Binary files a/docs/static/screenshots/APIHome.png and /dev/null differ diff --git a/docs/static/screenshots/APITestInput.png b/docs/static/screenshots/APITestInput.png deleted file mode 100644 index 41b4fab0..00000000 Binary files a/docs/static/screenshots/APITestInput.png and /dev/null differ diff --git a/docs/static/screenshots/APITestResult.png b/docs/static/screenshots/APITestResult.png deleted file mode 100644 index f1a4a07d..00000000 Binary files a/docs/static/screenshots/APITestResult.png and /dev/null differ diff --git a/docs/static/screenshots/APITrainCompleted.png b/docs/static/screenshots/APITrainCompleted.png deleted file mode 100644 index b5f3d682..00000000 Binary files a/docs/static/screenshots/APITrainCompleted.png and /dev/null differ diff --git a/docs/static/screenshots/APITrainInProgress.png b/docs/static/screenshots/APITrainInProgress.png deleted file mode 100644 index 270e89db..00000000 Binary files a/docs/static/screenshots/APITrainInProgress.png and /dev/null differ diff --git a/docs/static/screenshots/APITrainStart.png b/docs/static/screenshots/APITrainStart.png deleted file mode 100644 index 611c05da..00000000 Binary files a/docs/static/screenshots/APITrainStart.png and /dev/null differ diff --git a/docs/static/screenshots/Agent_Workflow.png b/docs/static/screenshots/Agent_Workflow.png deleted file mode 100644 index a497a4f0..00000000 Binary files a/docs/static/screenshots/Agent_Workflow.png and /dev/null differ diff --git a/docs/static/screenshots/Agent_sent.png b/docs/static/screenshots/Agent_sent.png deleted file mode 100644 index e95d9a72..00000000 Binary files a/docs/static/screenshots/Agent_sent.png and /dev/null differ diff --git a/docs/static/screenshots/BackendServiceHomeScreenshot.png b/docs/static/screenshots/BackendServiceHomeScreenshot.png deleted file mode 100644 index e8c6a5e3..00000000 Binary files a/docs/static/screenshots/BackendServiceHomeScreenshot.png and /dev/null differ diff --git a/docs/static/screenshots/RestoreAgentFromZip.png b/docs/static/screenshots/RestoreAgentFromZip.png deleted file mode 100644 index 445cc8a3..00000000 Binary files a/docs/static/screenshots/RestoreAgentFromZip.png and /dev/null differ diff --git a/docs/static/screenshots/articulatescreenshot.png b/docs/static/screenshots/articulatescreenshot.png deleted file mode 100644 index 3d36689f..00000000 Binary files a/docs/static/screenshots/articulatescreenshot.png and /dev/null differ diff --git a/docs/集成微信公众号/README.md b/docs/集成微信公众号/README.md deleted file mode 100644 index ac2fa6d2..00000000 --- a/docs/集成微信公众号/README.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: 集成微信公众号 -tags: BotSharp,微信公众测试号 -grammar_cjkRuby: true ---- -集成微信公众号主要是将BotSharp与微信公众号对接起来,搭建一个环境,为后续工作做好准备。 - - ----------- - -# BotSharp的配置 - - 要与微信公众号对接,首先要成功运行BotSharp。下面详细讲解运行BotSharp的步骤: -## 加载项目 -加载的项目为botsharp-channel-weixin和botsharp-dialogflow两个项目。 -项目botsharp-channel-weixin为腾讯微信BotSharp的通道模块,加载此项目可以省去编写微信通道模块的过程,当然也可以根据自己的需求去编写微信的通道模块。 - - -项目文件botsharp-channel-weixin下载地址(https://github.com/Oceania2018/botsharp-channel-weixin)将botsharp-channel-weixin和botsharp-dialogflow项目放置到BotSharp同级的目录下。并加载到BotSharp中。 - -![](./集成微信公众号图片/图片1.png) - -右键点击“==依赖项==”、“==添加引用==”,把botsharp-channel-weixin项目添加到BotSharp.WebHost的引用中。 - -![](./集成微信公众号图片/图片2.png) - -找到BotSharp.WebHost下的app.json,修改moduleBasePath和botsharp-dialogflow的Path路径。程序会根据路径找到其项目的.dll。 - -![](./集成微信公众号图片/图片3.png) - -## 运行BotSharp -加载项目完毕,运行BotSharp项目,出现如下的黑色的控制台程序,表示程序找到了botsharp-dialogflow的.dll,项目运行成功。 - -![](./集成微信公众号图片/BotSharp运行结果.png) - - -运行成功后,打开网址为(http://localhost:3112/index.html) 的网页,此网页所显示的为BotSharp的接口列表。 - -![](./集成微信公众号图片/3112.png) - -# 对接微信公众号 -## 申请微信测试号 -在微信公众平台认证之前,我们可以先申请一个测试的公众号来进行测试,这对开发人员来说还是有很大好处的。(https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login) - -## 测试号接口信息配置 -**1)申请服务器** - -我们所要填写的url必须是外网能够访问到的服务器地址,而且必须是80端口,通过服务器的地址你要能够让微信访问到你的项目。 - -![](./集成微信公众号图片/微信接口配置信息1.png) - -我们需要把内网映射出去变成能够访问的外网,我们采取一个简单的方法,通过ngrok进行内网穿透。ngrok工具的下载地址:(http://ngrok.ciqiuwl.cn/)下载完成后解压缩。 - -找到apps.bat文件,点击右键打开记事本进行编辑,,执行 *ngrok -config=ngrok.cfg -subdomain xxx 80*//(xxx 是你自定义的域名前缀),如执行*ngrok -config=ngrok.cfg -subdomain sss 3112* ,双击弹出一个黑窗体,该黑窗体显示的域名就是映射出去的网址。 - -也有其它的方法得到外网网址,如通过路由器映射,可自行通过百度上网查询。 - -![](./集成微信公众号图片/ngrok黑窗体.png) - - -其中http://sss.ngrok.xiaomiqiu.cn 即为映射的外网IP。 - -**2)填写接口配置信息** - -url填写: http://外网IP/wx -Token:自主设置,这个token与公众平台wiki中常提的access_token不是一回事。这个token只用于验证开发者服务器。 - -![](./集成微信公众号图片/配置接口url.png) - -Token是用于交互安全认证的,可任意填写,但要与服务端的校验微信的Controller一样。 - -打开BotSharp.Webhost下的channels.weixin.json - -![](./集成微信公众号图片/程序配置信息.png) - -正确填写Token、AppId字符串。其中Token要与微信测试号中的Token相同。 - -![](./集成微信公众号图片/配置接口Token.png) - -填写完毕,打开ngrok并运行BotSharp项目,则可以成功提交微信测试号的接口配置信息。 - -![](./集成微信公众号图片/接口配置成功.png) - -填写JS接口安全域名,域名可随意填写。微信扫描关注测试公众号。 -至此,集成微信公众号完成。 - - - diff --git a/docs/集成微信公众号/集成微信公众号图片/3112.png b/docs/集成微信公众号/集成微信公众号图片/3112.png deleted file mode 100644 index c75647b4..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/3112.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/BotSharp运行结果.png b/docs/集成微信公众号/集成微信公众号图片/BotSharp运行结果.png deleted file mode 100644 index c25ae8e6..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/BotSharp运行结果.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/ngrok黑窗体.png b/docs/集成微信公众号/集成微信公众号图片/ngrok黑窗体.png deleted file mode 100644 index 601d32a4..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/ngrok黑窗体.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/图片1.png b/docs/集成微信公众号/集成微信公众号图片/图片1.png deleted file mode 100644 index a26650cb..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/图片1.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/图片2.png b/docs/集成微信公众号/集成微信公众号图片/图片2.png deleted file mode 100644 index 92eae0c6..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/图片2.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/图片3.png b/docs/集成微信公众号/集成微信公众号图片/图片3.png deleted file mode 100644 index 13da2077..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/图片3.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/微信接口配置信息1.png b/docs/集成微信公众号/集成微信公众号图片/微信接口配置信息1.png deleted file mode 100644 index aa463b89..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/微信接口配置信息1.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/接口配置成功.png b/docs/集成微信公众号/集成微信公众号图片/接口配置成功.png deleted file mode 100644 index e3d5ea21..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/接口配置成功.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/程序配置信息.png b/docs/集成微信公众号/集成微信公众号图片/程序配置信息.png deleted file mode 100644 index 3227e99f..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/程序配置信息.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/配置接口Token.png b/docs/集成微信公众号/集成微信公众号图片/配置接口Token.png deleted file mode 100644 index 66081456..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/配置接口Token.png and /dev/null differ diff --git a/docs/集成微信公众号/集成微信公众号图片/配置接口url.png b/docs/集成微信公众号/集成微信公众号图片/配置接口url.png deleted file mode 100644 index d6384ea7..00000000 Binary files a/docs/集成微信公众号/集成微信公众号图片/配置接口url.png and /dev/null differ diff --git a/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj b/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj index 0553f6c5..a4c3c091 100644 --- a/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj +++ b/src/Infrastructure/BotSharp.Abstraction/BotSharp.Abstraction.csproj @@ -4,7 +4,7 @@ netstandard2.1 enable 10.0 - 0.6.0 + 0.8.0 Icon.png diff --git a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj index 569421b4..b8c2cfaa 100644 --- a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj +++ b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj @@ -4,7 +4,7 @@ netstandard2.1 10.0 false - 0.6.0 + 0.8.0 diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json index 54024f22..48094800 100644 --- a/src/WebStarter/appsettings.json +++ b/src/WebStarter/appsettings.json @@ -48,7 +48,7 @@ "MongoDb": { "Master": "mongodb://localhost:27017/chat-ui" }, - "Agent": { + "BotSharp": { "Master": "Data Source=(localdb)\\ProjectModels;Initial Catalog=BotSharp;Integrated Security=True;Connect Timeout=30;Encrypt=False;Trust Server Certificate=False;Application Intent=ReadWrite;Multi Subnet Failover=False", "Slavers": [] },