Skip to content

Latest commit

 

History

History
79 lines (40 loc) · 2.48 KB

README.md

File metadata and controls

79 lines (40 loc) · 2.48 KB

OpenAI and FastAPI - Text summarization

This text summarizer is a web based frontend for summarising (Cyber Threat Intelligence]() (CTI) reports. It uses OpenAI's GPT-3.5 and GPT-4 API to generate meaningful summaries for management as well as for extracting IP addresses, domains, URLs, hashes etc from a CTI report.

However, if this task is not what you need, you can also give it another system prompt as well. GPT-3.5 and GPT-4 are so flexible.

One of the main benefits of using the API is that, according to OpenAI's documentation, they delete the queries after some time and don't use it for training the next models. See here and here.

Input:

Example of a (public) Blog CTI blog post

Output:

Example a GPT4 generated summary

This code is losely based on Oikosohn's openai quickstart fastapi repo, which in turn was based on openai-quickstart-python.

It uses the OpenAI API quickstart tutorial and the FastAPI web framework.

With prompt engineering, we ask openai's gpt-4 model to summarize a CTI text for upper management.

Note: you will have to get your own API key for this.

Setup

  1. First make a copy of the example environment variables file

    # Linux
    $ cp env.example .env
    # Windows
    xcopy .env.example .env
  2. Add your API key to the newly created .env file Note: when coding, you might want to not send a request to openai for every page reload. In that case, set DRY_RUN=1 in .env.

  3. Then build the image:

docker build -t openai-summarizer:0.1 . --network=host

(The .env file will be copied into the image as well)

  1. Run the dockerized app

    $  docker compose up -d

You should now be able to access the app at http://localhost:9999!

Reference

License

This code is released under the EUPL license 1.2