diff --git a/README.md b/README.md index 71c30dc61..370b035c5 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ uvicorn vicuna_server:app --host 0.0.0.0 ``` 2. Run gradio webui +``` +python app.py +``` # Featurs - SQL-Generate diff --git a/pilot/app.py b/pilot/app.py index f5fcb3ad1..6a7a76f3d 100644 --- a/pilot/app.py +++ b/pilot/app.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding:utf-8 -*- -import streamlit as st +import gradio as gr from langchain.agents import ( load_tools, initialize_agent, @@ -22,7 +22,7 @@ def agent_demo(): ) def knowledged_qa_demo(text_list): - llm_predictor = LLMPredictor(llm=VicunaRequestLLM) + llm_predictor = LLMPredictor(llm=VicunaRequestLLM()) hfemb = VicunaEmbeddingLLM() embed_model = LangchainEmbedding(hfemb) documents = [Document(t) for t in text_list] @@ -32,17 +32,24 @@ def knowledged_qa_demo(text_list): return index +def get_answer(q): + base_knowledge = """ 这是一段测试文字 """ + text_list = [base_knowledge] + index = knowledged_qa_demo(text_list) + response = index.query(q) + return response.response + if __name__ == "__main__": # agent_demo() - test1 = """ 这是一段测试文字 """ - text_list = [test1] - index = knowledged_qa_demo(text_list) + with gr.Blocks() as demo: + gr.Markdown("数据库智能助手") + with gr.Tab("知识问答"): + text_input = gr.TextArea() + text_output = gr.TextArea() + text_button = gr.Button() + + text_button.click(get_answer, inputs=text_input, outputs=text_output) - st.title("智能助手") - query = st.text_input("请提问.") - - if st.button("提交"): - response = index.query(query) - print(query, response.response) - st.write(response.response) \ No newline at end of file + demo.queue(concurrency_count=3).launch(server_name="0.0.0.0") + diff --git a/pilot/configs/model_config.py b/pilot/configs/model_config.py index 596e483d8..2b9ae6df0 100644 --- a/pilot/configs/model_config.py +++ b/pilot/configs/model_config.py @@ -18,7 +18,7 @@ llm_model_config = { LLM_MODEL = "vicuna-13b" -vicuna_model_server = "http://127.0.0.1:8000/" +vicuna_model_server = "http://192.168.31.114:8000/" # Load model config