Created
August 1, 2024 14:29
-
-
Save ybraz/42ed0dc734295e5dc02f33631c69f7cc to your computer and use it in GitHub Desktop.
Resumir notícias com GPT da OpenAI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from openai import OpenAI | |
| client = OpenAI(api_key=os.environ['OPENAI_API_KEY']) | |
| def chatgpt_summarize_and_translate(text): | |
| prompt = f""" | |
| Instrução: A partir de uma notícia de cybersegurança, gere um resumo conciso em um parágrafo e, em seguida, liste e explique as 5 principais ideias apresentadas na notícia, utilizando um emoticon para cada ideia, sempre em português do Brasil. | |
| Tom/Estilo: O resumo deve ser informativo e direto, sendo focado em um público extremamente técnico de especialistas em cybersegurança. | |
| Notícia: {text} | |
| """ | |
| completion = client.chat.completions.create( | |
| model="gpt-4o", | |
| messages=[ | |
| {"role": "system", "content": "Você é um engenheiro de cibersegurança especialista com aguçado senso crítico."}, | |
| {"role": "user", "content": prompt} | |
| ] | |
| ) | |
| return completion.choices[0].message.content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment