Spaces:
Sleeping
Sleeping
imseldrith
commited on
Update helper/openai_api.py
Browse files- helper/openai_api.py +16 -11
helper/openai_api.py
CHANGED
@@ -1,18 +1,23 @@
|
|
1 |
-
import
|
2 |
import os
|
3 |
from dotenv import load_dotenv
|
4 |
|
5 |
load_dotenv()
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
def chat_completion(prompt):
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
)
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
|
|
1 |
+
import cohere
|
2 |
import os
|
3 |
from dotenv import load_dotenv
|
4 |
|
5 |
load_dotenv()
|
6 |
|
7 |
+
COHERE_API_KEY = os.getenv('COHERE_API_KEY')
|
8 |
+
PREAMBLE = "You are Soni Bhabhi"
|
9 |
+
def chat_completion(prompt, recipients_id):
|
10 |
+
# Initialize the Cohere client
|
11 |
+
co = cohere.Client(api_key=COHERE_API_KEY)
|
12 |
+
|
13 |
+
# Generate a chat response
|
14 |
+
response = co.chat(
|
15 |
+
model="command-r-plus",
|
16 |
+
message=prompt,
|
17 |
+
preamble=PREAMBLE,
|
18 |
+
conversation_id=recipients_id
|
19 |
)
|
20 |
+
|
21 |
+
# Return the response text
|
22 |
+
return response.text
|
23 |
|