in patterns/agents/util.py [0:0]
def llm_call(prompt: str, system_prompt: str = "", model="claude-3-5-sonnet-20241022") -> str:
"""
Calls the model with the given prompt and returns the response.
Args:
prompt (str): The user prompt to send to the model.
system_prompt (str, optional): The system prompt to send to the model. Defaults to "".
model (str, optional): The model to use for the call. Defaults to "claude-3-5-sonnet-20241022".
Returns:
str: The response from the language model.
"""
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
messages = [{"role": "user", "content": prompt}]
response = client.messages.create(
model=model,
max_tokens=4096,
system=system_prompt,
messages=messages,
temperature=0.1,
)
return response.content[0].text