This is a command-line tool that summarizes text content. It can take either a text file or a text string as input and returns the summary of the provided content. The tool leverages the Qwen-2-0.5B language model API for generating summaries.
- Python 3.8 or higher
requests
library (install viapip install requests
)argparse
library (included in Python standard library)
-
Clone this repository or download the
summarizer.py
script. -
Ensure you have Python 3.6 or higher installed.
-
Install the
requests
library if not already installed:pip install requests
The script can be used to summarize the content of a text file or a direct text string provided via the command line.
To summarize the content of a text file, use the -t
or --textfile
argument followed by the path to the text file:
python summarizer.py -t path/to/your/file.txt
To summarize a direct text string, use the -s
or --string
argument followed by the text string:
python summarizer.py -s "The quick brown fox jumped over the lazy dog."
Summarize a text file:
python summarizer.py -t example.txt
Summarize a text string:
python summarizer.py -s "Artificial intelligence is transforming the world."
send_prompt(content)
: Sends the provided content to the Qwen-2 model API to generate a summary.main()
: Parses command-line arguments, reads input (from a file or string), and prints the summary.
-t
or--textfile
: Specifies the path to the text file to be summarized.-s
or--string
: Specifies the text string to be summarized.
The script includes basic error handling for file not found errors and missing arguments.
The script is configured to send requests to a local server running at http://localhost:8000/api/chat
. Ensure the server is running and accessible before using the script.
- The Qwen-2 language model by Alibaba Cloud for text summarization capabilities.