






import os
from shutil import copyfile
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


if TYPE_CHECKING:
							from transformers.pipelines.conversational import Conversation

a_      = logging.get_logger(__name__)

a_      = {"""vocab_file""": """tokenizer.model"""}

a_      = {
    """vocab_file""": {
        """hf-internal-testing/llama-tokenizer""": """https://huggingface.co/hf-internal-testing/llama-tokenizer/resolve/main/tokenizer.model""",
    },
    """tokenizer_file""": {
        """hf-internal-testing/llama-tokenizer""": """https://huggingface.co/hf-internal-testing/llama-tokenizer/resolve/main/tokenizer_config.json""",
    },
}
a_      = {
    """hf-internal-testing/llama-tokenizer""": 2_048,
}
a_      = """▁"""

a_      = """[INST]""", """[/INST]"""
a_      = """<<SYS>>\n""", """\n<</SYS>>\n\n"""

# fmt: off
a_      = """You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your\
answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure\
that your responses are socially unbiased and positive in nature.

If a question does not make any sense, or is not factually coherent, explain why instead of answering something not\
correct. If you don't know the answer to a question, please don't share false information."""





class 		SCREAMING_SNAKE_CASE__   (     UpperCAmelCase__    ):
		_UpperCAmelCase         =VOCAB_FILES_NAMES
		_UpperCAmelCase         =PRETRAINED_VOCAB_FILES_MAP
		_UpperCAmelCase         =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
		_UpperCAmelCase         =['input_ids', 'attention_mask']



		def __init__(    self:    Optional[int]				,   a:    Dict				,   a:    Union[str, Any]="<unk>"				,   a:    Optional[Any]="<s>"				,   a:    Optional[Any]="</s>"				,   a:    List[Any]=None				,   a:    Optional[Any] = None				,   a:    Union[str, Any]=True				,   a:    str=False				,   a:    Optional[Any]=False				,   a:    Optional[int]=True				,   **a:    Dict				,   )  ->str:






								'''simple docstring'''


								a_				     =   {} if sp_model_kwargs is None else sp_model_kwargs
								a_				     =   AddedToken(lowerCamelCase__				,   lstrip=lowerCamelCase__				,   rstrip=lowerCamelCase__) if isinstance(lowerCamelCase__				,   lowerCamelCase__) else bos_token
								a_				     =   AddedToken(lowerCamelCase__				,   lstrip=lowerCamelCase__				,   rstrip=lowerCamelCase__) if isinstance(lowerCamelCase__				,   lowerCamelCase__) else eos_token
								a_				     =   AddedToken(lowerCamelCase__				,   lstrip=lowerCamelCase__				,   rstrip=lowerCamelCase__) if isinstance(lowerCamelCase__				,   lowerCamelCase__) else unk_token
								a_				     =   AddedToken(lowerCamelCase__				,   lstrip=lowerCamelCase__				,   rstrip=lowerCamelCase__) if isinstance(lowerCamelCase__				,   lowerCamelCase__) else pad_token
								super().__init__(
								    bos_token=lowerCamelCase__				,   eos_token=lowerCamelCase__				,   unk_token=lowerCamelCase__				,   pad_token=lowerCamelCase__				,   add_bos_token=lowerCamelCase__				,   add_eos_token=lowerCamelCase__				,   sp_model_kwargs=self.sp_model_kwargs				,   clean_up_tokenization_spaces=lowerCamelCase__				,   legacy=lowerCamelCase__				,   **lowerCamelCase__				,   )
								if legacy:
														logger.warning_once(
														    f"""You are using the legacy behaviour of the {self.__class__}. This means that tokens that come after special tokens will not be properly handled. We recommend you to"""
														    " read the related pull request available at https://github.com/huggingface/transformers/pull/24565")
								a_				     =   legacy
								a_				     =   vocab_file
								a_				     =   add_bos_token
								a_				     =   add_eos_token
								a_				     =   spm.SentencePieceProcessor(**self.sp_model_kwargs)
								self.sp_model.Load(lowerCamelCase__)



		def __getstate__(    self:    Tuple)  ->List[Any]:






								'''simple docstring'''


								a_				     =   self.__dict__.copy()
								a_				     =   None
								a_				     =   self.sp_model.serialized_model_proto()
								return state



		def __setstate__(    self:    Union[str, Any]				,   a:    Tuple)  ->Tuple:






								'''simple docstring'''


								a_				     =   d
								a_				     =   spm.SentencePieceProcessor(**self.sp_model_kwargs)
								self.sp_model.LoadFromSerializedProto(self.sp_model_proto)



		@property
		def _lowerCAmelCase     (    self:    List[str])  ->Union[str, Any]:






								'''simple docstring'''


								return self.sp_model.get_piece_size()



		def _lowerCAmelCase     (    self:    str)  ->List[str]:






								'''simple docstring'''


								a_				     =   {self.convert_ids_to_tokens(lowerCamelCase__): i for i in range(self.vocab_size)}
								vocab.update(self.added_tokens_encoder)
								return vocab



		def _lowerCAmelCase     (    self:    int				,   a:    Dict				,   **a:    List[Any])  ->Optional[Any]:






								'''simple docstring'''


								if not self.legacy:
														a_				     =   SPIECE_UNDERLINE + text.replace(lowerCamelCase__				,   " ")
								return super().tokenize(lowerCamelCase__				,   **lowerCamelCase__)



		def _lowerCAmelCase     (    self:    Tuple				,   a:    Tuple)  ->str:






								'''simple docstring'''


								if not self.legacy:
														a_				     =   text.startswith(lowerCamelCase__)
														if is_first:
																				a_				     =   text[1:]

								a_				     =   self.sp_model.encode(lowerCamelCase__				,   out_type=lowerCamelCase__)

								if not self.legacy and not is_first and not text.startswith(" ") and tokens[0].startswith(lowerCamelCase__):
														a_				     =   ([tokens[0][1:]] if len(tokens[0]) > 1 else []) + tokens[1:]
								return tokens



		def _lowerCAmelCase     (    self:    Optional[Any]				,   a:    Union[str, Any])  ->Union[str, Any]:






								'''simple docstring'''


								return self.sp_model.piece_to_id(lowerCamelCase__)



		def _lowerCAmelCase     (    self:    Optional[Any]				,   a:    Optional[int])  ->Any:






								'''simple docstring'''


								a_				     =   self.sp_model.IdToPiece(lowerCamelCase__)
								return token



		def _lowerCAmelCase     (    self:    List[str]				,   a:    Any)  ->List[Any]:






								'''simple docstring'''


								a_				     =   []
								a_				     =   ""
								a_				     =   False
								for i, token in enumerate(lowerCamelCase__):
														# make sure that special tokens are not decoded using sentencepiece model
														if token in self.all_special_tokens:
																				if not prev_is_special and i != 0:
																										out_string += " "
																				out_string += self.sp_model.decode(lowerCamelCase__) + token
																				a_				     =   True
																				a_				     =   []
														else:
																				current_sub_tokens.append(lowerCamelCase__)
																				a_				     =   False
								out_string += self.sp_model.decode(lowerCamelCase__)
								return out_string



		def _lowerCAmelCase     (    self:    Any				,   a:    Any				,   a:    List[Any] = None)  ->Union[str, Any]:






								'''simple docstring'''


								if not os.path.isdir(lowerCamelCase__):
														logger.error(f"""Vocabulary path ({save_directory}) should be a directory""")
														return
								a_				     =   os.path.join(
								    lowerCamelCase__				,   (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"])

								if os.path.abspath(self.vocab_file) != os.path.abspath(lowerCamelCase__) and os.path.isfile(self.vocab_file):
														copyfile(self.vocab_file				,   lowerCamelCase__)
								elif not os.path.isfile(self.vocab_file):
														with open(lowerCamelCase__				,   "wb") as fi:
																				a_				     =   self.sp_model.serialized_model_proto()
																				fi.write(lowerCamelCase__)

								return (out_vocab_file,)



		def _lowerCAmelCase     (    self:    List[str]				,   a:    Optional[int]				,   a:    Optional[Any]=None)  ->str:






								'''simple docstring'''


								a_				     =   [self.bos_token_id] if self.add_bos_token else []
								a_				     =   [self.eos_token_id] if self.add_eos_token else []

								a_				     =   bos_token_id + token_ids_a + eos_token_id

								if token_ids_a is not None:
														a_				     =   output + bos_token_id + token_ids_a + eos_token_id

								return output



		def _lowerCAmelCase     (    self:    str				,   a:    Union[str, Any]				,   a:    str = None				,   a:    Dict = False)  ->Tuple:






								'''simple docstring'''


								if already_has_special_tokens:
														return super().get_special_tokens_mask(
														    token_ids_a=lowerCamelCase__				,   token_ids_a=lowerCamelCase__				,   already_has_special_tokens=lowerCamelCase__)

								a_				     =   [1] if self.add_bos_token else []
								a_				     =   [1] if self.add_eos_token else []

								if token_ids_a is None:
														return bos_token_id + ([0] * len(lowerCamelCase__)) + eos_token_id
								return (
								    bos_token_id
								    + ([0] * len(lowerCamelCase__))
								    + eos_token_id
								    + bos_token_id
								    + ([0] * len(lowerCamelCase__))
								    + eos_token_id
								)



		def _lowerCAmelCase     (    self:    Union[str, Any]				,   a:    int				,   a:    Dict = None)  ->str:






								'''simple docstring'''


								a_				     =   [self.bos_token_id] if self.add_bos_token else []
								a_				     =   [self.eos_token_id] if self.add_eos_token else []

								a_				     =   [0] * len(bos_token_id + token_ids_a + eos_token_id)

								if token_ids_a is not None:
														output += [1] * len(bos_token_id + token_ids_a + eos_token_id)

								return output




		def _lowerCAmelCase     (    self:    List[Any]				,   a:    int)  ->Any:






								'''simple docstring'''


								a_				     =   list(conversation.iter_texts())
								if not all([is_user for is_user, msg in dialogue[::2]]) or not all(
								    [not is_user for is_user, msg in dialogue[1::2]]):
														raise ValueError(
														    "The model only supports 'user' and 'assistant' roles, starting with user and alternating (u/a/u/a/u...)")

								a_				     =   []
								if len(conversation.past_user_inputs) > 0:
														if not conversation.past_user_inputs[0].startswith(lowerCamelCase__) or E_SYS not in conversation.past_user_inputs[0]:
																				a_				     =   (
																				    B_SYS + DEFAULT_SYSTEM_PROMPT + E_SYS + conversation.past_user_inputs[0]
																				)
								elif not dialogue[0][1].startswith(lowerCamelCase__) or E_SYS not in dialogue[0][1]:
														a_				     =   (dialogue[0][0], B_SYS + DEFAULT_SYSTEM_PROMPT + E_SYS + dialogue[0][1])

								dialog_tokens += sum(
								    [
								        [self.bos_token_id]
								        + self.encode(
								            f"""{B_INST} {(prompt[1]).strip()} {E_INST} {(answer[1]).strip()} """				,   add_special_tokens=lowerCamelCase__)
								        + [self.eos_token_id]
								        for prompt, answer in zip(dialogue[::2]				,   dialogue[1::2])
								    ]				,   []				,   )
								if not (dialogue[-1][0]):
														raise ValueError(f"""Last message must be from user, got {dialogue[-1]['role']}""")
								dialog_tokens += [self.bos_token_id] + self.encode(
								    f"""{B_INST} {(dialogue[-1][1]).strip()} {E_INST}"""				,   add_special_tokens=lowerCamelCase__)
								return dialog_tokens











'''simple docstring'''





import requests
from bsa import BeautifulSoup



def 			__UpperCAmelCase				(lowercase__	,lowercase__				)		->				str:

						'''simple docstring'''


						a_				     =   (
						    "https://www.horoscope.com/us/horoscopes/general/"
						    F"""horoscope-general-daily-{day}.aspx?sign={zodiac_sign}"""
						)
						a_				     =   BeautifulSoup(requests.get(lowercase__				).content	,"html.parser"				)
						return soup.find("div"	,class_="main-horoscope"				).p.text


if __name__ == "__main__":
							print('Daily Horoscope. \n')
							print(
							    'enter your Zodiac sign number:\n',
							    '1. Aries\n',
							    '2. Taurus\n',
							    '3. Gemini\n',
							    '4. Cancer\n',
							    '5. Leo\n',
							    '6. Virgo\n',
							    '7. Libra\n',
							    '8. Scorpio\n',
							    '9. Sagittarius\n',
							    '10. Capricorn\n',
							    '11. Aquarius\n',
							    '12. Pisces\n',
							)
							a_      = int(input('number> ').strip())
							print('choose some day:\n', 'yesterday\n', 'today\n', 'tomorrow\n')
							a_      = input('enter the day> ')
							a_      = horoscope(zodiac_sign, day)
							print(horoscope_text)



