Halemo commited on
Commit
c591b46
·
1 Parent(s): 5beca3b

some tweaks

Browse files
Files changed (1) hide show
  1. app.py +23 -8
app.py CHANGED
@@ -26,7 +26,9 @@ def validate_api_key(api_key):
26
 
27
  # Ask for API key from user
28
  st.title("Colivara Demo")
29
- st.write("Welcome to the Colivara Demo.")
 
 
30
  st.subheader("API Key")
31
  api_key = st.text_input("API Key", type="password")
32
  if not api_key or not validate_api_key(api_key):
@@ -35,12 +37,17 @@ if not api_key or not validate_api_key(api_key):
35
  st.stop()
36
 
37
  client = Colivara(base_url="https://api.colivara.com", api_key=api_key)
 
 
 
 
38
 
 
39
  # Create Collection Section
40
- st.subheader("Create Collection (Optional)")
41
  collection_name = st.text_input(
42
  "Collection Name",
43
- help="Enter the name of the collection to create, or leave empty if not creating one.",
44
  )
45
  if st.button("Create Collection"):
46
  if not collection_name:
@@ -49,7 +56,7 @@ if st.button("Create Collection"):
49
  with st.spinner("Creating collection..."):
50
  client.create_collection(collection_name)
51
  st.success(f"Collection '{collection_name}' successfully created.")
52
-
53
  # List Collections Section
54
  st.subheader("List Collections")
55
  if st.button("List Collections"):
@@ -60,7 +67,7 @@ if st.button("List Collections"):
60
 
61
  if st.session_state["collections_list"]:
62
  st.code(st.session_state["collections_list"])
63
-
64
  # Upsert Documents Section
65
  st.subheader("Upsert Documents")
66
  uploaded_files = st.file_uploader(
@@ -103,9 +110,15 @@ if st.button("Upsert Files"):
103
  st.success(
104
  f"{len(new_files)} new files successfully upserted to the collection '{selected_collection}'."
105
  )
106
-
107
  # Search and Retrieve Documents Section
108
  st.subheader("Search and Retrieve Documents")
 
 
 
 
 
 
109
  query = st.text_input(
110
  "Search Query", help="Enter the search query to retrieve documents."
111
  )
@@ -119,12 +132,14 @@ top_k = st.slider(
119
  )
120
 
121
  if st.button("Search"):
122
- if not query:
 
 
123
  st.error("Please enter a search query to retrieve documents.")
124
  else:
125
  with st.spinner("Searching..."):
126
  results = client.search(
127
- query=query, collection_name=selected_collection, top_k=top_k
128
  )
129
  st.session_state["search_results"] = results.results
130
 
 
26
 
27
  # Ask for API key from user
28
  st.title("Colivara Demo")
29
+ st.write(
30
+ "Welcome to the Colivara Demo. To reveal the features, please enter your API key."
31
+ )
32
  st.subheader("API Key")
33
  api_key = st.text_input("API Key", type="password")
34
  if not api_key or not validate_api_key(api_key):
 
37
  st.stop()
38
 
39
  client = Colivara(base_url="https://api.colivara.com", api_key=api_key)
40
+ st.divider()
41
+ st.subheader("Features Overview")
42
+ st.write("Each section below is independent, and you can use them separately.")
43
+
44
 
45
+ st.divider()
46
  # Create Collection Section
47
+ st.subheader("Create Collection")
48
  collection_name = st.text_input(
49
  "Collection Name",
50
+ help="Enter the name of the collection to create",
51
  )
52
  if st.button("Create Collection"):
53
  if not collection_name:
 
56
  with st.spinner("Creating collection..."):
57
  client.create_collection(collection_name)
58
  st.success(f"Collection '{collection_name}' successfully created.")
59
+ st.divider()
60
  # List Collections Section
61
  st.subheader("List Collections")
62
  if st.button("List Collections"):
 
67
 
68
  if st.session_state["collections_list"]:
69
  st.code(st.session_state["collections_list"])
70
+ st.divider()
71
  # Upsert Documents Section
72
  st.subheader("Upsert Documents")
73
  uploaded_files = st.file_uploader(
 
110
  st.success(
111
  f"{len(new_files)} new files successfully upserted to the collection '{selected_collection}'."
112
  )
113
+ st.divider()
114
  # Search and Retrieve Documents Section
115
  st.subheader("Search and Retrieve Documents")
116
+
117
+ # Add collection name input for search
118
+ search_collection_name = st.text_input(
119
+ "Collection Name for Search", help="Enter the collection name to search in."
120
+ )
121
+
122
  query = st.text_input(
123
  "Search Query", help="Enter the search query to retrieve documents."
124
  )
 
132
  )
133
 
134
  if st.button("Search"):
135
+ if not search_collection_name:
136
+ st.error("Please enter the collection name for the search.")
137
+ elif not query:
138
  st.error("Please enter a search query to retrieve documents.")
139
  else:
140
  with st.spinner("Searching..."):
141
  results = client.search(
142
+ query=query, collection_name=search_collection_name, top_k=top_k
143
  )
144
  st.session_state["search_results"] = results.results
145