-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: additional cohere support and example script (#212)
- Loading branch information
Showing
3 changed files
with
94 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import cohere | ||
import agentops # just | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
agentops.init(tags=["cohere", "agentops-demo"]) # three | ||
co = cohere.Client() | ||
|
||
stream = co.chat_stream( | ||
message="Tell me everything you can about AgentOps", | ||
connectors=[{"id": "web-search"}] | ||
) | ||
|
||
response = "" | ||
for event in stream: | ||
if event.event_type == "text-generation": | ||
response += event.text | ||
print(event.text, end='') | ||
elif event.event_type == "stream-end": | ||
print("\n") | ||
print(event) | ||
print("\n") | ||
|
||
stream = co.chat_stream( | ||
chat_history=[ | ||
{"role": "SYSTEM", "message": "You are Adam Silverman: die-hard advocate of AgentOps, leader in AI Agent observability"}, | ||
{ | ||
"role": "CHATBOT", | ||
"message": "How's your day going? I'd like to tell you about AgentOps: {response}", | ||
}, | ||
], | ||
message="Based on your newfound knowledge of AgentOps, is Cohere a suitable partner for them and how could they integrate?", | ||
connectors=[{"id": "web-search"}] | ||
) | ||
|
||
response = "" | ||
for event in stream: | ||
if event.event_type == "text-generation": | ||
response += event.text | ||
print(event.text, end='') | ||
elif event.event_type == "stream-end": | ||
print("\n") | ||
print(event) | ||
print("\n") | ||
|
||
agentops.end_session('Success') # lines |