hrishikeshagi
commited on
Commit
·
4a9fd2e
1
Parent(s):
4fe68cc
Upload cohereblogpost.py
Browse files- cohereblogpost.py +43 -0
cohereblogpost.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""cohereblogpost.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1ayh0Wdn_olBVoK3oviOQnBx93AAS2g-M
|
8 |
+
"""
|
9 |
+
|
10 |
+
!pip install requests gradio -q
|
11 |
+
|
12 |
+
!pip install cohere -q
|
13 |
+
|
14 |
+
import cohere
|
15 |
+
|
16 |
+
co = cohere.Client('NTZ1vJAJ6xFNk8ibiQjVh8E5CQLafLpKxjWJc5jp')
|
17 |
+
|
18 |
+
def write_post(topic):
|
19 |
+
response = co.generate(
|
20 |
+
model='command-xlarge-20221108',
|
21 |
+
prompt=f' \"{topic}\":',
|
22 |
+
max_tokens=300,
|
23 |
+
temperature=0.9,
|
24 |
+
k=0,
|
25 |
+
p=0.75,
|
26 |
+
frequency_penalty=0,
|
27 |
+
presence_penalty=0,
|
28 |
+
stop_sequences=[],
|
29 |
+
return_likelihoods='NONE')
|
30 |
+
return(response.generations[0].text)
|
31 |
+
|
32 |
+
import gradio as gr
|
33 |
+
|
34 |
+
with gr.Blocks() as demo:
|
35 |
+
gr.Markdown("# Artificial Literature Generator : By Hrishikesh")
|
36 |
+
#with gr.Row():
|
37 |
+
inp = gr.Textbox(placeholder="Enter the text", label = "Topic")
|
38 |
+
btn = gr.Button("Generate 🚀")
|
39 |
+
out = gr.Textbox()
|
40 |
+
btn.click(fn=write_post, inputs=inp, outputs=out)
|
41 |
+
|
42 |
+
demo.launch(debug = True)
|
43 |
+
|