Skip to content

Commit

Permalink
feat: Added MediaWiki query engine!
Browse files Browse the repository at this point in the history
  • Loading branch information
amindadgar committed May 16, 2024
1 parent f32a46f commit f7d62fd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
17 changes: 15 additions & 2 deletions subquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
DEFAULT_GUIDANCE_SUB_QUESTION_PROMPT_TMPL,
GDriveQueryEngine,
GitHubQueryEngine,
MediaWikiQueryEngine,
NotionQueryEngine,
prepare_discord_engine_auto_filter,
)
Expand Down Expand Up @@ -72,7 +73,7 @@ def query_multiple_source(
# discourse_query_engine: BaseQueryEngine
gdrive_query_engine: BaseQueryEngine
notion_query_engine: BaseQueryEngine
# media_wiki_query_engine: BaseQueryEngine
media_wiki_query_engine: BaseQueryEngine
# telegram_query_engine: BaseQueryEngine

# query engine perparation
Expand Down Expand Up @@ -144,7 +145,19 @@ def query_multiple_source(
)
)
if media_wiki:
raise NotImplementedError
mediawiki_query_engine = MediaWikiQueryEngine(
community_id=community_id
).prepare()
tool_metadata = ToolMetadata(
name="WikiPedia",
description="Hosts articles about any information on internet",
)
query_engine_tools.append(
QueryEngineTool(
query_engine=mediawiki_query_engine,
metadata=tool_metadata,
)
)

embed_model = CohereEmbedding()
llm = OpenAI("gpt-3.5-turbo")
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_mediawiki_query_engine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from unittest import TestCase

from bot.retrievers.custom_retriever import CustomVectorStoreRetriever
from utils.query_engine import MediaWikiQueryEngine


class TestMediaWikiQueryEngine(TestCase):
def setUp(self) -> None:
community_id = "sample_community"
self.notion_query_engine = MediaWikiQueryEngine(community_id)

def test_prepare_engine(self):
notion_query_engine = self.notion_query_engine.prepare(testing=True)
print(notion_query_engine.__dict__)
self.assertIsInstance(notion_query_engine.retriever, CustomVectorStoreRetriever)
1 change: 1 addition & 0 deletions utils/query_engine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# flake8: noqa
from .gdrive import GDriveQueryEngine
from .github import GitHubQueryEngine
from .media_wiki import MediaWikiQueryEngine
from .notion import NotionQueryEngine
from .prepare_discord_query_engine import prepare_discord_engine_auto_filter
from .subquery_gen_prompt import DEFAULT_GUIDANCE_SUB_QUESTION_PROMPT_TMPL
7 changes: 7 additions & 0 deletions utils/query_engine/media_wiki.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from utils.query_engine.base_engine import BaseEngine


class MediaWikiQueryEngine(BaseEngine):
def __init__(self, community_id: str) -> None:
platform_name = "mediawiki"
super().__init__(platform_name, community_id)

0 comments on commit f7d62fd

Please sign in to comment.