File size: 527 Bytes
ba968f8
503fdb7
 
 
 
 
ba968f8
 
 
 
 
 
 
 
 
 
 
 
503fdb7
ba968f8
 
 
503fdb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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