Spaces:
Sleeping
Sleeping
File size: 828 Bytes
421003d 9af1238 1d8154e 07d3b7a afe42be f092898 07d3b7a 9af1238 f092898 e777dab f092898 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from langchain.chains import ConversationChain
from transformers import AutoTokenizer, AutoModelForCausalLM
import gradio as gr
from myLLM import AutoModelLanguageModel
model_name = "microsoft/DialoGPT-medium"
tokenizer = AutoTokenizer.from_pretrained(model_name)
llm = AutoModelLanguageModel(model_name)
agent = ConversationChain(llm=llm)
# Define the Gradio interface
def chatbot_interface(input_text):
response = agent(input_text)
return response
# Define the Gradio app
gradio_app = gr.Interface(
fn=chatbot_interface,
inputs=gr.inputs.Textbox(prompt="Say something..."),
outputs=gr.outputs.Textbox(),
title="ConversationChain Chatbot",
description="A chatbot interface powered by ConversationChain and Hugging Face.",
)
# Run the Gradio app
if __name__ == "__main__":
gradio_app.run()
|