mtyrrell commited on
Commit
6eb6385
·
1 Parent(s): 6795b19

sources fix

Browse files
src/components/generator/sources.py CHANGED
@@ -213,9 +213,12 @@ def create_sources_list(
213
 
214
  # Create a descriptive title
215
  title = " - ".join(title_parts) if title_parts else f"Source {citation_num}"
216
-
217
- # 2. Extract Link using configured field (use '#' as fallback for empty/missing)
218
- link = all_meta.get(link_metadata_field) or '#'
 
 
 
219
 
220
  sources.append({
221
  "uri": link,
 
213
 
214
  # Create a descriptive title
215
  title = " - ".join(title_parts) if title_parts else f"Source {citation_num}"
216
+
217
+ # 2. Extract Link using configured field (use 'doc://#' as fallback for empty/missing)
218
+ # ChatUI requires URLs to match doc://, http://, or https:// schemes
219
+ link = all_meta.get(link_metadata_field)
220
+ if not link or link == '#':
221
+ link = 'doc://#' # Use doc:// scheme for placeholder links
222
 
223
  sources.append({
224
  "uri": link,
src/components/orchestration/ui_adapters.py CHANGED
@@ -139,10 +139,14 @@ async def chatui_adapter(data, compiled_graph, max_turns: int = 3, max_chars: in
139
  sources_collected = content
140
  elif result_type == "end":
141
  if sources_collected:
142
- # Send sources as structured JSON for ChatUI to parse
143
- sources_json = json.dumps({"webSources": sources_collected})
144
- logger.info(f"Sending structured sources: {sources_json}")
145
- yield sources_json
 
 
 
 
146
  elif result_type == "error":
147
  yield f"Error: {content}"
148
  else:
@@ -242,10 +246,17 @@ async def chatui_file_adapter(data, compiled_graph, max_turns: int = 3, max_char
242
  sources_collected = content
243
  elif result_type == "end":
244
  if sources_collected:
245
- # Send sources as structured JSON for ChatUI to parse
246
- sources_json = json.dumps({"webSources": sources_collected})
247
- logger.info(f"Sending structured sources (file): {sources_json}")
248
- yield sources_json
 
 
 
 
 
 
 
249
  elif result_type == "error":
250
  yield f"Error: {content}"
251
  else:
 
139
  sources_collected = content
140
  elif result_type == "end":
141
  if sources_collected:
142
+ # Send sources as markdown with doc:// URLs for ChatUI to parse
143
+ sources_text = "\n\n**Sources:**\n"
144
+ for i, source in enumerate(sources_collected, 1):
145
+ title = source.get('title', 'Unknown')
146
+ uri = source.get('uri') or 'doc://#'
147
+ sources_text += f"{i}. [{title}]({uri})\n"
148
+ logger.info(f"Sending markdown sources with doc:// scheme")
149
+ yield sources_text
150
  elif result_type == "error":
151
  yield f"Error: {content}"
152
  else:
 
246
  sources_collected = content
247
  elif result_type == "end":
248
  if sources_collected:
249
+ # Send sources as markdown with doc:// URLs for ChatUI to parse
250
+ sources_text = "\n\n**Sources:**\n"
251
+ for i, source in enumerate(sources_collected, 1):
252
+ if isinstance(source, dict):
253
+ title = source.get('title', 'Unknown')
254
+ uri = source.get('uri') or 'doc://#'
255
+ sources_text += f"{i}. [{title}]({uri})\n"
256
+ else:
257
+ sources_text += f"{i}. {str(source)}\n"
258
+ logger.info(f"Sending markdown sources with doc:// scheme (file)")
259
+ yield sources_text
260
  elif result_type == "error":
261
  yield f"Error: {content}"
262
  else: