How can I deploy a chat bot using vertex ai?

how can I authenticate my account, so that after deploying the chat app will give me a response and connect to vertex ai. Locally it’s working because I use - [gcloud auth application-default login] to authenticate my code. New to this, so any help would be greatly appreciated.

def LLM_init():
    template = """some prompt
    {chat_history}
        Human: {human_input}
        Chatbot:"""

    promptllm = PromptTemplate(template=template, input_variables=["chat_history","human_input"])
    memory = ConversationBufferMemory(memory_key="chat_history")

    PROJECT_ID = os.environ.get("GCP_PROJECT")  # Your Google Cloud Project ID
    LOCATION = os.environ.get("GCP_REGION")  # Your Google Cloud Project Region
    vertexai.init(project=PROJECT_ID, location=LOCATION)

    
    safety_settings = {
    generative_models.HarmCategory.HARM_CATEGORY_HATE_SPEECH: generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
    generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
    generative_models.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
    generative_models.HarmCategory.HARM_CATEGORY_HARASSMENT: generative_models.HarmBlockThreshold.BLOCK_ONLY_HIGH,
}

    llm_chain = LLMChain(
        prompt=promptllm, 
        llm=VertexAI(model_name="gemini-1.5-flash-001", safety_settings=safety_settings), 
        memory=memory, 
        verbose=True
    ) 
    return llm_chain

This is perhaps what your are looking for:

@Calise Did you get this working? If so, please post steps taken? Thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.