NickNYU commited on
Commit
fd51403
·
1 Parent(s): 13f45af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -18
app.py CHANGED
@@ -29,27 +29,14 @@ with st.sidebar:
29
 
30
  def main() -> None:
31
  st.header("X-Pipe Wiki 机器人 💬")
32
- # robot_manager = XPipeRobotManagerFactory.get_or_create(XPipeRobotRevision.SIMPLE_OPENAI_VERSION_0)
33
- # robot = robot_manager.get_robot()
34
- from llama_index import StorageContext
35
- store = StorageContext.from_defaults(persist_dir="./dataset")
36
- from langchain_manager.manager import LangChainAzureManager
37
- lc_manager = LangChainAzureManager()
38
- from llama_index import ServiceContext
39
- from llama_index import LangchainEmbedding
40
- service = ServiceContext.from_defaults(llm=lc_manager.get_llm(), embed_model=LangchainEmbedding(lc_manager.get_embedding()))
41
-
42
- from llama_index import load_index_from_storage
43
- index = load_index_from_storage(
44
- service_context=service,
45
- storage_context=store,
46
  )
47
- query_engine = index.as_query_engine(service_context=service)
48
- # robot = AzureOpenAIXPipeWikiRobot(query_engine)
49
  query = st.text_input("X-Pipe Wiki 问题:")
50
  if query:
51
- # response = robot.ask(question=query)
52
- st.write(query_engine.query(query))
53
 
54
 
55
  if __name__ == "__main__":
 
29
 
30
  def main() -> None:
31
  st.header("X-Pipe Wiki 机器人 💬")
32
+ robot_manager = XPipeRobotManagerFactory.get_or_create(
33
+ XPipeRobotRevision.SIMPLE_OPENAI_VERSION_0
 
 
 
 
 
 
 
 
 
 
 
 
34
  )
35
+ robot = robot_manager.get_robot()
 
36
  query = st.text_input("X-Pipe Wiki 问题:")
37
  if query:
38
+ response = robot.ask(question=query)
39
+ st.write(response)
40
 
41
 
42
  if __name__ == "__main__":