Downloads · 30 days
0
moe2210/BiotechGPT
BiotechGPT is a machine learning model from moe2210. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
import requests from telegram.ext import Updater, MessageHandler, Filters
Downloads · 30 days
0
Access
Public
Updated Oct 1, 2024
Repo size
—
Likes
0
Public
Click a slice to open those files.
Other1.5 KB · 64%
From the Hugging Face model README
import requests from telegram.ext import Updater, MessageHandler, Filters
hf_api_url = 'https://api-inference.huggingface.co/models/EleutherAI/gpt-j-6B' hf_api_key = 'your_huggingface_api_key' telegram_token = 'your_telegram_bot_token'
headers = {"Authorization": f"Bearer {hf_api_key}"}
def hf_response(update, context): user_message = update.message.text payload = {"inputs": user_message} response = requests.post(hf_api_url, headers=headers, json=payload) generated_text = response.json()[0]["generated_text"] update.message.reply_text(generated_text)
def main(): updater = Updater(telegram_token, use_context=True) dp = updater.dispatcher dp.add_handler(MessageHandler(Filters.text, hf_response)) updater.start_polling() updater.idle()
if name == 'main': main()