Skip to content

Commit e5adce2

Browse files
authored
Merge pull request #1074 from kga245/feature/add-tone-argument
Feature/add tone argument
2 parents e074659 + cf8a84e commit e5adce2

File tree

2 files changed

+59
-8
lines changed

2 files changed

+59
-8
lines changed

cli.py

+36-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from dotenv import load_dotenv
1818

1919
from gpt_researcher import GPTResearcher
20-
from gpt_researcher.utils.enum import ReportType
20+
from gpt_researcher.utils.enum import ReportType, Tone
2121
from backend.report_type import DetailedReport
2222

2323
# =============================================================================
@@ -64,6 +64,19 @@
6464
choices=choices,
6565
required=True)
6666

67+
# First, let's see what values are actually in the Tone enum
68+
print([t.value for t in Tone])
69+
70+
cli.add_argument(
71+
"--tone",
72+
type=str,
73+
help="The tone of the report (optional).",
74+
choices=["objective", "formal", "analytical", "persuasive", "informative",
75+
"explanatory", "descriptive", "critical", "comparative", "speculative",
76+
"reflective", "narrative", "humorous", "optimistic", "pessimistic"],
77+
default="objective"
78+
)
79+
6780
# =============================================================================
6881
# Main
6982
# =============================================================================
@@ -83,9 +96,30 @@ async def main(args):
8396

8497
report = await detailed_report.run()
8598
else:
99+
# Convert the simple keyword to the full Tone enum value
100+
tone_map = {
101+
"objective": Tone.Objective,
102+
"formal": Tone.Formal,
103+
"analytical": Tone.Analytical,
104+
"persuasive": Tone.Persuasive,
105+
"informative": Tone.Informative,
106+
"explanatory": Tone.Explanatory,
107+
"descriptive": Tone.Descriptive,
108+
"critical": Tone.Critical,
109+
"comparative": Tone.Comparative,
110+
"speculative": Tone.Speculative,
111+
"reflective": Tone.Reflective,
112+
"narrative": Tone.Narrative,
113+
"humorous": Tone.Humorous,
114+
"optimistic": Tone.Optimistic,
115+
"pessimistic": Tone.Pessimistic
116+
}
117+
86118
researcher = GPTResearcher(
87119
query=args.query,
88-
report_type=args.report_type)
120+
report_type=args.report_type,
121+
tone=tone_map[args.tone]
122+
)
89123

90124
await researcher.conduct_research()
91125

docs/docs/gpt-researcher/getting-started/cli.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This command-line interface (CLI) tool allows you to generate research reports u
2323
The basic syntax for using the CLI is:
2424

2525
```
26-
python cli.py "<query>" --report_type <report_type>
26+
python cli.py "<query>" --report_type <report_type> [--tone <tone>]
2727
```
2828

2929
### Arguments
@@ -36,6 +36,22 @@ python cli.py "<query>" --report_type <report_type>
3636
- `outline_report`
3737
- `custom_report`
3838
- `subtopic_report`
39+
- `--tone` (optional): The tone of the report. Defaults to 'objective'. Options include:
40+
- `objective`: Impartial and unbiased presentation
41+
- `formal`: Academic standards with sophisticated language
42+
- `analytical`: Critical evaluation and examination
43+
- `persuasive`: Convincing viewpoint
44+
- `informative`: Clear and comprehensive information
45+
- `explanatory`: Clarifying complex concepts
46+
- `descriptive`: Detailed depiction
47+
- `critical`: Judging validity and relevance
48+
- `comparative`: Juxtaposing different theories
49+
- `speculative`: Exploring hypotheses
50+
- `reflective`: Personal insights
51+
- `narrative`: Story-based presentation
52+
- `humorous`: Light-hearted and engaging
53+
- `optimistic`: Highlighting positive aspects
54+
- `pessimistic`: Focusing on challenges
3955

4056
## Examples
4157

@@ -44,14 +60,14 @@ python cli.py "<query>" --report_type <report_type>
4460
python cli.py "What are the main causes of climate change?" --report_type research_report
4561
```
4662

47-
2. Create a detailed report on artificial intelligence:
63+
2. Create a detailed report on artificial intelligence with an analytical tone:
4864
```
49-
python cli.py "The impact of artificial intelligence on job markets" --report_type detailed_report
65+
python cli.py "The impact of artificial intelligence on job markets" --report_type detailed_report --tone analytical
5066
```
5167

52-
3. Generate an outline report on renewable energy:
68+
3. Generate an outline report on renewable energy with a persuasive tone:
5369
```
54-
python cli.py "Renewable energy sources and their potential" --report_type outline_report
70+
python cli.py "Renewable energy sources and their potential" --report_type outline_report --tone persuasive
5571
```
5672

5773
## Output
@@ -61,4 +77,5 @@ The generated report will be saved as a Markdown file in the `outputs` directory
6177
## Note
6278

6379
- The execution time may vary depending on the complexity of the query and the type of report requested.
64-
- Make sure you have the necessary API keys and permissions set up in your `.env` file for the tool to function correctly.
80+
- Make sure you have the necessary API keys and permissions set up in your `.env` file for the tool to function correctly.
81+
- All tone options should be provided in lowercase.

0 commit comments

Comments
 (0)