- chatbot/plugins/chat.py +3 -3
chatbot/plugins/chat.py
CHANGED
@@ -167,10 +167,10 @@ gen = genai.Client(api_key=GOOGLE_API_KEY)
|
|
167 |
|
168 |
async def search_auto_by_cohere(user_id, prompt):
|
169 |
COHERE_API_KEY = os.environ.get("COHERE_API_KEY")
|
170 |
-
co = cohere.
|
171 |
chat_history = await db._get_cohere_chat_from_db(user_id)
|
172 |
chat_history.append({"role": "User", "message": prompt})
|
173 |
-
stream =
|
174 |
model='command-r-08-2024',
|
175 |
message=prompt,
|
176 |
temperature=0.3,
|
@@ -180,7 +180,7 @@ async def search_auto_by_cohere(user_id, prompt):
|
|
180 |
)
|
181 |
data = []
|
182 |
output = ""
|
183 |
-
|
184 |
if event.event_type == "search-results":
|
185 |
if event.documents:
|
186 |
data.extend(event.documents)
|
|
|
167 |
|
168 |
async def search_auto_by_cohere(user_id, prompt):
|
169 |
COHERE_API_KEY = os.environ.get("COHERE_API_KEY")
|
170 |
+
co = cohere.Client(api_key=COHERE_API_KEY)
|
171 |
chat_history = await db._get_cohere_chat_from_db(user_id)
|
172 |
chat_history.append({"role": "User", "message": prompt})
|
173 |
+
stream = co.chat_stream(
|
174 |
model='command-r-08-2024',
|
175 |
message=prompt,
|
176 |
temperature=0.3,
|
|
|
180 |
)
|
181 |
data = []
|
182 |
output = ""
|
183 |
+
for event in stream:
|
184 |
if event.event_type == "search-results":
|
185 |
if event.documents:
|
186 |
data.extend(event.documents)
|