from typing import Dict
from langchain.schema.document import Document

from qdrant import QwinQdrantClient

class CasinoGameInfoProvider:
    def __init__(self, user_id: str, qdrant: QwinQdrantClient):
        self.user_id = user_id
        self.qdrant = qdrant
    
    def game_info(self, query: Dict) -> [Document]:
        try:
            if query['search']:
                docs = self.qdrant.search_games_docs(query['search'])
                return [Document(page_content=doc) for doc in docs]

            game_codes = query['game_codes']
            key_words = query['key_words']

            if not game_codes and not key_words:
                return [Document(page_content='Ask the user to clarify what he wants to know')]
            
            docs = self.qdrant.search_game_docs(game_codes, key_words)
            return [Document(page_content=doc) for doc in docs]
        except:
            return [Document(page_content='There is no information. Clarify user question.')]