Below is the documentation for integrating Reconify with Cohere via Python PIP module.
Currently we support chat and generate completions on Cohere.
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 reconifyCohereHandler
Prior to initializing the Reconify module, make sure to import and initialize the Cohere module
from cohere import Client
cohere_client = Client('YOUR_COHERE_KEY')
Configure the instance of Reconify passing the Cohere instance along with the Reconify API_KEY and APP_KEY created above.
reconifyCohereHandler.config(cohere_client,
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.
reconifyCohereHandler.config(cohere_client,
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.
reconifyCohereHandler.setUser ({
"userId": "123",
"isAuthenticated": 1,
"firstName": "Francis",
"lastName": "Smith",
"email": "",
"phone": "",
"gender": "female"
});
The session ID is a simple string.
reconifyCohereHandler.setSession('MySessionId');
from cohere import Client
from reconify import reconifyCohereHandler
cohere_client = Client('YOUR_COHERE_KEY')
reconifyCohereHandler.config(cohere_client,
appKey = 'Your_App_Key',
apiKey = 'Your_Api_Key'
)
reconifyCohereHandler.setUser({
"userId": "12345",
"firstName": "Jim",
"lastName": "Smith"
})
response = cohere_client.chat(
model="command",
message="tell me a good cat joke"
)
from cohere import Client
from reconify import reconifyCohereHandler
cohere_client = Client('YOUR_COHERE_KEY')
reconifyCohereHandler.config(cohere_client,
appKey = 'Your_App_Key',
apiKey = 'Your_Api_Key'
)
reconifyCohereHandler.setUser({
"userId": "12345",
"firstName": "Jim",
"lastName": "Smith"
})
response = cohere_client.generate(
model="command",
prompt="write a cat haiku",
max_tokens=300
)