flowquery 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +3 -3
  2. package/dist/flowquery.min.js +1 -1
  3. package/dist/parsing/functions/aggregate_function.d.ts +1 -1
  4. package/dist/parsing/functions/aggregate_function.d.ts.map +1 -1
  5. package/dist/parsing/functions/aggregate_function.js.map +1 -1
  6. package/dist/parsing/functions/async_function.d.ts +19 -16
  7. package/dist/parsing/functions/async_function.d.ts.map +1 -1
  8. package/dist/parsing/functions/async_function.js +20 -59
  9. package/dist/parsing/functions/async_function.js.map +1 -1
  10. package/dist/parsing/functions/function.d.ts +1 -1
  11. package/dist/parsing/functions/function.d.ts.map +1 -1
  12. package/dist/parsing/functions/function.js +1 -1
  13. package/dist/parsing/functions/function.js.map +1 -1
  14. package/dist/parsing/functions/function_factory.d.ts +2 -0
  15. package/dist/parsing/functions/function_factory.d.ts.map +1 -1
  16. package/dist/parsing/functions/function_factory.js +12 -11
  17. package/dist/parsing/functions/function_factory.js.map +1 -1
  18. package/dist/parsing/functions/function_metadata.d.ts +53 -24
  19. package/dist/parsing/functions/function_metadata.d.ts.map +1 -1
  20. package/dist/parsing/functions/function_metadata.js +55 -45
  21. package/dist/parsing/functions/function_metadata.js.map +1 -1
  22. package/dist/parsing/functions/predicate_function.d.ts +1 -1
  23. package/dist/parsing/functions/predicate_function.d.ts.map +1 -1
  24. package/dist/parsing/functions/predicate_function.js +1 -1
  25. package/dist/parsing/functions/predicate_function.js.map +1 -1
  26. package/dist/parsing/operations/load.d.ts +1 -0
  27. package/dist/parsing/operations/load.d.ts.map +1 -1
  28. package/dist/parsing/operations/load.js +3 -1
  29. package/dist/parsing/operations/load.js.map +1 -1
  30. package/dist/parsing/parser.d.ts.map +1 -1
  31. package/dist/parsing/parser.js +1 -2
  32. package/dist/parsing/parser.js.map +1 -1
  33. package/docs/flowquery.min.js +1 -1
  34. package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
  35. package/misc/apps/RAG/package.json +1 -2
  36. package/misc/apps/RAG/src/components/ChatContainer.tsx +33 -6
  37. package/misc/apps/RAG/src/components/ChatMessage.css +24 -0
  38. package/misc/apps/RAG/src/components/ChatMessage.tsx +51 -2
  39. package/misc/apps/RAG/src/components/FlowQueryAgent.ts +566 -286
  40. package/misc/apps/RAG/src/plugins/index.ts +3 -1
  41. package/misc/apps/RAG/src/plugins/loaders/CatFacts.ts +6 -5
  42. package/misc/apps/RAG/src/plugins/loaders/Form.ts +7 -7
  43. package/misc/apps/RAG/src/plugins/loaders/Llm.ts +14 -14
  44. package/misc/apps/RAG/src/plugins/loaders/MockData.ts +5 -5
  45. package/misc/apps/RAG/src/plugins/loaders/Table.ts +4 -4
  46. package/misc/apps/RAG/src/plugins/loaders/Weather.ts +126 -0
  47. package/misc/apps/RAG/src/prompts/FlowQuerySystemPrompt.ts +4 -0
  48. package/package.json +1 -1
  49. package/src/parsing/functions/aggregate_function.ts +1 -1
  50. package/src/parsing/functions/async_function.ts +20 -51
  51. package/src/parsing/functions/function.ts +2 -2
  52. package/src/parsing/functions/function_factory.ts +18 -9
  53. package/src/parsing/functions/function_metadata.ts +55 -47
  54. package/src/parsing/functions/predicate_function.ts +2 -2
  55. package/src/parsing/operations/load.ts +3 -1
  56. package/src/parsing/parser.ts +2 -1
  57. package/tests/extensibility.test.ts +22 -22
  58. package/tests/parsing/parser.test.ts +2 -2
  59. package/misc/apps/RAG/.env.example +0 -14
  60. package/misc/apps/RAG/src/plugins/loaders/FetchJson.ts +0 -66
@@ -56,6 +56,30 @@
56
56
  color: #666;
57
57
  }
58
58
 
