|
import anthropic |
|
|
|
|
|
def get_anthropic_response(question): |
|
|
|
client = anthropic.Anthropic(api_key="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") |
|
|
|
|
|
model_name = "claude-3-opus-20240229" |
|
max_tokens = 1024 |
|
|
|
|
|
message = client.messages.create( |
|
model=model_name, |
|
max_tokens=max_tokens, |
|
messages=[{"role": "user", "content": question}] |
|
) |
|
|
|
|
|
return message.content |
|
|
|
|
|
def chatbot(user_message): |
|
|
|
response = get_anthropic_response(user_message) |
|
print(response) |
|
return response[0].text |
|
|