Spaces:
Sleeping
Sleeping
rainbowemoji commited on
Commit ·
7821cec
1
Parent(s): 7c98610
fix: text_input usage
Browse files- .idea/etf-assistant.iml +7 -1
- .idea/workspace.xml +8 -6
- app.py +10 -9
- requirements.txt +0 -0
.idea/etf-assistant.iml
CHANGED
|
@@ -3,8 +3,14 @@
|
|
| 3 |
<component name="NewModuleRootManager">
|
| 4 |
<content url="file://$MODULE_DIR$">
|
| 5 |
<excludeFolder url="file://$MODULE_DIR$/.streamlit" />
|
|
|
|
| 6 |
</content>
|
| 7 |
-
<orderEntry type="
|
| 8 |
<orderEntry type="sourceFolder" forTests="false" />
|
| 9 |
</component>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
</module>
|
|
|
|
| 3 |
<component name="NewModuleRootManager">
|
| 4 |
<content url="file://$MODULE_DIR$">
|
| 5 |
<excludeFolder url="file://$MODULE_DIR$/.streamlit" />
|
| 6 |
+
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
| 7 |
</content>
|
| 8 |
+
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
|
| 9 |
<orderEntry type="sourceFolder" forTests="false" />
|
| 10 |
</component>
|
| 11 |
+
<component name="PackageRequirementsSettings">
|
| 12 |
+
<option name="requirementsPath" value="D:\2_Study\1_AI\lc\New folder\etf-assistant\requirements.txt" />
|
| 13 |
+
<option name="versionSpecifier" value="Strong equality (==x.y.z)" />
|
| 14 |
+
<option name="modifyBaseFiles" value="true" />
|
| 15 |
+
</component>
|
| 16 |
</module>
|
.idea/workspace.xml
CHANGED
|
@@ -5,8 +5,9 @@
|
|
| 5 |
</component>
|
| 6 |
<component name="ChangeListManager">
|
| 7 |
<list default="true" id="48e09a2c-c8fe-48db-8b61-cb395ec0aa52" name="Changes" comment="">
|
| 8 |
-
<change beforePath="$PROJECT_DIR$/.
|
| 9 |
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
|
|
| 10 |
<change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
|
| 11 |
</list>
|
| 12 |
<option name="SHOW_DIALOG" value="false" />
|
|
@@ -32,12 +33,13 @@
|
|
| 32 |
<option name="hideEmptyMiddlePackages" value="true" />
|
| 33 |
<option name="showLibraryContents" value="true" />
|
| 34 |
</component>
|
| 35 |
-
<component name="PropertiesComponent">{
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
| 39 |
}
|
| 40 |
-
}</component>
|
| 41 |
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
| 42 |
<component name="TaskManager">
|
| 43 |
<task active="true" id="Default" summary="Default task">
|
|
|
|
| 5 |
</component>
|
| 6 |
<component name="ChangeListManager">
|
| 7 |
<list default="true" id="48e09a2c-c8fe-48db-8b61-cb395ec0aa52" name="Changes" comment="">
|
| 8 |
+
<change beforePath="$PROJECT_DIR$/.idea/etf-assistant.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/etf-assistant.iml" afterDir="false" />
|
| 9 |
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
| 10 |
+
<change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
|
| 11 |
<change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
|
| 12 |
</list>
|
| 13 |
<option name="SHOW_DIALOG" value="false" />
|
|
|
|
| 33 |
<option name="hideEmptyMiddlePackages" value="true" />
|
| 34 |
<option name="showLibraryContents" value="true" />
|
| 35 |
</component>
|
| 36 |
+
<component name="PropertiesComponent"><![CDATA[{
|
| 37 |
+
"keyToString": {
|
| 38 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
| 39 |
+
"git-widget-placeholder": "main",
|
| 40 |
+
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
|
| 41 |
}
|
| 42 |
+
}]]></component>
|
| 43 |
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
| 44 |
<component name="TaskManager">
|
| 45 |
<task active="true" id="Default" summary="Default task">
|
app.py
CHANGED
|
@@ -35,8 +35,8 @@ def _initialize_indexes():
|
|
| 35 |
return db
|
| 36 |
|
| 37 |
|
| 38 |
-
def _initialize_retriever(
|
| 39 |
-
retriever =
|
| 40 |
qa = ConversationalRetrievalChain.from_llm(
|
| 41 |
ChatOpenAI(temperature=0),
|
| 42 |
retriever
|
|
@@ -46,13 +46,17 @@ def _initialize_retriever(db):
|
|
| 46 |
|
| 47 |
chat_history = []
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
global chat_history
|
| 51 |
result = qa({
|
| 52 |
-
"question":
|
| 53 |
"chat_history": chat_history
|
| 54 |
})
|
| 55 |
-
chat_history = chat_history.append((
|
| 56 |
chat_history = chat_history[-10:]
|
| 57 |
st.write(
|
| 58 |
"Bot: ",
|
|
@@ -65,7 +69,4 @@ db = _initialize_indexes()
|
|
| 65 |
qa = _initialize_retriever(db)
|
| 66 |
|
| 67 |
question = st.text_input('Question')
|
| 68 |
-
|
| 69 |
-
'Answer',
|
| 70 |
-
on_click=lambda: answer(question)
|
| 71 |
-
)
|
|
|
|
| 35 |
return db
|
| 36 |
|
| 37 |
|
| 38 |
+
def _initialize_retriever(db_object):
|
| 39 |
+
retriever = db_object.as_retriever(search_type="similarity", search_kwargs={"k": 2})
|
| 40 |
qa = ConversationalRetrievalChain.from_llm(
|
| 41 |
ChatOpenAI(temperature=0),
|
| 42 |
retriever
|
|
|
|
| 46 |
|
| 47 |
chat_history = []
|
| 48 |
|
| 49 |
+
|
| 50 |
+
def answer(user_input):
|
| 51 |
+
if user_input == '':
|
| 52 |
+
return
|
| 53 |
+
print("----------", user_input)
|
| 54 |
global chat_history
|
| 55 |
result = qa({
|
| 56 |
+
"question": user_input,
|
| 57 |
"chat_history": chat_history
|
| 58 |
})
|
| 59 |
+
chat_history = chat_history.append((user_input, result["answer"]))
|
| 60 |
chat_history = chat_history[-10:]
|
| 61 |
st.write(
|
| 62 |
"Bot: ",
|
|
|
|
| 69 |
qa = _initialize_retriever(db)
|
| 70 |
|
| 71 |
question = st.text_input('Question')
|
| 72 |
+
answer(question)
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
Binary files a/requirements.txt and b/requirements.txt differ
|
|
|