59
+ .flowquery-toggle-link {
60
+ font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
61
+ font-size: 12px;
62
+ font-weight: 600;
63
+ color: #666;
64
+ background: none;
65
+ border: none;
66
+ cursor: pointer;
67
+ padding: 2px 6px;
68
+ border-radius: 4px;
69
+ transition: background-color 0.15s ease, color 0.15s ease;
70
+ margin-left: 4px;
71
+ }
72
+
73
+ .flowquery-toggle-link:hover {
74
+ background-color: rgba(0, 120, 212, 0.1);
75
+ color: #0078d4;
76
+ }
77
+
78
+ .flowquery-toggle-link.active {
79
+ color: #0078d4;
80
+ background-color: rgba(0, 120, 212, 0.1);
81
+ }
82
+
59
83
  .chat-message-text {
60
84
  white-space: pre-wrap;
61
85
  word-break: break-word;
@@ -67,6 +67,7 @@ interface MessageContentProps {
67
67
  content: string;
68
68
  isStreaming?: boolean;
69
69
  adaptiveCard?: Record<string, unknown>;
70
+ showFlowQuery?: boolean;
70
71
  }
71
72
 
72
73
  interface MessageContentState {
@@ -107,7 +108,7 @@ class MessageContent extends Component<MessageContentProps, MessageContentState>
107
108
  }
108
109
 
109
110
  render() {
110
- const { content, isStreaming } = this.props;
111
+ const { content, isStreaming, showFlowQuery } = this.props;
111
112
  const { runnerQuery } = this.state;
112
113
 
113
114
  const flowQueryBlocks = this.getFlowQueryBlocks();
@@ -126,6 +127,21 @@ class MessageContent extends Component<MessageContentProps, MessageContentState>
126
127
  );
127
128
  }
128
129
 
130
+ // If FlowQuery blocks are hidden, render content without code blocks
131
+ if (!showFlowQuery) {
132
+ // Remove FlowQuery code blocks from content for display
133
+ const contentWithoutFlowQuery = content.replace(/```flowquery\n[\s\S]*?```/gi, '').trim();
134
+ return (
135
+ <>
136
+ {contentWithoutFlowQuery}
137
+ {allAdaptiveCards.map((card, index) => (
138
+ <AdaptiveCardRenderer key={`card-${index}`} card={card} />
139
+ ))}
140
+ {isStreaming && <Spinner size="tiny" className="streaming-indicator" />}
141
+ </>
142
+ );
143
+ }
144
+
129
145
  // Split content by FlowQuery code blocks and render with buttons
130
146
  const parts: React.ReactNode[] = [];
131
147
  let lastIndex = 0;
@@ -204,10 +220,31 @@ class MessageContent extends Component<MessageContentProps, MessageContentState>
204
220
  }
205
221
  }
206
222
 
207
- export class ChatMessage extends Component<ChatMessageProps> {
223
+ interface ChatMessageState {
224
+ showFlowQuery: boolean;
225
+ }
226
+
227
+ export class ChatMessage extends Component<ChatMessageProps, ChatMessageState> {
228
+ constructor(props: ChatMessageProps) {
229
+ super(props);
230
+ this.state = {
231
+ showFlowQuery: false
232
+ };
233
+ }
234
+
235
+ private hasFlowQueryBlocks(): boolean {
236
+ return /```flowquery\n[\s\S]*?```/gi.test(this.props.message.content);
237
+ }
238
+
239
+ private toggleFlowQuery = (): void => {
240
+ this.setState(prev => ({ showFlowQuery: !prev.showFlowQuery }));
241
+ };
242
+
208
243
  render() {
209
244
  const { message } = this.props;
245
+ const { showFlowQuery } = this.state;
210
246
  const isUser = message.role === 'user';
247
+ const hasFlowQuery = !isUser && this.hasFlowQueryBlocks();
211
248
 
212
249
  return (
213
250
  <div className={`chat-message ${isUser ? 'chat-message-user' : 'chat-message-assistant'}`}>
@@ -222,12 +259,24 @@ export class ChatMessage extends Component<ChatMessageProps> {
222
259
  <span className="chat-message-time">
223
260
  {message.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
224
261
  </span>
262
+ {hasFlowQuery && (
263
+ <Tooltip content={showFlowQuery ? 'Hide FlowQuery' : 'Show FlowQuery'} relationship="label">
264
+ <button
265
+ className={`flowquery-toggle-link ${showFlowQuery ? 'active' : ''}`}
266
+ onClick={this.toggleFlowQuery}
267
+ aria-label={showFlowQuery ? 'Hide FlowQuery code' : 'Show FlowQuery code'}
268
+ >
269
+ &lt;/&gt;
270
+ </button>
271
+ </Tooltip>
272
+ )}
225
273
  </div>
226
274
  <div className="chat-message-text">
227
275
  <MessageContent
228
276
  content={message.content}
229
277
  isStreaming={message.isStreaming}
230
278
  adaptiveCard={message.adaptiveCard}
279
+ showFlowQuery={showFlowQuery}
231
280
  />
232
281
  </div>
233
282
  </div>