Make conversation processor configurable

This commit is contained in:
Debanjum Singh Solanky 2021-11-27 01:26:26 +05:30
parent d4e1120b22
commit a99b4b3434
3 changed files with 40 additions and 1 deletions

View file

@ -30,3 +30,9 @@ search-type:
image: image:
encoder: "clip-ViT-B-32" encoder: "clip-ViT-B-32"
processor:
conversation:
openai-api-key: null
conversation-logfile: "tests/data/.conversation_logs.json"
conversation-history: null

View file

@ -80,6 +80,15 @@ default_config = {
'image': 'image':
{ {
'encoder': "clip-ViT-B-32" 'encoder': "clip-ViT-B-32"
} },
},
'processor':
{
'conversation':
{
'openai-api-key': "",
'conversation-logfile': ".conversation_logs.json",
'conversation-history': ""
},
} }
} }

View file

@ -93,3 +93,27 @@ class SearchConfig():
ledger: TextSearchConfig = None ledger: TextSearchConfig = None
music: TextSearchConfig = None music: TextSearchConfig = None
image: ImageSearchConfig = None image: ImageSearchConfig = None
class ConversationProcessorConfig():
def __init__(self, conversation_logfile, conversation_history, openai_api_key, verbose):
self.openai_api_key = openai_api_key
self.conversation_logfile = conversation_logfile
self.conversation_history = conversation_history
self.verbose = verbose
def create_from_dictionary(config, key_tree, verbose):
conversation_config = get_from_dict(config, *key_tree)
if not conversation_config:
return None
return ConversationProcessorConfig(
openai_api_key = conversation_config['openai-api-key'],
conversation_history = '',
conversation_logfile = Path(conversation_config['conversation-logfile']),
verbose = verbose)
@dataclass
class ProcessorConfig():
conversation: ConversationProcessorConfig = None