English to French"human = "Translate this sentence from English to French. I love programming."prompt = ChatPromptTemplate.from_messages(    [("system", system), ("human",  human)])messages = prompt.format_messages()chat(messages)    AIMessage(content=" J'aime la programmation.", additional_kwargs={}, example=False)If we want to construct a simple chain that takes user specified parameters:system = "You are a helpful assistant that translates {input_language} to {output_language}."human = "{text}"prompt = ChatPromptTemplate.from_messages(    [("system", system), ("human",  human)])chain = prompt | chatchain.invoke(    {"input_language": "English", "output_language": "Japanese", "text": "I love programming"})    AIMessage(content=' ÁßÅ„ÅØ„Éó„É≠„Ç∞„É©„Éü„É≥„Ç∞„ÅåÂ§ßÂ•Ω„Åç„Åß„Åô„ÄÇ', additional_kwargs={}, example=False)Code generation chat models‚ÄãYou can now leverage the Codey API for code chat within Vertex AI. The model name is:codechat-bison: for code assistancechat = ChatVertexAI(    model_name="codechat-bison",    max_output_tokens=1000,    temperature=0.5)# For simple string in string out usage, we can use the `predict` method:print(chat.predict("Write a Python function to identify all prime numbers"))     ```python    def is_prime(x):         if (x <= 1):             return False        for i in range(2, x):             if (x % i == 0):                 return False        return True    ```Asynchronous calls‚ÄãWe can make asynchronous calls via the agenerate and ainvoke methods.import asyncio# import nest_asyncio# nest_asyncio.apply()chat = ChatVertexAI(    model_name="chat-bison",    max_output_tokens=1000,    temperature=0.7,    top_p=0.95,    top_k=40,)asyncio.run(chat.agenerate([messages]))    LLMResult(generations=[[ChatGeneration(text=" J'aime la programmation.", generation_info=None, message=AIMessage(content=" J'aime la programmation.", additional_kwargs={}, example=False))]], llm_output={},
Note: This is seperate from the Google PaLM integration. Google has chosen to offer an enterprise version of PaLM through GCP, and this supports the models made available through there.
Note: This is seperate from the Google PaLM integration. Google has chosen to offer an enterprise version of PaLM through GCP, and this supports the models made available through there. ->: English to French"human = "Translate this sentence from English to French. I love programming."prompt = ChatPromptTemplate.from_messages(    [("system", system), ("human",  human)])messages = prompt.format_messages()chat(messages)    AIMessage(content=" J'aime la programmation.", additional_kwargs={}, example=False)If we want to construct a simple chain that takes user specified parameters:system = "You are a helpful assistant that translates {input_language} to {output_language}."human = "{text}"prompt = ChatPromptTemplate.from_messages(    [("system", system), ("human",  human)])chain = prompt | chatchain.invoke(    {"input_language": "English", "output_language": "Japanese", "text": "I love programming"})    AIMessage(content=' ÁßÅ„ÅØ„Éó„É≠„Ç∞„É©„Éü„É≥„Ç∞„ÅåÂ§ßÂ•Ω„Åç„Åß„Åô„ÄÇ', additional_kwargs={}, example=False)Code generation chat models‚ÄãYou can now leverage the Codey API for code chat within Vertex AI. The model name is:codechat-bison: for code assistancechat = ChatVertexAI(    model_name="codechat-bison",    max_output_tokens=1000,    temperature=0.5)# For simple string in string out usage, we can use the `predict` method:print(chat.predict("Write a Python function to identify all prime numbers"))     ```python    def is_prime(x):         if (x <= 1):             return False        for i in range(2, x):             if (x % i == 0):                 return False        return True    ```Asynchronous calls‚ÄãWe can make asynchronous calls via the agenerate and ainvoke methods.import asyncio# import nest_asyncio# nest_asyncio.apply()chat = ChatVertexAI(    model_name="chat-bison",    max_output_tokens=1000,    temperature=0.7,    top_p=0.95,    top_k=40,)asyncio.run(chat.agenerate([messages]))    LLMResult(generations=[[ChatGeneration(text=" J'aime la programmation.", generation_info=None, message=AIMessage(content=" J'aime la programmation.", additional_kwargs={}, example=False))]], llm_output={},