from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage
from langchain_salesforce import SalesforceTool
# Initialize the Salesforce tool
tool = SalesforceTool(
username=username, password=password, security_token=security_token, domain=domain
)
# Initialize Anthropic LLM
llm = ChatAnthropic(model="claude-sonnet-4-20250514")
# First, let's query some contacts to get real data
contacts_query = {
"operation": "query",
"query": "SELECT Id, Name, Email, Phone FROM Contact LIMIT 3",
}
contacts_result = tool.invoke(contacts_query)
# Now let's use the LLM to analyze and summarize the contact data
if contacts_result and "records" in contacts_result:
contact_data = contacts_result["records"]
# Create a message asking the LLM to analyze the contact data
analysis_prompt = f"""
Please analyze the following Salesforce contact data and provide insights:
Contact Data: {contact_data}
Please provide:
1. A summary of the contacts
2. Any patterns you notice
3. Suggestions for data quality improvements
"""
message = HumanMessage(content=analysis_prompt)
analysis_result = llm.invoke([message])
print("\nLLM Analysis:")
print(analysis_result.content)