abhivsh commited on
Commit
c46aced
·
verified ·
1 Parent(s): 76bd4ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -48,38 +48,37 @@ llm_name = "gpt-3.5-turbo"
48
 
49
  vectordb = initialize.initialize()
50
 
51
- def chat_query(question):
52
 
53
  llm = ChatOpenAI(model=llm_name, temperature=0.1, api_key = OPENAI_API_KEY)
54
 
55
  # Conversation Retrival Chain with Memory
56
  memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
57
  retriever=vectordb.as_retriever()
58
- #qa = ConversationalRetrievalChain.from_llm(llm, retriever=retriever, memory=memory)
59
 
60
  # Replace input() with question variable for Gradio
61
- # result = qa({"question": question})
62
- # return result['answer']
63
 
64
  # Chatbot only answers based on Documents
65
- qa = VectorDBQA.from_chain_type(llm=OpenAI(openai_api_key = OPENAI_API_KEY, ), chain_type="stuff", vectorstore=vectordb)
66
- result = qa.run(question)
67
- return result
68
 
69
 
70
 
71
 
72
  # logo_path = os.path.join(os.getcwd(), "Logo.png")
73
 
74
- iface = gr.Interface(
75
  fn=chat_query,
76
- inputs= gr.Textbox(lines = 6, placeholder="Enter your Query here....",label="Query :"),
77
- outputs=gr.Textbox(label="Chatbot Reply : "),
78
  title = " -----: ChatBot :----- ",
79
  description="""-- Welcome to the Language Model trained on Model-TS (Engineering-SS).\n\n
80
  -- The Model tries to answer the Query based on Model-Technical Specifications. \n\n
81
  -- For precise reply, please input `Specific Keywords` in your Query. \n\n """,
82
  concurrency_limit = None,
 
83
 
84
  )
85
 
 
48
 
49
  vectordb = initialize.initialize()
50
 
51
+ def chat_query(question, history):
52
 
53
  llm = ChatOpenAI(model=llm_name, temperature=0.1, api_key = OPENAI_API_KEY)
54
 
55
  # Conversation Retrival Chain with Memory
56
  memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
57
  retriever=vectordb.as_retriever()
58
+ qa = ConversationalRetrievalChain.from_llm(llm, retriever=retriever, memory=memory)
59
 
60
  # Replace input() with question variable for Gradio
61
+ result = qa({"question": question})
62
+ return result['answer']
63
 
64
  # Chatbot only answers based on Documents
65
+ # qa = VectorDBQA.from_chain_type(llm=OpenAI(openai_api_key = OPENAI_API_KEY, ), chain_type="stuff", vectorstore=vectordb)
66
+ # result = qa.run(question)
67
+ # return result
68
 
69
 
70
 
71
 
72
  # logo_path = os.path.join(os.getcwd(), "Logo.png")
73
 
74
+ iface = gr.ChatInterface(
75
  fn=chat_query,
 
 
76
  title = " -----: ChatBot :----- ",
77
  description="""-- Welcome to the Language Model trained on Model-TS (Engineering-SS).\n\n
78
  -- The Model tries to answer the Query based on Model-Technical Specifications. \n\n
79
  -- For precise reply, please input `Specific Keywords` in your Query. \n\n """,
80
  concurrency_limit = None,
81
+ examples = {'What should be the GIB height outside the GIS hall ?'},
82
 
83
  )
84