kookoobau commited on
Commit
e777dab
1 Parent(s): 38d339d
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -1,17 +1,11 @@
1
  import gradio as gr
2
- from langchain.llms.huggingface_hub import HuggingFaceHub
3
  from transformers import AutoTokenizer
4
 
5
- # Define the Hugging Face model and tokenizer
6
  model_name = "microsoft/DialoGPT-medium"
7
  tokenizer = AutoTokenizer.from_pretrained(model_name)
8
-
9
- # Define the LangChain chat agent
10
- agent = HuggingFaceHub(
11
- model_name=model_name,
12
- task="text2text-generation",
13
- tokenizer=tokenizer,
14
- )
15
 
16
  # Define the Gradio interface
17
  def chatbot_interface(input_text):
@@ -23,8 +17,8 @@ gradio_app = gr.Interface(
23
  fn=chatbot_interface,
24
  inputs=gr.inputs.Textbox(prompt="Say something..."),
25
  outputs=gr.outputs.Textbox(),
26
- title="LangChain Chatbot",
27
- description="A chatbot interface powered by LangChain and Hugging Face.",
28
  )
29
 
30
  # Run the Gradio app
 
1
  import gradio as gr
2
+ from langchain.chains.conversation import ConversationChain
3
  from transformers import AutoTokenizer
4
 
5
+ # Define the LangChain chat agent
6
  model_name = "microsoft/DialoGPT-medium"
7
  tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+ agent = ConversationChain(llm=model_name, tokenizer=tokenizer)
 
 
 
 
 
 
9
 
10
  # Define the Gradio interface
11
  def chatbot_interface(input_text):
 
17
  fn=chatbot_interface,
18
  inputs=gr.inputs.Textbox(prompt="Say something..."),
19
  outputs=gr.outputs.Textbox(),
20
+ title="ConversationChain Chatbot",
21
+ description="A chatbot interface powered by ConversationChain and Hugging Face.",
22
  )
23
 
24
  # Run the Gradio app