File size: 842 Bytes
7900ffb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e949bd
7900ffb
 
 
 
 
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
import cohere

# Initialize the Cohere client with your API key
api_key = os.getenv('COHERE_API_KEY')
if not api_key:
    raise ValueError("Cohere API key not found in environment variables")

# Initialize the Cohere client with the API key from the environment variable
co = cohere.Client(api_key)

def generate_text(prompt):
    # Generate a response using the Cohere model
    response = co.generate(
        model='746cb80b-3fba-43ec-b14f-1b0f84e9ed4d-ft',
        prompt=prompt
    )
    # Return the generated text
    return response.generations[0].text

# Create a Gradio interface
iface = gr.Interface(
    fn=generate_text,
    inputs="text",
    outputs="text",
    title="Cohere Chatbot",
    description="Enter your prompt and get a response generated by Cohere.",
    theme='ParityError/Anime'
)

# Launch the app
iface.launch()