facilitator_bot
The facilitator bot contains the chatbot functionality for responding as a facilitator.
The faciliator chatbot can either return a generated text response or a logical response based on difference classification cases of the input.
Typical usage (module)
Independent usage
For testing or interacting directly the module can also be used as a script:
FacilitatorChat
Wraps Responder to interactively converse with a facilitator
Support interaction directly with a prompted openAI model or interactin with the custom role model or director models
Author's Note: This is primarily for use in the Support Group Facilitator Study.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chat_backend |
str
|
Which generative model to use. Defaults to "gpt". |
'gpt'
|
classifier_backend |
str
|
Which classifier model to use. Defaults to "llm". |
'llm'
|
Attributes:
| Name | Type | Description |
|---|---|---|
facilitator_prompt |
str
|
Prompt used by the generative chatbots |
classification_processor |
obj
|
Object for processing model classifications into a usable format. |
rm_facilitator |
obj
|
Logic for the Role Model Facilitator Condition |
d_facilitator |
obj
|
Logic for the Director Facilitator Condition |
Source code in backend/app/facilitator/facilitator_bot.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
get_bot_response(statement, speaker='Human', reset_conversation=False)
Get a response from the language model based on the prompt, statement, and conversation so far
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
statement |
str
|
Input statement the bot will respond to. |
required |
speaker |
str
|
Name of the speaker. Defaults to "Human". |
'Human'
|
reset_conversation |
bool
|
Resets the conversation to the beginning prompt. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Text of the bot response |
Source code in backend/app/facilitator/facilitator_bot.py
get_classifications(statement)
Passes the bot to the classification processor.
Different classifiers are processed differently. In order to properly handle the different methods for doing classification,
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
statement |
str
|
text of statement for classification. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
processed_classifications |
str
|
joined list of classes that have been classified. |
Source code in backend/app/facilitator/facilitator_bot.py
get_facilitator_response(director_condition=False)
Gets facilitator response for either Role Model or Director condition
based on the respective facilitator logic
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
director_condition |
bool
|
True if in the director condition, false if in the in the role model condition. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Recommended response to come from the facilitator. |
Source code in backend/app/facilitator/facilitator_bot.py
main()
Interactively test the FacilitatorChat
Must be run from the backend dir: $ python -m app.facilitator.facilitator_bot
Will run until killed with ctrl+c