Instructions to use easytt1178/example-model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use easytt1178/example-model with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("easytt1178/example-model", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download src/agents/bot_agent.py from easytt1178/example-model: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/easytt1178/example-model/resolve/main/src/agents/bot_agent.py
- Command line
-
hf download hf://easytt1178/example-model/src/agents/bot_agent.py
-
curl -L -o bot_agent.py https://huggingface.co/easytt1178/example-model/resolve/main/src/agents/bot_agent.py
2.06 kB
| import os | |
| TELEGRAM_TEMPLATE = """""" | |
| import os | |
| import logging | |
| from telegram import Update | |
| from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes | |
| TOKEN = os.getenv("TELEGRAM_TOKEN") | |
| async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): | |
| await update.message.reply_text("Hello! I'm your assistant bot.") | |
| async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE): | |
| await update.message.reply_text(update.message.text) | |
| def main(): | |
| if not TOKEN: | |
| raise RuntimeError("Set TELEGRAM_TOKEN env var") | |
| app = Application.builder().token(TOKEN).build() | |
| app.add_handler(CommandHandler("start", start)) | |
| app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo)) | |
| app.run_polling() | |
| if __name__ == "__main__": | |
| main() | |
| """""" | |
| DISCORD_TEMPLATE = """""" | |
| import os | |
| import discord | |
| TOKEN = os.getenv("DISCORD_TOKEN") | |
| intents = discord.Intents.default() | |
| intents.message_content = True | |
| client = discord.Client(intents=intents) | |
| async def on_ready(): | |
| print(f"Logged in as {client.user}") | |
| async def on_message(message: discord.Message): | |
| if message.author == client.user: | |
| return | |
| if message.content.startswith("!ping"): | |
| await message.channel.send("pong") | |
| def main(): | |
| if not TOKEN: | |
| raise RuntimeError("Set DISCORD_TOKEN env var") | |
| client.run(TOKEN) | |
| if __name__ == "__main__": | |
| main() | |
| """""" | |
| def create_bot(bot_type: str, output_dir: str = "bots") -> str: | |
| os.makedirs(output_dir, exist_ok=True) | |
| if bot_type == "telegram": | |
| path = os.path.join(output_dir, "telegram_bot.py") | |
| with open(path, "w", encoding="utf-8") as f: | |
| f.write(TELEGRAM_TEMPLATE) | |
| return path | |
| elif bot_type == "discord": | |
| path = os.path.join(output_dir, "discord_bot.py") | |
| with open(path, "w", encoding="utf-8") as f: | |
| f.write(DISCORD_TEMPLATE) | |
| return path | |
| else: | |
| raise ValueError("Unsupported bot_type. Use 'telegram' or 'discord'.") |