Below is the documentation for integrating Reconify with Anthropic via Python PIP module.
Currently we support chat and completions on Anthropic.
If you are using Amazon Bedrock, refer to the Bedrock Python documentation.
The first step is to create an account at app.reconify.com.
In the Reconify console, add an Application to your account. This will generate both an API_KEY and an APP_KEY which will be used in the code below to send data to Reconify.
The easiest way to get started is to use the PIP module.
pip install reconify
from reconify import reconifyAnthropicHandler
Prior to initializing the Reconify module, make sure to import and initialize the Anthropic module
from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
anthropic = Anthropic(api_key = 'YOUR_ANTHROPIC_KEY')
Configure the instance of Reconify passing the Anthropic instance along with the Reconify API_KEY and APP_KEY created above.
reconifyAnthropicHandler.config(anthropic,
appKey = "YOUR_APP_KEY",
apiKey = "YOUR_API_KEY",
)
This is all that is needed for the basic integration. The module takes care of the rest.
You can optionally turn on "debug" mode by passing in "debug = True" in the method above. This will print debug messages to the console.
reconifyAnthropicHandler.config(anthropic,
appKey = "YOUR_APP_KEY",
apiKey = "YOUR_API_KEY",
debug = True,
)
You can optionally pass in a user object or session ID to be used in the analytics reporting. The session ID will be used to group interactions together in the same session transcript.
The user object should include a unique userId, the other fields are optional.
reconifyAnthropicHandler.setUser ({
"userId": "123",
"isAuthenticated": 1,
"firstName": "Francis",
"lastName": "Smith",
"email": "",
"phone": "",
"gender": "female"
});
The session ID is a simple string.
reconifyAnthropicHandler.setSession('MySessionId');
from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
from reconify import reconifyAnthropicHandler
anthropic = Anthropic(api_key = 'YOUR_ANTHROPIC_KEY')
reconifyAnthropicHandler.config(anthropic,
appKey = 'Your_App_Key',
apiKey = 'Your_Api_Key'
)
reconifyAnthropicHandler.setUser({
"userId": "12345",
"firstName": "Jim",
"lastName": "Smith"
})
response = anthropic.messages.create(
model="claude-2.1",
max_tokens=300,
messages=[
{"role": "user", "content":"Tell me a cat joke"}
]
)
from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
from reconify import reconifyAnthropicHandler
anthropic = Anthropic(api_key = 'YOUR_ANTHROPIC_KEY')
reconifyAnthropicHandler.config(anthropic,
appKey = 'Your_App_Key',
apiKey = 'Your_Api_Key'
)
reconifyAnthropicHandler.setUser({
"userId": "12345",
"firstName": "Jim",
"lastName": "Smith"
})
response = anthropic.completions.create(
model="claude-2",
max_tokens_to_sample=300,
prompt=f"{HUMAN_PROMPT} Tell me a good cat joke{AI_PROMPT}"
)