2021-09-30 04:18:33 +02:00
|
|
|
# System Packages
|
2021-09-30 04:02:55 +02:00
|
|
|
from enum import Enum
|
2021-09-30 04:18:33 +02:00
|
|
|
from dataclasses import dataclass
|
2021-09-30 11:04:04 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
# Internal Packages
|
2021-12-09 14:50:38 +01:00
|
|
|
from src.utils.rawconfig import ConversationProcessorConfig
|
2021-09-30 04:02:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SearchType(str, Enum):
|
2022-07-21 19:57:57 +02:00
|
|
|
Org = "org"
|
2021-09-30 04:02:55 +02:00
|
|
|
Ledger = "ledger"
|
|
|
|
Music = "music"
|
2022-07-21 18:22:24 +02:00
|
|
|
Markdown = "markdown"
|
2021-09-30 04:02:55 +02:00
|
|
|
Image = "image"
|
|
|
|
|
2021-09-30 04:18:33 +02:00
|
|
|
|
2022-08-11 18:11:25 +02:00
|
|
|
class ProcessorType(str, Enum):
|
|
|
|
Conversation = "conversation"
|
|
|
|
|
|
|
|
|
2021-09-30 11:04:04 +02:00
|
|
|
class TextSearchModel():
|
|
|
|
def __init__(self, entries, corpus_embeddings, bi_encoder, cross_encoder, top_k, verbose):
|
2021-09-30 05:24:27 +02:00
|
|
|
self.entries = entries
|
|
|
|
self.corpus_embeddings = corpus_embeddings
|
|
|
|
self.bi_encoder = bi_encoder
|
|
|
|
self.cross_encoder = cross_encoder
|
|
|
|
self.top_k = top_k
|
2021-09-30 11:04:04 +02:00
|
|
|
self.verbose = verbose
|
2021-09-30 06:09:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ImageSearchModel():
|
2021-09-30 11:04:04 +02:00
|
|
|
def __init__(self, image_names, image_embeddings, image_metadata_embeddings, image_encoder, verbose):
|
|
|
|
self.image_encoder = image_encoder
|
2021-09-30 06:09:42 +02:00
|
|
|
self.image_names = image_names
|
|
|
|
self.image_embeddings = image_embeddings
|
|
|
|
self.image_metadata_embeddings = image_metadata_embeddings
|
|
|
|
self.image_encoder = image_encoder
|
2021-09-30 11:04:04 +02:00
|
|
|
self.verbose = verbose
|
2021-09-30 06:09:42 +02:00
|
|
|
|
|
|
|
|
2021-09-30 05:24:27 +02:00
|
|
|
@dataclass
|
|
|
|
class SearchModels():
|
2022-07-21 19:57:57 +02:00
|
|
|
orgmode_search: TextSearchModel = None
|
2021-09-30 11:04:04 +02:00
|
|
|
ledger_search: TextSearchModel = None
|
|
|
|
music_search: TextSearchModel = None
|
2022-07-21 18:22:24 +02:00
|
|
|
markdown_search: TextSearchModel = None
|
2021-09-30 06:09:42 +02:00
|
|
|
image_search: ImageSearchModel = None
|
2021-09-30 11:04:04 +02:00
|
|
|
|
|
|
|
|
2021-12-09 14:50:38 +01:00
|
|
|
class ConversationProcessorConfigModel():
|
|
|
|
def __init__(self, processor_config: ConversationProcessorConfig, verbose: bool):
|
2021-12-20 08:56:35 +01:00
|
|
|
self.openai_api_key = processor_config.openai_api_key
|
2021-11-28 17:57:33 +01:00
|
|
|
self.conversation_logfile = Path(processor_config.conversation_logfile)
|
2021-12-20 08:56:35 +01:00
|
|
|
self.chat_session = ''
|
2021-11-28 22:22:52 +01:00
|
|
|
self.meta_log = []
|
2021-09-30 11:04:04 +02:00
|
|
|
self.verbose = verbose
|
|
|
|
|
|
|
|
|
2021-11-26 20:56:26 +01:00
|
|
|
@dataclass
|
2021-12-09 14:50:38 +01:00
|
|
|
class ProcessorConfigModel():
|
|
|
|
conversation: ConversationProcessorConfigModel = None
|