Spaces:
Sleeping
Sleeping
Commit
·
657b7ec
1
Parent(s):
646f93c
Update app.py
Browse files
app.py
CHANGED
@@ -4,16 +4,20 @@ import cohere
|
|
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(
|
|
|
|
|
|
|
|
|
9 |
response = output.generations[0].text
|
10 |
return response
|
11 |
|
12 |
iface = gr.Interface(fn=generate_response,
|
13 |
-
inputs="
|
|
|
14 |
outputs="text",
|
15 |
title='Cohere Text Generation',
|
16 |
description='Enter your prompt to generate text')
|
17 |
|
18 |
iface.launch(share=True)
|
19 |
-
|
|
|
4 |
# Initialize the Cohere client
|
5 |
co = cohere.Client('mTeiGiDIpi4R7perkfRnMnCmi5jJzM8QziDVPrG8') # Replace with your api_key
|
6 |
|
7 |
+
def generate_response(prompt, temperature):
|
8 |
+
output = co.generate(
|
9 |
+
model='9b2e329d-7542-4c44-8f8c-cac03a6c4f5a-ft',
|
10 |
+
prompt=prompt,
|
11 |
+
options={'temperature': temperature} # set temperature
|
12 |
+
)
|
13 |
response = output.generations[0].text
|
14 |
return response
|
15 |
|
16 |
iface = gr.Interface(fn=generate_response,
|
17 |
+
inputs=[gr.inputs.Textbox(lines=2, label="Prompt"),
|
18 |
+
gr.inputs.Slider(minimum=0, maximum=1, default=0.5, label="Temperature")],
|
19 |
outputs="text",
|
20 |
title='Cohere Text Generation',
|
21 |
description='Enter your prompt to generate text')
|
22 |
|
23 |
iface.launch(share=True)
|
|