Illia56 commited on
Commit
12b6845
·
1 Parent(s): 872c6a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -25,6 +25,8 @@ with st.sidebar:
25
  code_interpreter = st.sidebar.toggle("Code Interpreter", value=True)
26
  system_prompt = st.sidebar.text_input("System prompt for code interpreter", value = "Rule 1: If a user requests a code snippet, provide only one that can run in a Streamlit app without requiring additional libraries.")
27
  useSystemPrompt = st.sidebar.toggle("Use System prompt", value=True)
 
 
28
 
29
  # Retrieve the corresponding language code from the dictionary
30
  selected_language_code = GOOGLE_LANGUAGES_TO_CODES[selected_language_name]
@@ -48,7 +50,7 @@ def predict(message):
48
  st.write("Done...")
49
 
50
  st.write("Checking images...")
51
- if 'images' in response.keys():
52
  for i in response['images']:
53
  st.image(i)
54
 
@@ -72,13 +74,17 @@ if prompt := st.chat_input("Ask Palm 2 anything..."):
72
  st.markdown(response['content'])
73
 
74
  if response['code']:
75
- with st.status("Exporting replit..."):
76
- url = bard.export_replit(
77
- code=response['code'],
78
- program_lang=response['program_lang'],
79
- )['url']
80
- st.title('Export to repl.it')
81
- st.markdown(f'[link]({url})')
 
 
 
 
82
  if code_interpreter:
83
  try:
84
  exec(response['code'])
 
25
  code_interpreter = st.sidebar.toggle("Code Interpreter", value=True)
26
  system_prompt = st.sidebar.text_input("System prompt for code interpreter", value = "Rule 1: If a user requests a code snippet, provide only one that can run in a Streamlit app without requiring additional libraries.")
27
  useSystemPrompt = st.sidebar.toggle("Use System prompt", value=True)
28
+ exportToReplIt = st.sidebar.toggle("Export to repl.it", value=False)
29
+ showImages = st.sidebar.toggle("Show images", value=True)
30
 
31
  # Retrieve the corresponding language code from the dictionary
32
  selected_language_code = GOOGLE_LANGUAGES_TO_CODES[selected_language_name]
 
50
  st.write("Done...")
51
 
52
  st.write("Checking images...")
53
+ if 'images' in response.keys() and showImages:
54
  for i in response['images']:
55
  st.image(i)
56
 
 
74
  st.markdown(response['content'])
75
 
76
  if response['code']:
77
+ if exportToReplIt:
78
+ with st.status("Exporting replit..."):
79
+ fale = False
80
+ try:
81
+ url = bard.export_replit(code=response['code'],program_lang=response['program_lang'])['url']
82
+ except error:
83
+ fale=True
84
+ st.write('ERROR')
85
+ if not fale:
86
+ st.title('Export to repl.it')
87
+ st.markdown(f'[link]({url})')
88
  if code_interpreter:
89
  try:
90
  exec(response['code'])