def __init__()

in genai-on-vertex-ai/gemini/needle_in_a_haystack/needlehaystack/providers/google.py [0:0]


    def __init__(self,
                 project_id: str,
                 model_name: str = "gemini-2.0-flash-001",
                 model_kwargs: dict = DEFAULT_MODEL_KWARGS,
                 vocab_file_url: str = VOCAB_FILE_URL):
        """
        Initializes the Google model provider with a specific model.

        Args:
            project_id (str): ID of the google cloud platform project to use
            model_name (str): The name of the Google model to use. Defaults to 'gemini-2.0-flash-001'.
            model_kwargs (dict): Model configuration. Defaults to {max_tokens: 300, temperature: 0}.
            vocab_file_url (str): Sentencepiece model file that defines tokenization vocabulary. Deafults to gemma
                tokenizer https://github.com/google/gemma_pytorch/blob/main/tokenizer/tokenizer.model
        """

        self.model_name = model_name
        self.model_kwargs = model_kwargs
        vertexai.init(project=project_id, location="us-central1")
        self.model = GenerativeModel(self.model_name)

        local_vocab_file = 'tokenizer.model'
        if not os.path.exists(local_vocab_file):
            response = requests.get(vocab_file_url)  # Download Tokenizer Vocab File (4MB)
            response.raise_for_status()

            with open(local_vocab_file, 'wb') as f:
                for chunk in response.iter_content():
                    f.write(chunk)
        self.tokenizer = sentencepiece.SentencePieceProcessor(local_vocab_file)

        resource_path = pkg_resources.resource_filename('needlehaystack', 'providers/gemini_prompt.txt')

        # Generate the prompt structure for the model
        # Replace the following file with the appropriate prompt structure
        with open(resource_path, 'r') as file:
            self.prompt_structure = file.read()