Skip to content

Commit 6604b9b

Browse files
committed
add migrations
1 parent 7edd759 commit 6604b9b

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

kubechat/chat/websocket/routing.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ async def bot_consumer_router(scope, receive, send):
1010
from kubechat.db.models import CollectionType
1111
from kubechat.db.ops import query_chat
1212
from kubechat.db.ops import query_bot
13+
from kubechat.db.models import BotType
1314

1415
user = scope.get(KEY_USER_ID, None)
1516
path = scope["path"]
@@ -25,23 +26,28 @@ async def bot_consumer_router(scope, receive, send):
2526
raise Exception("Chat not found")
2627
scope[KEY_CHAT_ID] = chat_id
2728

28-
if collection.type == CollectionType.DOCUMENT:
29+
if bot.type == BotType.KNOWLEDGE:
30+
if collection.type == CollectionType.DOCUMENT:
2931

30-
if settings.CHAT_CONSUMER_IMPLEMENTATION == "document-qa":
31-
from kubechat.chat.websocket.document_qa_consumer import DocumentQAConsumer
32-
return await DocumentQAConsumer.as_asgi()(scope, receive, send)
33-
elif settings.CHAT_CONSUMER_IMPLEMENTATION == "fake":
34-
from kubechat.chat.websocket.fake_consumer import FakeConsumer
35-
return await FakeConsumer.as_asgi()(scope, receive, send)
32+
if settings.CHAT_CONSUMER_IMPLEMENTATION == "document-qa":
33+
from kubechat.chat.websocket.document_qa_consumer import DocumentQAConsumer
34+
return await DocumentQAConsumer.as_asgi()(scope, receive, send)
35+
elif settings.CHAT_CONSUMER_IMPLEMENTATION == "fake":
36+
from kubechat.chat.websocket.fake_consumer import FakeConsumer
37+
return await FakeConsumer.as_asgi()(scope, receive, send)
38+
else:
39+
from kubechat.chat.websocket.embedding_consumer import EmbeddingConsumer
40+
return await EmbeddingConsumer.as_asgi()(scope, receive, send)
41+
elif collection.type == CollectionType.DATABASE:
42+
from kubechat.chat.websocket.text_2_sql_consumer import Text2SQLConsumer
43+
return await Text2SQLConsumer.as_asgi()(scope, receive, send)
3644
else:
37-
from kubechat.chat.websocket.embedding_consumer import EmbeddingConsumer
38-
return await EmbeddingConsumer.as_asgi()(scope, receive, send)
39-
elif collection.type == CollectionType.DATABASE:
40-
from kubechat.chat.websocket.text_2_sql_consumer import Text2SQLConsumer
41-
42-
return await Text2SQLConsumer.as_asgi()(scope, receive, send)
45+
raise Exception("Invalid collection type")
46+
elif bot.type == BotType.COMMON:
47+
from kubechat.chat.websocket.common_consumer import CommonConsumer
48+
return await CommonConsumer.as_asgi()(scope, receive, send)
4349
else:
44-
raise Exception("Invalid collection type")
50+
raise Exception("Invalid bot type")
4551

4652

4753
async def web_bot_consumer_router(scope, receive, send):

0 commit comments

Comments
 (0)