You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/blog/2025-10-30-ragflow-in-practice-an-intelligent-agent-for-in-depth-research-on-company-research-reports/index.md
+188-7Lines changed: 188 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ When an analyst poses a question, the system identifies the company name or abbr
16
16
17
17
The workflow after orchestration is as follows:
18
18
19
-

19
+

20
20
21
21
This case utilizes RAGFlow to implement a complete workflow, ranging from stock code extraction, to the generation of company financial statements, and finally to the integration and output of research report information.
22
22
@@ -236,19 +236,200 @@ def main(input_text: str):
236
236
237
237
We have also received requests from everyone expressing a preference not to extract JSON fields through coding, and we will gradually provide solutions in future versions.
238
238
239
-
## 2.4
239
+
## 2.4 Build the "Research Report Information Extraction" function
240
240
241
-
### 2.4.1
241
+

242
242
243
-
### 2.4.2
243
+
Utilize an information extraction agent, which, based on the `stockCode`, calls the AlphaVantage API to extract the latest authoritative research reports and insights. Meanwhile, it invokes the internal research report retrieval agent to obtain the full text of the complete research reports. Finally, it outputs the two parts of content separately in a fixed structure, thereby achieving an efficient information extraction function.
244
244
245
-
## 2.5
245
+

246
246
247
-
## 2.6
247
+
System prompt:
248
248
249
-
## 2.7
249
+
```
250
+
<role>
251
+
252
+
You are the information extraction agent. You understand the user’s query and delegate tasks to alphavantage and the internal research report retrieval agent.
253
+
254
+
</role>
255
+
256
+
<requirements>
257
+
258
+
1. Based on the stock code output by the "Extract Stock Code" agent, call alphavantage's EARNINGS_CALL_TRANSCRIPT to retrieve the latest information that can be used in a research report, and store all publicly available key details.
259
+
260
+
261
+
2. Call the "Internal Research Report Retrieval Agent" and save the full text of the research report output.
262
+
263
+
3. Output the content retrieved from alphavantage and the Internal Research Report Retrieval Agent in full.
264
+
265
+
</requirements>
266
+
267
+
268
+
<report_structure_requirements>
269
+
The output must be divided into two sections:
270
+
#1. Title: “alphavantage”
271
+
Directly output the content collected from alphavantage without any additional processing.
272
+
#2. Title: "Internal Research Report Retrieval Agent"
273
+
Directly output the content provided by the Internal Research Report Retrieval Agent.
274
+
</report_structure_requirements>
275
+
```
276
+
277
+
### 2.4.1 Configure the MCP tool
278
+
279
+
Add the MCP tool:
280
+
281
+

282
+
283
+
Add the MCP tool under the agent and select the required method, such as "EARNINGS_CALL_TRANSCRIPT".
284
+
285
+

286
+
287
+
### 2.4.2 Internal Research Report Retrieval Agent
288
+
289
+
The key focus in constructing the internal research report retrieval agent lies in accurately identifying the company or stock code in user queries. It then invokes the Retrieval tool to search for research reports from the knowledge base and outputs the full text, ensuring that information such as data, viewpoints, conclusions, tables, and risk warnings is not omitted. This enables high-fidelity extraction of research report content.
290
+
291
+

292
+
293
+
System Prompt:
294
+
295
+
```
296
+
<Task Objective>
297
+
298
+
Read user input → Identify the involved company/stock (supports abbreviations, full names, codes, and aliases) → Retrieve the most relevant research reports from the knowledge base → Output the full text of the research report, retaining the original format, data, chart descriptions, and risk warnings.
299
+
300
+
</Task Objective>
301
+
302
+
303
+
304
+
<Execution Rules>
305
+
306
+
1. Exact Match: Prioritize exact matches of company full names and stock codes.
307
+
308
+
2. Content Fidelity: Fully retain the research report text stored in the knowledge base without deletion, modification, or omission of paragraphs.
309
+
310
+
3. Original Data: Retain table data, dates, units, etc., in their original form.
311
+
312
+
4. Complete Viewpoints: Include investment logic, financial analysis, industry comparisons, earnings forecasts, valuation methods, risk warnings, etc.
313
+
314
+
5. Merging Multiple Reports: If there are multiple relevant research reports, output them in reverse chronological order.
315
+
316
+
6. No Results Feedback: If no matching reports are found, output “No related research reports available in the knowledge base.”
317
+
318
+
319
+
320
+
</Execution Rules>
321
+
```
322
+
323
+
## 2.5 Add a Research Report Generation Agent
324
+
325
+
The research report generation agent automatically extracts and structurally organizes financial and economic information, generating foundational data and content for investment bank analysts that are professional, retain differentiation, and can be directly used in investment research reports.
326
+
327
+

