Spaces:
Sleeping
Sleeping
Commit
·
2bc9cb4
1
Parent(s):
f1da378
Update app.py
Browse files
app.py
CHANGED
@@ -1,40 +1,18 @@
|
|
1 |
-
import
|
2 |
import cohere
|
3 |
|
4 |
# Initialize the Cohere client
|
5 |
-
co = cohere.Client('mTeiGiDIpi4R7perkfRnMnCmi5jJzM8QziDVPrG8') # Replace with your
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
response
|
11 |
-
model='9b2e329d-7542-4c44-8f8c-cac03a6c4f5a-ft',
|
12 |
-
prompt=prompt
|
13 |
-
)
|
14 |
-
output_text.config(state="normal") # Allow editing of the output box
|
15 |
-
output_text.delete("1.0", "end") # Clear the previous output
|
16 |
-
output_text.insert("1.0", response.generations[0].text) # Display the new output
|
17 |
-
output_text.config(state="disabled") # Disable editing of the output box
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
input_label = tk.Label(root, text="Enter your prompt:")
|
25 |
-
input_label.pack()
|
26 |
-
input_box = tk.Text(root, height=5, width=40)
|
27 |
-
input_box.pack()
|
28 |
-
|
29 |
-
# Create a button to generate text
|
30 |
-
generate_button = tk.Button(root, text="Generate", command=generate_text)
|
31 |
-
generate_button.pack()
|
32 |
-
|
33 |
-
# Create an output box
|
34 |
-
output_label = tk.Label(root, text="Generated Text:")
|
35 |
-
output_label.pack()
|
36 |
-
output_text = tk.Text(root, height=10, width=40, state="disabled")
|
37 |
-
output_text.pack()
|
38 |
-
|
39 |
-
# Start the GUI event loop
|
40 |
-
root.mainloop()
|
|
|
1 |
+
import gradio as gr
|
2 |
import cohere
|
3 |
|
4 |
# Initialize the Cohere client
|
5 |
+
co = cohere.Client('mTeiGiDIpi4R7perkfRnMnCmi5jJzM8QziDVPrG8') # Replace with your api_key
|
6 |
|
7 |
+
def generate_response(prompt):
|
8 |
+
output = co.generate(model='9b2e329d-7542-4c44-8f8c-cac03a6c4f5a-ft', prompt=prompt)
|
9 |
+
response = output.generations[0].text
|
10 |
+
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
iface = gr.Interface(fn=generate_response,
|
13 |
+
inputs="text",
|
14 |
+
outputs="text",
|
15 |
+
title='Cohere Text Generation',
|
16 |
+
description='Enter your prompt to generate text')
|
17 |
|
18 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|