From e7ccef3a1ebb6446a8b7ba6287d742c5c0942c76 Mon Sep 17 00:00:00 2001 From: Amedee Potier Date: Wed, 30 Dec 2020 14:53:03 +0000 Subject: [PATCH 01/11] KB-8933: Improve online doc --- openchatbotclient/client.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/openchatbotclient/client.py b/openchatbotclient/client.py index 038f3e6..f8d1c0d 100644 --- a/openchatbotclient/client.py +++ b/openchatbotclient/client.py @@ -1,14 +1,21 @@ """Client for Open Chat Bot. - Example of usage: - from openchatbotclient.client import client - myclient = client('bot.domain.com', 8443, path='api') - response = myclient.ask("my-userId", "hello") + Example of usage: - In this case next GET request will be invoked: - https://bot.domain.com:8443/api/ask - with params: - {'userId': 'my-userId', 'query': 'hello'} + from openchatbotclient.client import Client + + # You may create a Client using the native constructor + client = Client('bot.domain.com', 8443, path='api') + response = client.ask("my-userId", "hello") + + # Or using a URL to the API + client = Client.from_url("https://mybot.mydomain.com/api/v1/ask") + response = client.ask("john.doe", "what is the weather today?") + + The 'ask' method will cause a GET request to be invoked, such as: + https://bot.domain.com:8443/api/ask + with params: + {'userId': 'my-userId', 'query': 'hello'} Authors: - Alexander Danilov from Konverso @@ -18,6 +25,9 @@ - 2019/11/01: Alexander: Initial class implementation - 2020/11/02: Amédée: Renaming class to "client" - 2020/11/02: Amédée: Adding the "from_descriptor" static method + - 2020/12/15: Amédée: Adding the "from_url" static method + Adjusting names to be PEP8 compliants + """ import json @@ -97,7 +107,7 @@ def from_descriptor(descriptor): @staticmethod def from_url(url): - """Given a "descriptor" instance, returns a new "client" instance""" + """Given a URL pointing to the "ask" API, returns a new "client" instance""" # Extracting from the URL the protocol, the domain, the path # token0://token2/token3 @@ -126,6 +136,10 @@ def from_url(url): @property def base_url(self) -> str: + """Returns the URL of the remote bot "ask" API web service, + that is something like: + http[s]://host.domain[:port]/path/to/api/ask + """ url = self.host if self.port: From 365152a307d75f440c41606c4d0d4bf8cfb310df Mon Sep 17 00:00:00 2001 From: Amedee Potier Date: Wed, 30 Dec 2020 14:53:08 +0000 Subject: [PATCH 02/11] KB-8933: Improve online doc --- openchatbotclient/client_group.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openchatbotclient/client_group.py b/openchatbotclient/client_group.py index 4ce79e4..791fab0 100644 --- a/openchatbotclient/client_group.py +++ b/openchatbotclient/client_group.py @@ -9,6 +9,8 @@ History: - 2020/11/02: Amédée: Initial class implementation + - 2020/12/15: Amédée: Adjusting names to be PEP8 compliants + """ from .client import Client From 025b7aa9be6bc90c433070a614e680bbf6bfaaac Mon Sep 17 00:00:00 2001 From: Amedee Potier Date: Wed, 30 Dec 2020 14:53:14 +0000 Subject: [PATCH 03/11] KB-8933: Improve online doc --- openchatbotclient/repository.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openchatbotclient/repository.py b/openchatbotclient/repository.py index d9d6b97..ef128ff 100644 --- a/openchatbotclient/repository.py +++ b/openchatbotclient/repository.py @@ -10,6 +10,7 @@ History: - 2020/11/02: Amédée: Initial version. + - 2020/12/15: Amédée: Adjusting names to be PEP8 compliants """ From 1213d5b56bf9d5cfa8385e483d257db803c719f2 Mon Sep 17 00:00:00 2001 From: Amedee Potier Date: Wed, 30 Dec 2020 14:53:23 +0000 Subject: [PATCH 04/11] KB-8933: Improve package info --- setup.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 9b1f81f..509b743 100755 --- a/setup.py +++ b/setup.py @@ -4,14 +4,14 @@ long_description = fh.read() setuptools.setup( - name="open-chat-bot-client", - version="0.0.1", + name="open-chatbot-py-client", + version="0.1.0", author="Konverso", - author_email="", - description="Client for Open Chat Bot", + author_email="contact@konverso.ai", + description="Client to access any chatbot compliant with the Alliance for Open Chatbot standard", long_description=long_description, long_description_content_type="text/markdown", - url="https://konverso.ai", + url="https://www.konverso.ai", packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3", From e45fce100190b286f3e14a4462be446394a59c64 Mon Sep 17 00:00:00 2001 From: Amedee Potier Date: Wed, 30 Dec 2020 15:01:07 +0000 Subject: [PATCH 05/11] KB-8933: Add package inner documentation --- openchatbotclient/__init__.py | 43 ++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/openchatbotclient/__init__.py b/openchatbotclient/__init__.py index 9c27f9f..f6f4d95 100644 --- a/openchatbotclient/__init__.py +++ b/openchatbotclient/__init__.py @@ -1,4 +1,45 @@ -"""Client for Open Chat Bot's""" +""" +Open Chat Bot Client package +============================ + +This Python package contains utilities that allow you to find, access, and use bots that are compliant with the Alliance for Open Chatbot standard. The package is designed for the Python 3 environments. + +The Open Chatbot standard +------------------------- + +The implementation is based on the standard defined by the Alliance. + - The Alliance: https://www.alliance-open-chatbot.org/ + - The standard: https://github.com/alliance-for-openchatbot/standard + +Authors +------- + +The initial implementation is made by Konverso in 2020 by Alexander Danilov and Amedee Potier (amedee.potier@konverso.ai). + +See also +-------- + + - The API standard specifications: https://github.com/alliance-for-openchatbot/standard + - The definition of the standard bot descriptor: https://openchatbot.io/domainbots + - The easy-to-use web client that adds a widget connected to any chatbot to your website: https://github.com/ohoachuck/openchatbot-webclient + +License +------- + +This package is released under the MIT license. To learn more about it, view the LICENSE file in this folder. + +Usage +----- + +To get started, either view the test.py file in this module, or consult the help on the client module: + + from openchatbotclient import client + help(client) + +You may also find complete examples and tutorials in the related GitHub repository: + https://github.com/konverso-ai/open-chatbot-py-client + +""" from .client import Client from .descriptor import Descriptor From 2c44d1185cf645094a0a30e9c02177b4b3e57974 Mon Sep 17 00:00:00 2001 From: Amedee Potier Date: Wed, 30 Dec 2020 15:19:01 +0000 Subject: [PATCH 06/11] KB-8933: Improve the test --- openchatbotclient/test.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/openchatbotclient/test.py b/openchatbotclient/test.py index cec4d13..8981478 100644 --- a/openchatbotclient/test.py +++ b/openchatbotclient/test.py @@ -13,11 +13,17 @@ from openchatbotclient import Client - bot_konverso = Client('https://callbot.konverso.ai', port=443, path='/api/ask') + # Create a client using its constructor and query it + bot_konverso = Client('https://callbot.konverso.ai', port=443, path='/api/ask') response = bot_konverso.ask("amedee", "hello", lang="fr") print(response) + # Create a client using a URL pointing to its open chatbot API + bot_konverso = Client.from_url('https://callbot.konverso.ai/api/ask') + response = bot_konverso.ask("amedee", "hello you", lang="fr") + print(response) + # # Use the Repository to retrieve a Client or a Descriptor # @@ -92,11 +98,11 @@ import json print(json.dumps(bot_konverso.descriptor, indent=4)) - print("\n\n#### Testing wikipedia") - bot_doungdoung = Client.from_url('https://doungdoung.com/api/wikipedia/v1.0/ask') - response = bot_doungdoung.ask("amedee", "hello", lang="fr") - print("Wikipedia says: %s", response.text) + #print("\n\n#### Testing wikipedia") + #bot_doungdoung = Client.from_url('https://doungdoung.com/api/wikipedia/v1.0/ask') + #response = bot_doungdoung.ask("amedee", "hello", lang="fr") + #print("Wikipedia says: %s", response.text) bot_kwalys = repo.get_client("kwalys.com") response = bot_kwalys.ask("amedee", "hello", lang="fr") - print("EDF says: %s", response.text) + print("EDF replies: ", response.text) From 37ed72fc171654af61610e83d709525c8bfe3e48 Mon Sep 17 00:00:00 2001 From: Amedee Potier Date: Wed, 30 Dec 2020 15:19:59 +0000 Subject: [PATCH 07/11] KB-8933: Improve the doc further --- openchatbotclient/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openchatbotclient/__init__.py b/openchatbotclient/__init__.py index f6f4d95..3898ec7 100644 --- a/openchatbotclient/__init__.py +++ b/openchatbotclient/__init__.py @@ -19,9 +19,12 @@ See also -------- - - The API standard specifications: https://github.com/alliance-for-openchatbot/standard - - The definition of the standard bot descriptor: https://openchatbot.io/domainbots - - The easy-to-use web client that adds a widget connected to any chatbot to your website: https://github.com/ohoachuck/openchatbot-webclient + - The API standard specifications: + https://github.com/alliance-for-openchatbot/standard + - The definition of the standard bot descriptor: + https://openchatbot.io/domainbots + - The easy-to-use web client that adds a widget connected to any chatbot to your website: + https://github.com/ohoachuck/openchatbot-webclient License ------- From 2d4acf274f448dde0965d33a0cfdca3e3807d334 Mon Sep 17 00:00:00 2001 From: Dan-Konverso <73980622+Dan-Konverso@users.noreply.github.com> Date: Mon, 11 Jan 2021 10:10:05 +0500 Subject: [PATCH 08/11] Update __init__.py --- openchatbotclient/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openchatbotclient/__init__.py b/openchatbotclient/__init__.py index 3898ec7..79bb375 100644 --- a/openchatbotclient/__init__.py +++ b/openchatbotclient/__init__.py @@ -39,7 +39,7 @@ from openchatbotclient import client help(client) -You may also find complete examples and tutorials in the related GitHub repository: +View complete examples and tutorials in the related GitHub repository: https://github.com/konverso-ai/open-chatbot-py-client """ From b5b6d8931a292ea01233e1658b8c882aac1740d8 Mon Sep 17 00:00:00 2001 From: Dan-Konverso <73980622+Dan-Konverso@users.noreply.github.com> Date: Mon, 11 Jan 2021 10:11:27 +0500 Subject: [PATCH 09/11] Update client.py --- openchatbotclient/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openchatbotclient/client.py b/openchatbotclient/client.py index f8d1c0d..7b467f9 100644 --- a/openchatbotclient/client.py +++ b/openchatbotclient/client.py @@ -4,7 +4,7 @@ from openchatbotclient.client import Client - # You may create a Client using the native constructor + # You can create a Client using the native constructor client = Client('bot.domain.com', 8443, path='api') response = client.ask("my-userId", "hello") @@ -12,7 +12,7 @@ client = Client.from_url("https://mybot.mydomain.com/api/v1/ask") response = client.ask("john.doe", "what is the weather today?") - The 'ask' method will cause a GET request to be invoked, such as: + The 'ask' method causes a GET request to be invoked, such as: https://bot.domain.com:8443/api/ask with params: {'userId': 'my-userId', 'query': 'hello'} From 0d564c8466183a7ac9484492c87c5a5464b00cd1 Mon Sep 17 00:00:00 2001 From: Dan-Konverso <73980622+Dan-Konverso@users.noreply.github.com> Date: Mon, 11 Jan 2021 10:14:07 +0500 Subject: [PATCH 10/11] Update client_group.py --- openchatbotclient/client_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openchatbotclient/client_group.py b/openchatbotclient/client_group.py index 791fab0..9937513 100644 --- a/openchatbotclient/client_group.py +++ b/openchatbotclient/client_group.py @@ -9,7 +9,7 @@ History: - 2020/11/02: Amédée: Initial class implementation - - 2020/12/15: Amédée: Adjusting names to be PEP8 compliants + - 2020/12/15: Amédée: Adjusting names to be compliant with PEP8 """ From 9be625e90a7db41f46e3497e235a02a677dcb546 Mon Sep 17 00:00:00 2001 From: Dan-Konverso <73980622+Dan-Konverso@users.noreply.github.com> Date: Mon, 11 Jan 2021 10:14:40 +0500 Subject: [PATCH 11/11] Update repository.py --- openchatbotclient/repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openchatbotclient/repository.py b/openchatbotclient/repository.py index ef128ff..00e5f74 100644 --- a/openchatbotclient/repository.py +++ b/openchatbotclient/repository.py @@ -10,7 +10,7 @@ History: - 2020/11/02: Amédée: Initial version. - - 2020/12/15: Amédée: Adjusting names to be PEP8 compliants + - 2020/12/15: Amédée: Adjusting names to be compliant with PEP8 """