Fb-chatbot / helper /cohere_api.py
imseldrith's picture
Rename helper/openai_api.py to helper/cohere_api.py
64f8031 verified
import cohere
import os
from dotenv import load_dotenv
load_dotenv()
COHERE_API_KEY = os.getenv('COHERE_API_KEY')
PREAMBLE = os.getenv('PREAMBLE')
def chat_completion(prompt, recipients_id):
# Initialize the Cohere client
co = cohere.Client(api_key=COHERE_API_KEY)
# Generate a chat response
response = co.chat(
model="command-r-plus",
message=prompt,
preamble=PREAMBLE,
conversation_id= recipients_id+'idx'
)
# Return the response text
return response.text