TeamTonic/coherebot
0
1import cohere2import gradio as gr3import os4 5# Initialize the Cohere client with your API key6api_key = os.getenv('COHERE_API_KEY')7if not api_key:8 raise ValueError("Cohere API key not found in environment variables")9 10# Initialize the Cohere client with the API key from the environment variable11co = cohere.Client(api_key)12 13def generate_text(prompt):14 # Generate a response using the Cohere model15 response = co.generate(16 model='746cb80b-3fba-43ec-b14f-1b0f84e9ed4d-ft',17 prompt=prompt18 )19 # Return the generated text20 return response.generations[0].text21 22# Create a Gradio interface23iface = gr.Interface(24 fn=generate_text,25 inputs="text",26 outputs="text",27 title="Welcome to Tonic's 🌈Here.Chat🗣️😷",28 description="""29 ### How To Use 🌈Here.Chat: 30 🗣️📝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. 31 You can also use 🗣️😷Here.Chat via API below or by cloning this space. 🧬🔬🔍 Simply click here: <a style="display:inline-block" href="https://huggingface.co/spaces/TeamTonic/coherebot?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></h3>32 #### Join us : 33 🌟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)"34 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() 35 """,36 theme='ParityError/Anime'37)38 39# Launch the app40iface.launch()