File size: 1,552 Bytes
d5c3b26
 
2719ab0
d5c3b26
 
abcdcaf
d5c3b26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e7a6fb6
2719ab0
e7a6fb6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

import cohere
import os

# initialize Cohere client
co = cohere.Client("PYBgeV5VEGwJNrLn7gHpSlig6dFsKsUNTZlGOKs7")


conversation="""
Senior Dev: Hey, have you seen the latest pull request for the authentication module?
Junior Dev: No, not yet. What's in it?
Senior Dev: They've added support for JWT tokens, so we can use that instead of session cookies for authentication.
Junior Dev: Oh, that's great. I've been wanting to switch to JWT for a while now.
Senior Dev: Yeah, it's definitely more secure and scalable. I've reviewed the code and it looks good, so go ahead and merge it if you're comfortable with it.
Junior Dev: Will do, thanks for the heads up.
"""


response = co.summarize( conversation,
    model='summarize-xlarge', 
    length='short',
    extractiveness='high',
    temperature = 0.5,
)
summary = response.summary

print(summary)

import gradio as gr 
co = cohere.Client("CoHere_API_KEY")


def chat_summarizer(conversation):
    # generate summary using Cohere API
    response = co.summarize(conversation, model='summarize-xlarge',length='short', extractiveness='high', temperature=0.5)
    summary = response.summary
    
    return summary



chat_input = gr.inputs.Textbox(lines=10, label="Conversation")
chat_output = gr.outputs.Textbox(label="Summary")

chat_interface = gr.Interface(fn=chat_summarizer, inputs=chat_input, outputs=chat_output, 
                              title="Chat Summarizer", description="This app generates a summary of a chat conversation using Cohere API.")

chat_interface.launch(inline= False)