Skip to content

Commit

Permalink
Merge pull request #63 from gomate-community/pipeline
Browse files Browse the repository at this point in the history
Pipeline
  • Loading branch information
yanqiangmiffy authored Sep 19, 2024
2 parents 65bbf6f + 6a7edfc commit 650fc8e
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 393 deletions.
20 changes: 10 additions & 10 deletions examples/rag/app_weibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# 修改成自己的配置!!!
app_config = ApplicationConfig()
app_config.llm_model_path = "H:/pretrained_models/llm/glm-4-9b-chat"
app_config.docs_path = 'H:/Projects/GoMate/data/docs/weibo'
app_config.docs_path = 'H:/Projects/Weibo Insight/data/docs/weibo'
retriever_config = DenseRetrieverConfig(
model_name_or_path="H:/pretrained_models/mteb/bge-large-zh-v1.5",
dim=1024,
Expand Down Expand Up @@ -119,7 +119,7 @@ def predict(input,


with gr.Blocks(theme="soft") as demo:
gr.Markdown("""<h1><center>交互式微博舆情问答系统</center></h1>
gr.Markdown("""<h1><center>交互式微博舆情问答助手</center></h1>
<center><font size=3>
</center></font>
""")
Expand All @@ -137,10 +137,10 @@ def predict(input,

large_language_model = gr.Dropdown(
[
"ChatGLM3-6B",
"ChatGLM3-9B",
],
label="large language model",
value="ChatGLM3-6B")
value="ChatGLM3-9B")

top_k = gr.Slider(1,
20,
Expand All @@ -162,7 +162,7 @@ def predict(input,
value='知识库问答',
interactive=False)

kg_name = gr.Radio(["文档知识库"],
kg_name = gr.Radio(["微博知识库"],
label="知识库",
value=None,
info="使用知识库问答,请加载知识库",
Expand All @@ -181,16 +181,16 @@ def predict(input,
# )
with gr.Column(scale=4):
with gr.Row():
chatbot = gr.Chatbot(label='Gomate Application').style(height=650)
chatbot = gr.Chatbot(label='Weibo Insight Application',height=650)
with gr.Row():
message = gr.Textbox(label='请输入问题')
with gr.Row():
clear_history = gr.Button("🧹 清除历史对话")
send = gr.Button("🚀 发送")
with gr.Row():
gr.Markdown("""提醒:<br>
[Gomate Application](https://github.com/gomate-community/GoMate) <br>
有任何使用问题[Github Issue区](https://github.com/gomate-community/GoMate)进行反馈.
[Weibo Insight](https://github.com/Weibo-Insight/WeiboInsight) <br>
有任何使用问题[Github Issue区](https://github.com/Weibo-Insight/WeiboInsight)进行反馈.
<br>
""")
with gr.Column(scale=2):
Expand Down Expand Up @@ -238,12 +238,12 @@ def predict(input,
],
outputs=[message, chatbot, state, search])

demo.queue(concurrency_count=2).launch(
demo.queue().launch(
server_name='0.0.0.0',
server_port=7860,
share=True,
show_error=True,
debug=True,
enable_queue=True,
# enable_queue=True,
inbrowser=False,
)
42 changes: 21 additions & 21 deletions gomate/applications/rag_weibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,24 @@ def chat(self, question: str = '', top_k: int = 20):
return result, history, contents


if __name__ == '__main__':
# 修改成自己的配置!!!
app_config = ApplicationConfig()
app_config.llm_model_path = "H:/pretrained_models/llm/glm-4-9b-chat"

retriever_config = DenseRetrieverConfig(
model_name_or_path="H:/pretrained_models/mteb/bge-large-zh-v1.5",
dim=1024,
index_path=os.path.join(PROJECT_BASE, 'output/weibo_dense')
)
rerank_config = BgeRerankerConfig(
model_name_or_path="H:/pretrained_models/mteb/bge-reranker-large"
)

app_config.retriever_config = retriever_config
app_config.rerank_config = rerank_config
application = WeiboRagApplication(app_config)
# application.init_vector_store()
application.load_vector_store()
result, history, contents = application.chat("刘畅演员最近有什么活动")
print(result, history, contents)
# if __name__ == '__main__':
# # 修改成自己的配置!!!
# app_config = ApplicationConfig()
# app_config.llm_model_path = "H:/pretrained_models/llm/glm-4-9b-chat"
#
# retriever_config = DenseRetrieverConfig(
# model_name_or_path="H:/pretrained_models/mteb/bge-large-zh-v1.5",
# dim=1024,
# index_path=os.path.join(PROJECT_BASE, 'output/weibo_dense')
# )
# rerank_config = BgeRerankerConfig(
# model_name_or_path="H:/pretrained_models/mteb/bge-reranker-large"
# )
#
# app_config.retriever_config = retriever_config
# app_config.rerank_config = rerank_config
# application = WeiboRagApplication(app_config)
# # application.init_vector_store()
# application.load_vector_store()
# result, history, contents = application.chat("刘畅演员最近有什么活动")
# print(result, history, contents)
Loading

0 comments on commit 650fc8e

Please sign in to comment.