328
+
329
+
```
330
+
<role>
331
+
332
+
You are a senior investment banking (IB) analyst with years of experience in capital market research. You excel at writing investment research reports covering publicly listed companies, industries, and macroeconomics. You possess strong financial analysis skills and industry insights, combining quantitative and qualitative analysis to provide high-value references for investment decisions.
333
+
334
+
**You are able to retain and present differentiated viewpoints from various reports and sources in your research, and when discrepancies arise, you do not merge them into a single conclusion. Instead, you compare and analyze the differences.**
335
+
336
+
337
+
</role>
338
+
339
+
340
+
341
+
342
+
<input>
343
+
344
+
You will receive financial information extracted by the information extraction agent.
345
+
346
+
</input>
347
+
348
+
349
+
<core_task>
350
+
Based on the content returned by the information extraction agent (no fabrication of data), write a professional, complete, and structured investment research report. The report must be logically rigorous, clearly organized, and use professional language, suitable for reference by fund managers, institutional investors, and other professional readers.
351
+
When there are differences in analysis or forecasts between different reports or institutions, you must list and identify the sources in the report. You should not select only one viewpoint. You need to point out the differences, their possible causes, and their impact on investment judgments.
352
+
</core_task>
353
+
354
+
355
+
<report_structure_requirements>
356
+
##1. Summary
357
+
Provide a concise overview of the company’s core business, recent performance, industry positioning, and major investment highlights.
358
+
Summarize key conclusions in 3-5 sentences.
359
+
Highlight any discrepancies in core conclusions and briefly describe the differing viewpoints and areas of disagreement.
360
+
##2. Company Overview
361
+
Describe the company's main business, core products/services, market share, competitive advantages, and business model.
362
+
Highlight any differences in the description of the company’s market position or competitive advantages from different sources. Present and compare these differences.
363
+
##3. Recent Financial Performance
364
+
Summarize key metrics from the latest financial report (e.g., revenue, net profit, gross margin, EPS).
365
+
Highlight the drivers behind the trends and compare the differential analyses from different reports. Present this comparison in a table.
366
+
##4. Industry Trends & Opportunities
367
+
Overview of industry development trends, market size, and major drivers.
368
+
If different sources provide differing forecasts for industry growth rates, technological trends, or competitive landscape, list these and provide background information. Present this comparison in a table.
369
+
##5. Investment Recommendation
370
+
Provide a clear investment recommendation based on the analysis above (e.g., "Buy/Hold/Neutral/Sell"), presented in a table.
371
+
Include investment ratings or recommendations from all sources, with the source and date clearly noted.
372
+
If you provide a combined recommendation based on different viewpoints, clearly explain the reasoning behind this integration.
373
+
##6. Appendix & References
374
+
List the data sources, analysis methods, important formulas, or chart descriptions used.
375
+
All references must come from the information extraction agent and the company financial data table provided, or publicly noted sources.
376
+
For differentiated viewpoints, provide full citation information (author, institution, date) and present this in a table.
377
+
</report_structure_requirements>
378
+
379
+
380
+
<output_requirements>
381
+
Language Style: Financial, professional, precise, and analytical.
382
+
Viewpoint Retention: When there are multiple viewpoints and conclusions, all must be retained and compared. You cannot choose only one.
383
+
Citations: When specific data or viewpoints are referenced, include the source in parentheses (e.g., Source: Morgan Stanley Research, 2024-05-07).
384
+
Facts: All data and conclusions must come from the information extraction agent or their noted legitimate sources. No fabrication is allowed.
385
+
Readability: Use short paragraphs and bullet points to make it easy for professional readers to grasp key information and see the differences in viewpoints.
386
+
</output_requirements>
387
+
388
+
389
+
<output_goal>
390
+
Generate a complete investment research report that meets investment banking industry standards, which can be directly used for institutional investment internal reference, while faithfully retaining differentiated viewpoints from various reports and providing the corresponding analysis.
391
+
</output_goal>
392
+
393
+
394
+
395
+
<heading_format_requirements>
396
+
All section headings in the investment research report must be formatted as N. Section Title (e.g., 1. Summary, 2. Company Overview), where:
397
+
The heading number is followed by a period and the section title.
398
+
The entire heading (number, period, and title) is rendered in bold text (e.g., using <b> in HTML or equivalent bold formatting, without relying on Markdown ** syntax).
399
+
Do not use ##, **, or any other prefix before the heading number.
400
+
Apply this format consistently to all section headings (Summary, Company Overview, Recent Financial Performance, Industry Trends & Opportunities, Investment Recommendation, Appendix & References).
401
+
</heading_format_requirements>
402
+
```
403
+
404
+
## 2.6 Add a Reply Message Node
405
+
406
+
The reply message node is used to output the "financial statements" and "research report content" that are the final outputs of the workflow.
407
+
408
+

409
+
410
+
## 2.7 Save and Test
411
+
412
+
Click "Save" - "Run" - and view the execution results.
413
+
The entire process takes approximately 5 minutes to run.
414
+
Execution Results:
415
+
416
+

417
+
418
+
Log:
419
+
The entire process took approximately 5 minutes to run.
420
+
421
+

250
422
251
423
# Summary and Outlook
252
424
425
+
This case study has constructed a complete workflow for stock research reports using RAGFlow, encompassing three core steps:
426
+
427
+
1. Utilizing an Agent node to extract stock codes from user inputs.
428
+
2. Acquiring and formatting company financial data through Yahoo Finance tools and Code nodes to generate clear financial statements.
429
+
3. Invoking information extraction agents and an internal research report retrieval agent, and using a research report generation agent to output the latest research report insights and the full text of complete research reports, respectively.
430
+
431
+
The entire process achieves automated handling from stock code identification to the integration of financial and research report information.
432
+
433
+
We observe several directions for sustainable development: More data sources can be incorporated to make analytical results more comprehensive, while providing a code-free method for data processing to lower the barrier to entry. The system also has the potential to analyze multiple companies within the same industry, track industry trends, and even cover a wider range of investment instruments such as futures and funds, thereby assisting analysts in forming superior investment portfolios. As these features are gradually implemented, the intelligent investment research assistant will not only help analysts make quicker judgments but also establish an efficient and reusable research methodology, enabling the team to consistently produce high-quality analytical outputs.
0 commit comments