detached
Frieren 6 months ago
parent 032994f8c2
commit 467844f5d9

@ -1 +1,2 @@
API_KEY=86df1c93a84174062eaf6a38e331efc1.AJV5y2jkKASbZ3YD
API_KEY=
FILE_PATH=

@ -5,8 +5,11 @@
</component>
<component name="ChangeListManager">
<list default="true" id="db7f4434-7cc2-4790-b42e-92159334a8b4" name="Changes" comment="complete RAG, History RAG">
<change beforePath="$PROJECT_DIR$/.config/config.properties" beforeDir="false" afterPath="$PROJECT_DIR$/.config/config.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/serve/HistoryRAG.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/serve/HistoryRAG.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/serve/RAG.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/serve/RAG.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -23,7 +26,7 @@
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="master" />
<entry key="$PROJECT_DIR$" value="detached" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -57,25 +60,25 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Python.HistoryRAG.executor&quot;: &quot;Run&quot;,
&quot;Python.RAG.executor&quot;: &quot;Run&quot;,
&quot;Python.embedding.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;com.google.cloudcode.ide_session_index&quot;: &quot;20240519_0002&quot;,
&quot;git-widget-placeholder&quot;: &quot;detached&quot;,
&quot;last_opened_file_path&quot;: &quot;G:/code/py/LLM&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Python.HistoryRAG.executor": "Run",
"Python.RAG.executor": "Run",
"Python.embedding.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"com.google.cloudcode.ide_session_index": "20240528_0001",
"git-widget-placeholder": "032994f8",
"last_opened_file_path": "G:/code/py/LLM",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
"vue.rearranger.settings.migration": "true"
}
}</component>
}]]></component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="G:\code\py\LLM\src\base" />
@ -114,6 +117,9 @@
<workItem from="1716101749458" duration="1744000" />
<workItem from="1716103616899" duration="1362000" />
<workItem from="1716718682372" duration="7000" />
<workItem from="1716789003601" duration="30000" />
<workItem from="1716896259454" duration="607000" />
<workItem from="1716896875841" duration="3460000" />
</task>
<task id="LOCAL-00001" summary="init">
<option name="closed" value="true" />
@ -155,7 +161,15 @@
<option name="project" value="LOCAL" />
<updated>1715966892912</updated>
</task>
<option name="localTasksCounter" value="6" />
<task id="LOCAL-00006" summary="complete RAG, History RAG">
<option name="closed" value="true" />
<created>1716789017012</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1716789017012</updated>
</task>
<option name="localTasksCounter" value="7" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -191,8 +205,8 @@
<option name="LAST_COMMIT_MESSAGE" value="complete RAG, History RAG" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/LLM$RAG.coverage" NAME="RAG Coverage Results" MODIFIED="1715966784292" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src/serve" />
<SUITE FILE_PATH="coverage/LLM$RAG.coverage" NAME="RAG Coverage Results" MODIFIED="1716897848448" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src/serve" />
<SUITE FILE_PATH="coverage/LLM$embedding.coverage" NAME="embedding Coverage Results" MODIFIED="1715952325378" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src/serve" />
<SUITE FILE_PATH="coverage/LLM$HistoryRAG.coverage" NAME="HistoryRAG Coverage Results" MODIFIED="1716104864368" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src/serve" />
<SUITE FILE_PATH="coverage/LLM$HistoryRAG.coverage" NAME="HistoryRAG Coverage Results" MODIFIED="1716901838902" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src/serve" />
</component>
</project>

@ -2,6 +2,6 @@ langchain>=0.1.20
pypdf>=4.2.0
zhipuai~=2.0.1.20240423.1
langchainhub~=0.1.15
chromadb
httpx-sse~=0.4.0
chardet~=5.2.0
chardet~=5.2.0
gradio

@ -5,6 +5,8 @@ from langchain_core.messages import HumanMessage
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from src.serve.RAG import RAG
from src.init.property import Property
import gradio as gr
__contextualize_q_system_prompt = """Given a chat history and the latest user question \
which might reference context in the chat history, formulate a standalone question \
@ -60,18 +62,53 @@ class HistoryRAG(RAG):
if __name__ == '__main__':
print("welcome to use RAG question, input exit() to end")
try:
file_path = input("please input file path:").strip('"')
if not len(file_path):
raise ValueError("path not be empty")
except ValueError:
print("arise error" + repr(ValueError))
finally:
hr = HistoryRAG(file_path)
while True:
chat = input("user:")
if chat == "exit()":
break
print("system:" + hr.get_chat(chat))
file_path = Property.get_property("FILE_PATH")
hr = HistoryRAG(file_path)
iface = gr.Interface(fn=hr.get_chat, inputs="text", outputs="text", title="Chatbot",
description="从自定义文档中提问并获取答案")
gr.HTML("""<h1 align="center">ChatGLM4</h1>""")
iface.launch()
# print("welcome to use RAG question, input exit() to end")
# try:
# file_path = input("please input file path:").strip('"')
# if not len(file_path):
# raise ValueError("path not be empty")
# except ValueError:
# print("arise error" + repr(ValueError))
# finally:
# hr = HistoryRAG(file_path)
# while True:
# chat = input("user:")
# if chat == "exit()":
# break
# print("system:" + hr.get_chat(chat))
#
#
# with gr.Blocks() as demo:
# gr.HTML("""<h1 align="center">ChatGLM4</h1>""")
# chatbot = gr.Chatbot()
#
# with gr.Row():
# with gr.Column(scale=4):
# with gr.Column(scale=12):
# user_input = gr.Textbox(show_label=False, placeholder="Input...", lines=10, container=False)
# with gr.Column(min_width=32, scale=1):
# submitBtn = gr.Button("Submit")
# with gr.Column(scale=1):
# emptyBtn = gr.Button("Clear History")
# max_length = gr.Slider(0, 32768, value=8192, step=1.0, label="Maximum length", interactive=True)
# top_p = gr.Slider(0, 1, value=0.8, step=0.01, label="Top P", interactive=True)
# temperature = gr.Slider(0.01, 1, value=0.6, step=0.01, label="Temperature", interactive=True)
#
#
# def user(query, history):
# return "", history + [[parse_text(query), ""]]
#
#
# submitBtn.click(user, [user_input, chatbot], [user_input, chatbot], queue=False).then(
# [chatbot, max_length, top_p, temperature], chatbot
# )
# emptyBtn.click(lambda: None, None, chatbot, queue=False)
#
# demo.queue()
# demo.launch(server_name="127.0.0.1", server_port=7870, inbrowser=True, share=False)

@ -81,3 +81,4 @@ if __name__ == '__main__':
r = RAG("C:\\Users\\16922\\Desktop\\文档1.pdf")
r.select_prompt(2)
r.get_chat("what can Multimodal Agent AI systems do?")

Loading…
Cancel
Save