Spaces:
Runtime error
Runtime error
Rohan Kataria
commited on
Commit
β’
e4aa027
1
Parent(s):
46f398d
new changes
Browse files- .history/Dockerfile_20240311235819 +23 -0
- .history/Dockerfile_20240312000834 +18 -0
- Dockerfile +8 -13
- app.py +20 -19
.history/Dockerfile_20240311235819
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10-slim
|
2 |
+
|
3 |
+
RUN apt-get update && apt-get install -y \
|
4 |
+
build-essential \
|
5 |
+
curl \
|
6 |
+
software-properties-common \
|
7 |
+
git \
|
8 |
+
&& rm -rf /var/lib/apt/lists/*
|
9 |
+
|
10 |
+
# This sets the /app directory as the working directory for any RUN, CMD, ENTRYPOINT, or COPY instructions that follow.
|
11 |
+
WORKDIR /app
|
12 |
+
|
13 |
+
# This copies everything in your current directory to the /app directory in the container.
|
14 |
+
COPY . /app
|
15 |
+
|
16 |
+
# This runs pip install for all the packages listed in your requirements.txt file.
|
17 |
+
RUN pip install --upgrade pip
|
18 |
+
RUN pip install -r requirements.txt
|
19 |
+
|
20 |
+
#EXPOSE 8501
|
21 |
+
#I commented out EXPOSE 8501, and gave 7860 in CMD, since it works. Funny? The building of Streamlit never stops with 8501!!!
|
22 |
+
|
23 |
+
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
.history/Dockerfile_20240312000834
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10-slim
|
2 |
+
|
3 |
+
RUN apt-get update && apt-get install -y build-essential curl git && rm -rf /var/lib/apt/lists/*
|
4 |
+
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Create non-root user and switch to it
|
8 |
+
RUN useradd -m -u 1000 user && chown -R user:user /app
|
9 |
+
USER user
|
10 |
+
|
11 |
+
# Copy application files and install dependencies
|
12 |
+
COPY --chown=user:user . /app
|
13 |
+
RUN pip install --upgrade pip && pip install --user -r requirements.txt
|
14 |
+
|
15 |
+
#EXPOSE 8501
|
16 |
+
#I commented out EXPOSE 8501, and gave 7860 in CMD, since it works. Funny? The building of Streamlit never stops with 8501!!!
|
17 |
+
|
18 |
+
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
Dockerfile
CHANGED
@@ -1,23 +1,18 @@
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
-
RUN apt-get update && apt-get install -y
|
4 |
-
build-essential \
|
5 |
-
curl \
|
6 |
-
software-properties-common \
|
7 |
-
git \
|
8 |
-
&& rm -rf /var/lib/apt/lists/*
|
9 |
|
10 |
-
# This sets the /app directory as the working directory for any RUN, CMD, ENTRYPOINT, or COPY instructions that follow.
|
11 |
WORKDIR /app
|
12 |
|
13 |
-
#
|
14 |
-
|
|
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
-
RUN pip install -r requirements.txt
|
19 |
|
20 |
#EXPOSE 8501
|
21 |
#I commented out EXPOSE 8501, and gave 7860 in CMD, since it works. Funny? The building of Streamlit never stops with 8501!!!
|
22 |
|
23 |
-
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
+
RUN apt-get update && apt-get install -y build-essential curl git && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
|
4 |
|
|
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Create non-root user and switch to it
|
8 |
+
RUN useradd -m -u 1000 user && chown -R user:user /app
|
9 |
+
USER user
|
10 |
|
11 |
+
# Copy application files and install dependencies
|
12 |
+
COPY --chown=user:user . /app
|
13 |
+
RUN pip install --upgrade pip && pip install --user -r requirements.txt
|
14 |
|
15 |
#EXPOSE 8501
|
16 |
#I commented out EXPOSE 8501, and gave 7860 in CMD, since it works. Funny? The building of Streamlit never stops with 8501!!!
|
17 |
|
18 |
+
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
app.py
CHANGED
@@ -5,12 +5,12 @@ import os
|
|
5 |
# Constants
|
6 |
ROLE_USER = "user"
|
7 |
ROLE_ASSISTANT = "assistant"
|
8 |
-
MAX_MESSAGES = 5
|
9 |
|
10 |
-
st.set_page_config(page_title="Chat with Git", page_icon="π¦")
|
11 |
st.title("Chat with Git π€π")
|
12 |
st.markdown("by [Rohan Kataria](https://www.linkedin.com/in/imrohan/) view more at [VEW.AI](https://vew.ai/)")
|
13 |
-
st.markdown("This app allows you to chat with Git code files. You can paste link to the Git repository and ask questions about it. In the background uses the Git Loader and ConversationalRetrieval chain from langchain, Streamlit for UI.")
|
14 |
|
15 |
@st.cache_resource(ttl="1h")
|
16 |
def load_agent(url, branch, file_filter):
|
@@ -43,25 +43,26 @@ def main():
|
|
43 |
for msg in st.session_state.messages:
|
44 |
st.chat_message(msg["role"]).write(msg["content"])
|
45 |
|
46 |
-
if st.session_state["user_message_count"] < MAX_MESSAGES:
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
|
58 |
-
|
59 |
-
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
else:
|
64 |
-
st.warning("Your message limit is over. Contact [Rohan Kataria](https://www.linkedin.com/in/imrohan/) to increase the limit.")
|
|
|
65 |
|
66 |
if __name__ == "__main__":
|
67 |
-
main()
|
|
|
5 |
# Constants
|
6 |
ROLE_USER = "user"
|
7 |
ROLE_ASSISTANT = "assistant"
|
8 |
+
# MAX_MESSAGES = 5 # Commented out but can be reactivated later
|
9 |
|
10 |
+
st.set_page_config(page_title="Chat with Git Code Llama", page_icon="π¦")
|
11 |
st.title("Chat with Git π€π")
|
12 |
st.markdown("by [Rohan Kataria](https://www.linkedin.com/in/imrohan/) view more at [VEW.AI](https://vew.ai/)")
|
13 |
+
st.markdown("This app allows you to chat with Git code files. You can paste link to the Git repository and ask questions about it. In the background uses the Git Loader and ConversationalRetrieval chain from langchain, Ollama, Streamlit for UI.")
|
14 |
|
15 |
@st.cache_resource(ttl="1h")
|
16 |
def load_agent(url, branch, file_filter):
|
|
|
43 |
for msg in st.session_state.messages:
|
44 |
st.chat_message(msg["role"]).write(msg["content"])
|
45 |
|
46 |
+
# if st.session_state["user_message_count"] < MAX_MESSAGES: # Commented out to remove message limit check
|
47 |
+
user_query = st.chat_input(placeholder="Ask me anything!")
|
48 |
|
49 |
+
if user_query:
|
50 |
+
st.session_state.messages.append({"role": ROLE_USER, "content": user_query})
|
51 |
+
st.chat_message(ROLE_USER).write(user_query)
|
52 |
+
st.session_state["user_message_count"] += 1
|
53 |
|
54 |
+
# Generate the response
|
55 |
+
with st.spinner("Generating response"):
|
56 |
+
response = st.session_state["agent"](user_query)
|
57 |
|
58 |
+
# Display the response immediately
|
59 |
+
st.chat_message(ROLE_ASSISTANT).write(response)
|
60 |
|
61 |
+
# Add the response to the message history
|
62 |
+
st.session_state.messages.append({"role": ROLE_ASSISTANT, "content": response})
|
63 |
+
# else:
|
64 |
+
# st.warning("Your message limit is over. Contact [Rohan Kataria](https://www.linkedin.com/in/imrohan/) to increase the limit.")
|
65 |
+
# Commented out the warning message about message limit
|
66 |
|
67 |
if __name__ == "__main__":
|
68 |
+
main()
|