vishanth10 commited on
Commit
1d27410
·
1 Parent(s): 8959c46

Update on fetch files and other search bug

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -68,6 +68,7 @@ def list_user_data_sources():
68
  def list_uploaded_files(data_source_id):
69
  url = "https://api.carbon.ai/user_files_v2"
70
  payload = {
 
71
  "pagination": {
72
  "limit": 100,
73
  "offset": 0
@@ -75,7 +76,7 @@ def list_uploaded_files(data_source_id):
75
  "order_by": "created_at",
76
  "order_dir": "desc",
77
  "filters": {
78
- "organization_user_data_source_id": [data_source_id],
79
  "embedding_generators": ["OPENAI"],
80
  "include_all_children": True,
81
  },
@@ -97,7 +98,7 @@ def search_documents(query, file_ids):
97
  payload = {
98
  "query": query,
99
  "k": 2,
100
- "file_ids": file_ids,
101
  "include_all_children": True,
102
  "include_tags": True,
103
  "include_vectors": True,
@@ -117,7 +118,7 @@ def search_documents(query, file_ids):
117
  }
118
  #response = requests.post(url, json=payload, headers=headers)
119
  response = requests.request("POST", url, json=payload, headers=headers)
120
- print(response.json())
121
  return response.json()['documents']
122
 
123
  # Streamlit UI
@@ -159,22 +160,27 @@ if st.button("List Files"):
159
 
160
  # List Uploaded Files
161
  st.subheader("Documents Uploaded Result")
 
 
 
162
  file_ids = []
163
  if st.button("Show Uploaded Files"):
164
  data_source_id = get_data_source_id(data_source)
165
  uploaded_files = list_uploaded_files(data_source_id)
166
  st.write("Uploaded Files:")
 
167
  for file in uploaded_files:
168
- st.write(f"ID: {file['id']}, Organization Supplied User ID: {file['organization_supplied_user_id']}, "
169
  f"Organization User Data Source ID: {file['organization_user_data_source_id']}, External URL: {file['external_url']}")
170
  file_ids.append(file['id'])
171
- print(file_ids)
172
 
173
  # Search Documents
174
  st.subheader("Search Documents")
175
  query = st.text_input("Enter your search query:")
176
  if st.button("Search"):
177
  if query:
 
178
  search_results = search_documents(query, file_ids)
179
  st.write("Search Results:")
180
  for result in search_results:
 
68
  def list_uploaded_files(data_source_id):
69
  url = "https://api.carbon.ai/user_files_v2"
70
  payload = {
71
+
72
  "pagination": {
73
  "limit": 100,
74
  "offset": 0
 
76
  "order_by": "created_at",
77
  "order_dir": "desc",
78
  "filters": {
79
+ "organization_user_data_source_id": [], #data_source_id organization level need to explore
80
  "embedding_generators": ["OPENAI"],
81
  "include_all_children": True,
82
  },
 
98
  payload = {
99
  "query": query,
100
  "k": 2,
101
+ "file_ids": [],
102
  "include_all_children": True,
103
  "include_tags": True,
104
  "include_vectors": True,
 
118
  }
119
  #response = requests.post(url, json=payload, headers=headers)
120
  response = requests.request("POST", url, json=payload, headers=headers)
121
+ #print(response.json())
122
  return response.json()['documents']
123
 
124
  # Streamlit UI
 
160
 
161
  # List Uploaded Files
162
  st.subheader("Documents Uploaded Result")
163
+ # data_source_search = st.selectbox("Select Data Source for OAuth", ["GOOGLE_DRIVE", "DROPBOX", "NOTION"])
164
+ # if st.button("Submit"):
165
+ # data_source_search
166
  file_ids = []
167
  if st.button("Show Uploaded Files"):
168
  data_source_id = get_data_source_id(data_source)
169
  uploaded_files = list_uploaded_files(data_source_id)
170
  st.write("Uploaded Files:")
171
+ #print(uploaded_files)
172
  for file in uploaded_files:
173
+ st.write(f"ID: {file['id']}, Name: {file['name']}, Organization Supplied User ID: {file['organization_supplied_user_id']}, "
174
  f"Organization User Data Source ID: {file['organization_user_data_source_id']}, External URL: {file['external_url']}")
175
  file_ids.append(file['id'])
176
+ #print( file_ids)
177
 
178
  # Search Documents
179
  st.subheader("Search Documents")
180
  query = st.text_input("Enter your search query:")
181
  if st.button("Search"):
182
  if query:
183
+ #print(file_ids)
184
  search_results = search_documents(query, file_ids)
185
  st.write("Search Results:")
186
  for result in search_results: