awacke1 commited on
Commit
3321364
β€’
1 Parent(s): 15d4ccd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -39
app.py CHANGED
@@ -93,7 +93,11 @@ def search_arxiv(query):
93
  top_n_results = st.slider("Top n results as context", min_value=4, max_value=100, value=100)
94
  search_source = st.selectbox("Search Source", ["Semantic Search - up to 10 Mar 2024", "Arxiv Search - Latest - (EXPERIMENTAL)"])
95
  llm_model = st.selectbox("LLM Model", ["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mistral-7B-Instruct-v0.2", "google/gemma-7b-it", "None"])
 
 
96
  st.markdown('### πŸ”Ž ' + query)
 
 
97
  result = client.predict(
98
  search_query,
99
  top_n_results,
@@ -101,38 +105,20 @@ def search_arxiv(query):
101
  llm_model,
102
  api_name="/update_with_rag_md"
103
  )
 
 
104
  st.markdown(result)
105
  arxiv_results = st.text_area("ArXiv Results: ", value=result, height=700)
106
  result = str(result) # cast as string for these - check content length and format if encoding changes..
107
  result=result.replace('\\n', ' ')
108
  SpeechSynthesis(result) # Search History Reader / Writer IO Memory - Audio at Same time as Reading.
109
  filename=generate_filename(result, "md")
110
- base_filename, ext = os.path.splitext(filename)
111
- with open(f"{base_filename}.md", 'w') as file:
112
- try:
113
- content = query.strip() + '\r\n' + result
114
- file.write(content)
115
- except:
116
- st.write('.')
117
- # Show ArXiv Scholary Articles! ----------------*************-------------***************----------------------------------------
118
-
119
-
120
- #has_python_code = re.search(r"```python([\s\S]*?)```", prompt.strip() + '\r\n' + response)
121
- #has_python_code = bool(re.search(r"```python([\s\S]*?)```", prompt.strip() + '\r\n' + response))
122
- #if has_python_code:
123
- # python_code = re.findall(r"```python([\s\S]*?)```", response)[0].strip()
124
- # with open(f"{base_filename}-Code.py", 'w') as file:
125
- # file.write(python_code)
126
- # with open(f"{base_filename}.md", 'w') as file:
127
- # content = prompt.strip() + '\r\n' + response
128
- # file.write(content)
129
-
130
  create_file(filename, query, result, should_save)
131
 
132
- file_type = st.radio("Select Which Type of Memory You Prefer:", ("Semantic", "Episodic"))
133
- if st.button("Save"):
134
- file_name = save_file(result, file_type)
135
- st.success(f"File saved: {file_name}")
136
 
137
  saved_files = [f for f in os.listdir(".") if f.endswith(".md")]
138
  selected_file = st.sidebar.selectbox("Saved Files", saved_files)
@@ -140,19 +126,11 @@ def search_arxiv(query):
140
  if selected_file:
141
  file_content = load_file(selected_file)
142
  st.sidebar.markdown(file_content)
143
-
144
- if st.sidebar.button("πŸ“ Edit"):
145
- edited_content = st.text_area("Edit File", value=file_content, height=400)
146
- new_file_name = st.text_input("File Name", value=selected_file)
147
- if st.button("πŸ’Ύ Save"):
148
- with open(new_file_name, "w") as file:
149
- file.write(edited_content)
150
- st.success(f"File updated: {new_file_name}")
151
-
152
  if st.sidebar.button("πŸ—‘οΈ Delete"):
153
  os.remove(selected_file)
154
  st.warning(f"File deleted: {selected_file}")
155
-
 
156
  # Set page configuration with a title and favicon
157
  st.set_page_config(
158
  page_title="πŸš€πŸŒŒWorld Ship Design Program",
@@ -168,7 +146,7 @@ st.set_page_config(
168
 
169
  # Prompts for App, for App Product, and App Product Code
170
  PromptPrefix = 'Create a specification with streamlit functions creating markdown outlines and tables rich with appropriate emojis for methodical step by step rules defining the concepts at play. Use story structure architect rules to plan, structure and write three dramatic situations to include in the rules and how to play by matching the theme for topic of '
171
- PromptPrefix2 = 'Create a streamlit python user app with full code listing to create a UI implementing the using streamlit or gradio or huggingface to create user interface elements like emoji buttons, sliders, drop downs, and data interfaces like dataframes to show tables, session_state to track inventory, character advancement and experience, locations, file_uploader to allow the user to add images which are saved and referenced shown in gallery, camera_input to take character picture, on_change = function callbacks with continual running plots that change when you change data or click a button, randomness and word and letter rolls using emojis and st.markdown, st.expander for groupings and clusters of things, st.columns and other UI controls in streamlit as a game. Create inline data tables and list dictionaries for entities implemented as variables for the word game rule entities and stats. Design it as a fun data driven game app and show full python code listing for this ruleset and thematic story plot line: '
172
  PromptPrefix3 = 'Create a HTML5 aframe and javascript app using appropriate libraries to create a word game simulation with advanced libraries like aframe to render 3d scenes creating moving entities that stay within a bounding box but show text and animation in 3d for inventory, components and story entities. Show full code listing. Add a list of new random entities say 3 of a few different types to any list appropriately and use emojis to make things easier and fun to read. Use appropriate emojis in labels. Create the UI to implement storytelling in the style of a dungeon master, with features using three emoji appropriate text plot twists and recurring interesting funny fascinating and complex almost poetic named characters with genius traits and file IO, randomness, ten point choice lists, math distribution tradeoffs, witty humorous dilemnas with emoji , rewards, variables, reusable functions with parameters, and data driven app with python libraries and streamlit components for Javascript and HTML5. Use appropriate emojis for labels to summarize and list parts, function, conditions for topic:'
173
 
174
  # Function to display the entire glossary in a grid format with links
@@ -1342,8 +1320,9 @@ What is SORA?
1342
  # Search AI
1343
  query=example_input
1344
  if query:
1345
- search_arxiv(query)
1346
- search_glossary(query)
 
1347
  st.markdown(' ')
1348
 
1349
  st.write("Search history:")
@@ -1480,8 +1459,12 @@ try:
1480
  query_params = st.query_params
1481
  query = (query_params.get('q') or query_params.get('query') or [''])
1482
  if query:
1483
- search_glossary(query)
1484
- search_arxiv(query)
 
 
 
 
1485
  except:
1486
  st.markdown(' ')
1487
 
 
93
  top_n_results = st.slider("Top n results as context", min_value=4, max_value=100, value=100)
94
  search_source = st.selectbox("Search Source", ["Semantic Search - up to 10 Mar 2024", "Arxiv Search - Latest - (EXPERIMENTAL)"])
95
  llm_model = st.selectbox("LLM Model", ["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mistral-7B-Instruct-v0.2", "google/gemma-7b-it", "None"])
96
+
97
+
98
  st.markdown('### πŸ”Ž ' + query)
99
+
100
+
101
  result = client.predict(
102
  search_query,
103
  top_n_results,
 
105
  llm_model,
106
  api_name="/update_with_rag_md"
107
  )
108
+
109
+
110
  st.markdown(result)
111
  arxiv_results = st.text_area("ArXiv Results: ", value=result, height=700)
112
  result = str(result) # cast as string for these - check content length and format if encoding changes..
113
  result=result.replace('\\n', ' ')
114
  SpeechSynthesis(result) # Search History Reader / Writer IO Memory - Audio at Same time as Reading.
115
  filename=generate_filename(result, "md")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  create_file(filename, query, result, should_save)
117
 
118
+ #file_type = st.radio("Select Which Type of Memory You Prefer:", ("Semantic", "Episodic"))
119
+ #if st.button("Save"):
120
+ # file_name = save_file(result, file_type)
121
+ # st.success(f"File saved: {file_name}")
122
 
123
  saved_files = [f for f in os.listdir(".") if f.endswith(".md")]
124
  selected_file = st.sidebar.selectbox("Saved Files", saved_files)
 
126
  if selected_file:
127
  file_content = load_file(selected_file)
128
  st.sidebar.markdown(file_content)
 
 
 
 
 
 
 
 
 
129
  if st.sidebar.button("πŸ—‘οΈ Delete"):
130
  os.remove(selected_file)
131
  st.warning(f"File deleted: {selected_file}")
132
+ return result
133
+
134
  # Set page configuration with a title and favicon
135
  st.set_page_config(
136
  page_title="πŸš€πŸŒŒWorld Ship Design Program",
 
146
 
147
  # Prompts for App, for App Product, and App Product Code
148
  PromptPrefix = 'Create a specification with streamlit functions creating markdown outlines and tables rich with appropriate emojis for methodical step by step rules defining the concepts at play. Use story structure architect rules to plan, structure and write three dramatic situations to include in the rules and how to play by matching the theme for topic of '
149
+ PromptPrefix2 = 'Create a streamlit python user app with full code listing to create a UI implementing the using streamlit, gradio, huggingface to create user interface elements like emoji buttons, sliders, drop downs, and data interfaces like dataframes to show tables, session_statematching this ruleset and thematic story plot line: '
150
  PromptPrefix3 = 'Create a HTML5 aframe and javascript app using appropriate libraries to create a word game simulation with advanced libraries like aframe to render 3d scenes creating moving entities that stay within a bounding box but show text and animation in 3d for inventory, components and story entities. Show full code listing. Add a list of new random entities say 3 of a few different types to any list appropriately and use emojis to make things easier and fun to read. Use appropriate emojis in labels. Create the UI to implement storytelling in the style of a dungeon master, with features using three emoji appropriate text plot twists and recurring interesting funny fascinating and complex almost poetic named characters with genius traits and file IO, randomness, ten point choice lists, math distribution tradeoffs, witty humorous dilemnas with emoji , rewards, variables, reusable functions with parameters, and data driven app with python libraries and streamlit components for Javascript and HTML5. Use appropriate emojis for labels to summarize and list parts, function, conditions for topic:'
151
 
152
  # Function to display the entire glossary in a grid format with links
 
1320
  # Search AI
1321
  query=example_input
1322
  if query:
1323
+ result = search_arxiv(query)
1324
+ #search_glossary(query)
1325
+ search_glossary(result)
1326
  st.markdown(' ')
1327
 
1328
  st.write("Search history:")
 
1459
  query_params = st.query_params
1460
  query = (query_params.get('q') or query_params.get('query') or [''])
1461
  if query:
1462
+ result = search_arxiv(query)
1463
+ result2 = search_glossary(result)
1464
+
1465
+
1466
+
1467
+
1468
  except:
1469
  st.markdown(' ')
1470