import cohere import gradio as gr import os # 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="Welcome to Tonic's 🌈Here.Chat🗣️😷", description=""" ### How To Use 🌈Here.Chat: 🗣️📝Chat with the bot via text 👇🏻📩 Press send . Check out the model [Cohere/CoChat](https://dashboard.cohere.com/playground/generate) and check out the dataset used to train using Cohere: [tonic/easyreddit](https://huggingface.co/datasets/Tonic/EasyReddit) . This bot is trained on randomized reddit for maximum creativity. You can also use 🗣️😷Here.Chat via API below or by cloning this space. 🧬🔬🔍 Simply click here: Duplicate Space #### Join us : 🌟TeamTonic🌟 is always making cool demos! Join our active builder's🛠️community on 👻Discord: [Discord](https://discord.gg/GWpVpekp) On 🤗Huggingface: [TeamTonic](https://huggingface.co/TeamTonic) & [MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Polytonic](https://github.com/tonic-ai) & contribute to 🌟 [PolyGPT](https://github.com/tonic-ai/polygpt-alpha)" Add this space as a 🤖discordbot to your server by [clicking here](https://discord.com/oauth2/authorize?client_id=1174639739492646993&scope=bot+applications.commands&permissions=326417525824() """, theme='ParityError/Anime' ) # Launch the app iface.launch()