Skip to content

Commit

Permalink
updated the init and process signatures
Browse files Browse the repository at this point in the history
When using the example code was getting an error of too few arguments, updated the code based on what I saw in the built in logic adapters
  • Loading branch information
ryancollingwood authored and gunthercox committed Jan 30, 2019
1 parent 145d5d9 commit f753f06
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/logic/create-a-logic-adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ Example logic adapter
class MyLogicAdapter(LogicAdapter):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def __init__(self, chatbot, **kwargs):
super().__init__(chatbot, **kwargs)
def can_process(self, statement):
return True
def process(self, statement):
def process(self, input_statement, additional_response_selection_parameters):
import random
# Randomly select a confidence between 0 and 1
confidence = random.uniform(0, 1)
# For this example, we will just return the input as output
selected_statement = statement
selected_statement = input_statement
selected_statement.confidence = confidence
return selected_statement
Expand Down Expand Up @@ -100,7 +100,7 @@ For this example we will use a fictitious API endpoint that returns the current
else:
return False
def process(self, statement):
def process(self, input_statement, additional_response_selection_parameters):
from chatterbot.conversation import Statement
import requests
Expand Down Expand Up @@ -135,8 +135,8 @@ information passed to it by the ChatBot class.
.. code-block:: python
class MyLogicAdapter(LogicAdapter):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def __init__(self, chatbot, **kwargs):
super().__init__(chatbot, **kwargs)
self.api_key = kwargs.get('secret_key')
Expand Down

0 comments on commit f753f06

Please sign in to comment.