julianubc commited on
Commit
21bcd44
·
1 Parent(s): 05ee5fd
.gitignore ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ !.env.example
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ #.idea/
Dockerfile CHANGED
@@ -1,21 +1,28 @@
1
- FROM python:3.9-slim
 
2
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- software-properties-common \
9
- git \
10
- && rm -rf /var/lib/apt/lists/*
11
 
12
- COPY requirements.txt ./
13
- COPY src/ ./src/
 
 
 
14
 
15
- RUN pip3 install -r requirements.txt
 
16
 
 
17
  EXPOSE 8501
18
 
19
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
 
20
 
21
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
1
+ # 使用Python 3.10精简版作为基础镜像
2
+ FROM python:3.10-slim
3
 
4
+ # 设置工作目录
5
  WORKDIR /app
6
 
7
+ # 设置环境变量
8
+ ENV PYTHONUNBUFFERED=1 \
9
+ PYTHONDONTWRITEBYTECODE=1
 
 
 
10
 
11
+ # 复制依赖文件
12
+ COPY requirements.txt .
13
+
14
+ # 安装依赖
15
+ RUN pip install --no-cache-dir -r requirements.txt
16
 
17
+ # 复制源代码
18
+ COPY src/ ./src/
19
 
20
+ # 暴露Streamlit端口
21
  EXPOSE 8501
22
 
23
+ # 设置健康检查
24
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
25
+ CMD curl -f http://localhost:8501/_stcore/health || exit 1
26
 
27
+ # 启动命令
28
+ CMD ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
docker-compose.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ app:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile
8
+ ports:
9
+ - "8501:8501"
10
+ environment:
11
+ - GEMINI_API_KEY=${GEMINI_API_KEY}
12
+ volumes:
13
+ - ./src:/app/src # 开发环境下挂载源代码目录,方便实时修改
14
+ restart: unless-stopped
15
+ healthcheck:
16
+ test: ["CMD", "curl", "-f", "http://localhost:8501/_stcore/health"]
17
+ interval: 30s
18
+ timeout: 30s
19
+ retries: 3
20
+ start_period: 5s
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
1
+ streamlit
2
+ google-generativeai
3
+ python-dotenv
4
+ langchain
5
+ langchain-google-genai
src/{streamlit_app.py → app.py} RENAMED
@@ -10,16 +10,17 @@ st.set_page_config(page_title="Gemini Stream Chat")
10
  st.markdown("## 🚀 AI replica for [Takeoff](https://readyfortakeoff.app/)")
11
  st.caption("Powered directly by `google.generativeai`")
12
 
 
 
 
 
 
 
 
 
 
13
  SYSTEM_PROMPT = """
14
- You are an AI chatbot built for Takeoff (https://readyfortakeoff.app), a portfolio-building platform designed for individuals and jobseekers.
15
-
16
- Your role is to act as a helpful AI replica embedded in a user's portfolio. You can answer questions from recruiters and visitors about the user's work experience, projects, and skills. You should highlight relevant examples and provide helpful, professional, and concise responses.
17
-
18
- You can reference data such as the user's resume, portfolio content, project notes, and achievements. Where appropriate, link to projects or suggest relevant content the user has created.
19
-
20
- Your goal is to make it easy for others to understand the user's background and professional strengths.
21
  """
22
-
23
  if "chat_history" not in st.session_state:
24
  st.session_state.chat_history = []
25
 
 
10
  st.markdown("## 🚀 AI replica for [Takeoff](https://readyfortakeoff.app/)")
11
  st.caption("Powered directly by `google.generativeai`")
12
 
13
+ #SYSTEM_PROMPT = """
14
+ #You are an AI chatbot built for Takeoff (https://readyfortakeoff.app), a portfolio-building platform designed for individuals and jobseekers.
15
+ #
16
+ #Your role is to act as a helpful AI replica embedded in a user's portfolio. You can answer questions from recruiters and visitors about the user's work experience, projects, and skills. You should highlight relevant examples and provide helpful, professional, and concise responses.
17
+ #
18
+ #You can reference data such as the user's resume, portfolio content, project notes, and achievements. Where appropriate, link to projects or suggest relevant content the user has created.
19
+ #
20
+ #Your goal is to make it easy for others to understand the user's background and professional strengths.
21
+ #"""
22
  SYSTEM_PROMPT = """
 
 
 
 
 
 
 
23
  """
 
24
  if "chat_history" not in st.session_state:
25
  st.session_state.chat_history = []
26