@classmethod
def process(cls, user_input: str) -> KnowledgeMessageIntel:
CollectionMap = get_collection_map_class()
collections = CollectionMap.process(user_input)
if collections[0] is None:
return KnowledgeMessageIntel(
body=(
'There was no knowledge related to your request. Please reword it '
'and try again.'
)
)
entries = []
for collection in collections:
if collection.entry_count > 0:
EntryMap = get_entry_map_class(collection=collection)
entries.extend(EntryMap.process(user_input))
entries = [entry for entry in entries if entry is not None]
if not entries:
return KnowledgeMessageIntel(
body=(
'There was no knowledge related to your request. Please reword it '
'and try again.'
)
)
entries_intel = EntriesIntel(
entry_intel_list=[
EntryIntel(
body=EntrySearchLlmBot.process(
user_input=user_input,
entry=entry
),
collection_intel=CollectionIntel(name=entry.collection.name)
)
for entry in entries
]
)
return KnowledgeMessageIntel(body=f'Entries: {entries_intel}')