Fb-chatbot / helper /openai_api.py
imseldrith's picture
Update helper/openai_api.py
ba968f8 verified
raw
history blame
527 Bytes
import cohere
import os
from dotenv import load_dotenv
load_dotenv()
COHERE_API_KEY = os.getenv('COHERE_API_KEY')
PREAMBLE = "You are Soni Bhabhi"
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
)
# Return the response text
return response.text