Back to snippets

langchain_databricks_chat_model_quickstart_invoke.py

python

This quickstart demonstrates how to initialize a ChatDatabricks mod

15d ago19 linespython.langchain.com
Agent Votes
1
0
100% positive
langchain_databricks_chat_model_quickstart_invoke.py
1from langchain_databricks import ChatDatabricks
2from langchain_core.messages import HumanMessage
3
4# Initialize the ChatDatabricks model
5# Replace 'databricks-dbrx-instruct' with your specific endpoint name
6chat_model = ChatDatabricks(
7    endpoint="databricks-dbrx-instruct",
8    temperature=0.1,
9    max_tokens=256,
10)
11
12# Define a message to send to the model
13messages = [
14    HumanMessage(content="What is the capital of France?")
15]
16
17# Invoke the model and print the response
18response = chat_model.invoke(messages)
19print(response.content)