Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,25 +19,8 @@ def clone_repo(repo):
|
|
19 |
|
20 |
if btn and not flag:
|
21 |
clone_repo(repo=repo)
|
22 |
-
# if os.path.exists("githubCode") and os.path.isdir("githubCode"):
|
23 |
-
# print("File already exists!!")
|
24 |
-
# pass
|
25 |
-
# else:
|
26 |
-
# git.Repo.clone_from(repo,"githubCode")
|
27 |
flag = True
|
28 |
|
29 |
-
# def response_generator():
|
30 |
-
# response = random.choice(
|
31 |
-
# [
|
32 |
-
# "Hello there! How can I assist you today?",
|
33 |
-
# "Hi, human! Is there anything I can help you with?",
|
34 |
-
# "Do you need help?",
|
35 |
-
# ]
|
36 |
-
# )
|
37 |
-
# for word in response.split():
|
38 |
-
# yield word + " "
|
39 |
-
# time.sleep(0.05)
|
40 |
-
|
41 |
st.title("Nile")
|
42 |
|
43 |
# Initialize chat history
|
@@ -51,7 +34,7 @@ for message in st.session_state.messages:
|
|
51 |
|
52 |
# Accept user input
|
53 |
if prompt := st.chat_input("What's your question ?"):
|
54 |
-
from util import
|
55 |
# Add user message to chat history
|
56 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
57 |
# Display user message in chat message container
|
@@ -60,16 +43,15 @@ if prompt := st.chat_input("What's your question ?"):
|
|
60 |
|
61 |
# Display assistant response in chat message container
|
62 |
with st.chat_message("assistant"):
|
63 |
-
|
64 |
try:
|
65 |
-
response =
|
66 |
except InternalServerError as err:
|
67 |
retry_attempts = 0
|
68 |
MAX_RETRIES = 2
|
69 |
if retry_attempts < MAX_RETRIES:
|
70 |
retry_attempts += 1
|
71 |
time.sleep(2)
|
72 |
-
response =
|
73 |
else:
|
74 |
# If retries are exhausted, log the error for further investigation
|
75 |
response = "500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting"
|
|
|
19 |
|
20 |
if btn and not flag:
|
21 |
clone_repo(repo=repo)
|
|
|
|
|
|
|
|
|
|
|
22 |
flag = True
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
st.title("Nile")
|
25 |
|
26 |
# Initialize chat history
|
|
|
34 |
|
35 |
# Accept user input
|
36 |
if prompt := st.chat_input("What's your question ?"):
|
37 |
+
from util import ask
|
38 |
# Add user message to chat history
|
39 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
40 |
# Display user message in chat message container
|
|
|
43 |
|
44 |
# Display assistant response in chat message container
|
45 |
with st.chat_message("assistant"):
|
|
|
46 |
try:
|
47 |
+
response = ask(prompt)
|
48 |
except InternalServerError as err:
|
49 |
retry_attempts = 0
|
50 |
MAX_RETRIES = 2
|
51 |
if retry_attempts < MAX_RETRIES:
|
52 |
retry_attempts += 1
|
53 |
time.sleep(2)
|
54 |
+
response = ask(prompt)
|
55 |
else:
|
56 |
# If retries are exhausted, log the error for further investigation
|
57 |
response = "500 An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting"
|