jfeng1115 commited on
Commit
167f934
β€’
1 Parent(s): 72a5f6e

prepare chainlit

Browse files
Files changed (5) hide show
  1. .idea/.gitignore +0 -8
  2. .idea/vcs.xml +1 -1
  3. .idea/workspace.xml +53 -0
  4. Dockerfile +11 -0
  5. main.py β†’ app.py +3 -3
.idea/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Editor-based HTTP Client requests
5
- /httpRequests/
6
- # Datasource local storage ignored files
7
- /dataSources/
8
- /dataSources.local.xml
 
 
 
 
 
 
 
 
 
.idea/vcs.xml CHANGED
@@ -1,6 +1,6 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <project version="4">
3
  <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
  </component>
6
  </project>
 
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <project version="4">
3
  <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
  </component>
6
  </project>
.idea/workspace.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="7ba7bcf7-b91a-42f5-86ac-54dca93c4bf7" name="Changes" comment="">
8
+ <change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
11
+ </list>
12
+ <option name="SHOW_DIALOG" value="false" />
13
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
14
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
15
+ <option name="LAST_RESOLUTION" value="IGNORE" />
16
+ </component>
17
+ <component name="Git.Settings">
18
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
19
+ </component>
20
+ <component name="ProjectId" id="2WBBK5tjkR64UAw9UXjwDSQUFPk" />
21
+ <component name="ProjectViewState">
22
+ <option name="hideEmptyMiddlePackages" value="true" />
23
+ <option name="showLibraryContents" value="true" />
24
+ </component>
25
+ <component name="PropertiesComponent"><![CDATA[{
26
+ "keyToString": {
27
+ "RunOnceActivity.ShowReadmeOnStart": "true",
28
+ "WebServerToolWindowFactoryState": "false",
29
+ "git-widget-placeholder": "main",
30
+ "node.js.detected.package.eslint": "true",
31
+ "node.js.detected.package.tslint": "true",
32
+ "node.js.selected.package.eslint": "(autodetect)",
33
+ "node.js.selected.package.tslint": "(autodetect)",
34
+ "nodejs_package_manager_path": "npm",
35
+ "vue.rearranger.settings.migration": "true"
36
+ }
37
+ }]]></component>
38
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
39
+ <component name="TaskManager">
40
+ <task active="true" id="Default" summary="Default task">
41
+ <changelist id="7ba7bcf7-b91a-42f5-86ac-54dca93c4bf7" name="Changes" comment="" />
42
+ <created>1696196025530</created>
43
+ <option name="number" value="Default" />
44
+ <option name="presentableId" value="Default" />
45
+ <updated>1696196025530</updated>
46
+ <workItem from="1696196027593" duration="392000" />
47
+ </task>
48
+ <servers />
49
+ </component>
50
+ <component name="TypeScriptGeneratedFilesManager">
51
+ <option name="version" value="3" />
52
+ </component>
53
+ </project>
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+ RUN useradd -m -u 1000 user
3
+ USER user
4
+ ENV HOME=/home/user \
5
+ PATH=/home/user/.local/bin:$PATH
6
+ WORKDIR $HOME/app
7
+ COPY --chown=user .. $HOME/app
8
+ COPY ./requirements.txt ~/app/requirements.txt
9
+ RUN pip install -r requirements.txt
10
+ COPY .. .
11
+ CMD ["chainlit", "run", "app.py", "--port", "7860"]
main.py β†’ app.py RENAMED
@@ -58,7 +58,7 @@ qa_with_sources_chain = RetrievalQA.from_chain_type(
58
  return_source_documents=True
59
  )
60
 
61
- result = qa_with_sources_chain({"query" : "Was Will Ferrel funny?"})
62
 
63
  @cl.on_chat_start # marks a function that will be executed at the start of a user session
64
  def start_chat():
@@ -80,10 +80,10 @@ def start_chat():
80
  async def main(message: str):
81
  message_history = cl.user_session.get("message_history")
82
 
83
- qaPipeline = RetrievalAugmentedQAPipeline(vector_db_retriever=vector_db, llm=ChatOpenAI(model_name=model_name))
84
  msg = cl.Message(content="")
 
85
 
86
- await qaPipeline.stream_pipeline(user_query=message, message_history=message_history, msg=msg)
87
  await msg.send()
88
 
89
 
 
58
  return_source_documents=True
59
  )
60
 
61
+
62
 
63
  @cl.on_chat_start # marks a function that will be executed at the start of a user session
64
  def start_chat():
 
80
  async def main(message: str):
81
  message_history = cl.user_session.get("message_history")
82
 
83
+ result = qa_with_sources_chain({"query" : message})
84
  msg = cl.Message(content="")
85
+ msg.content = result["result"]
86
 
 
87
  await msg.send()
88
 
89