RT-AI / app.py
RAAZIM's picture
Update app.py
0abb9f6 verified
# Install the Hugging Face CLI
powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"
# (optional) Login with your Hugging Face credentials
hf auth login
# Push your model files
hf upload RAAZIM/RT-AI .
import gradio as gr
from transformers import pipeline
# 1. Load the GPT-Neo model (free to use)
generator = pipeline("text-generation", model="EleutherAI/gpt-neo-1.3B")
# 2. Create multi-turn chat memory
history = []
def chat(input_text):
global history
# Add user input to history
history.append(f"User: {input_text}")
# Prepare prompt with conversation history
prompt = "\n".join(history) + "\nAI:"
# Generate response
response = generator(prompt, max_length=200, do_sample=True, temperature=0.7)
ai_text = response[0]["generated_text"]
# Add AI response to history
history.append(f"AI: {ai_text}")
return ai_text
# 3. Gradio interface
iface = gr.Interface(
fn=chat,
inputs=gr.Textbox(lines=2, placeholder="Type your message here..."),
outputs="text",
title="AltisBot", # <-- Your chatbot name here
description="Your free AI assistant chatbot"
)
# 4. Launch the interface
iface.launch()
unknown model type (must be text-to-speech or automatic-speech-recognition)