Some ideas on the probable future of journalism facing IA and how to create a prompt facilitation application for ChatGPT with Streamlit

After a careful reading of this report on the possible and probable future of journalism, it was time to build a roadmap of achievements regarding the concrete proposals formulated in the study.

You can check the study “New powers, new responsibilities. A global survey of journalism and artificial intelligence”, by Charlie Beckett, Professor at the London School of Economics and Political Science and a summary that I made in French is also available at:
https://github.com/bflaven/new_powers_new_responsibilities_the_journalism_ai_report

You can find all files for each project on my GitHub account. See https://github.com/bflaven/ia_usages/tree/master/ai_chatgpt_prompts

1. Basic understanding on IA strategy: In-House or Outsourced: Which IA Solution is Best for Your Business?

Personally, I rarely deal with strategy. Rather, I define a specific actions plan coupled with objectives and I stick to it. Not hesitating to pivot or change direction when circumstances dictate. This is a personal interpretation of “Test early, Test often; Fail fast, Fail cheap.”.

So, regarding IA, I have schematized in an overly simplistic way 2 IA applicable approach:

  1. Tinkering: To create an almost internal solution from scratch with some do it yourself with the help of open-source solutions and free ressources.
  2. Outsourcing: To create a full external solution, leveraging on paid APIs available and with seasoned developers help.

Well, mostly, the truth stands in between these two scenarios according to the projects and objectives you want to achieve!

Last thing, I hear a lot of people around me talking about AI strategy or IA trends, as if the AI’s emergence was going to happen in the future, a kind of dystopia. But it is here and now! As always, it often hides fear, lack of reflection, will postpone to later rather than a turn to action or strategic thinking. To me, a sophisticated way of procrastination, to lull oneself into comfortable and reassuring illusions. To paraphrase a quote from Jim Rohn about happiness, I will say that:

“IA is not something you postpone for the future; it is something you design for the present.”

In a sense, the AI’s phenomenon is certainly a technological advance but also a powerful indicator of everyone’s ability to reinvent themselves.

Personally, actions carry values. Regarding AI, it only remains for me to go all the way again from reflection to design rather than wallowing into intellectual idleness.

As a first conclusion, of course there are financial argument and that related to competence and training, but it is often the cultural resistance to change that is the main obstacle to AI’s adoption (Cf. Growth mindset vs Fixed Mindset).

A precision, more political
Nevertheless, I can add a small precision. Precision that goes far beyond the scope of this post. Far from any controversial will, in a sense, I can nevertheless accept this “cultural resistance” if it is backed by political beliefs. Indeed, this “IA’s fear” can be explained by the fact that everyone, professionally speaking, feels “condemned”, to be always more efficient like AI to respond to injunctions of modern capitalism: being both introspective and extrovert, being flexible and focused, being able to adapt and assert your uniqueness.

But let’s get back to practice, exploring the uses of AI to implement functionalities in the context of my work within a media for example!

2. What I learn on IA strategy from this report on futur of journalism?

Even though the study may be from 2019, the IA’s needs for journalism expressed are more relevant than ever! I sought also for more concrete ideas, partly to distance from the hype around the term “artificial intelligence”.

First of all, a basic definition that suit for anybody:

“Artificial intelligence is a collection of ideas, technologies, and techniques that relate to a computer system’s capacity to perform tasks normally requiring human intelligence.”

Some of these points may sound obvious, but it is always good, for your own sake, to hammer some of these truths especially to defeat the “cultural gap” or the “cultural resistance” from editorial teams.

The MVP’s approach applied to IA

First lesson that sounds like a “cliché”, but like often, the best approach adopted seems to be the MVP [Minimum Viable Product] iteration when it comes to AI.

A classical feedback loop approach, this means launching an early version of tools, getting feedback from its users, then rolling out new features and functionality, and then iterating on this feedback continuously.

A second lesson taken from the report: remember that “Trying to do too much usually results in something that fails at everything”. So, picking up 2 or 3 IA significant topics that are related to your sector then make an MVP for each idea and reap the benefits of it seems again to be the best approach.

Indeed mass, effective application of AI is new so most organisations will not be AI-ready. These organisations will have to build their knowledge, skills… and the designing 2 or 3 real projects remains the best opportunity to learn.

I have forged for myself this mantra :).

Adoption by usage is the ferment of IA literacy.

Avoid as much as possible a formal and overarching IA strategy that does not fit to any reality. No a priori strategy, the feedback from the actions carried out during the project’s realization will shape naturally the strategy.

In the report, many respondents reported confusion around roles and responsibilities. Several respondents argued that at early-stage adoption for AI it is better to have a series of approaches related to different AI applications, rather than a formal, overarching strategy.

  • (i) For IA, do not look for silver bullet solution
    It is all about digital transformation, AI will undoubtedly complete what is usually called “digital transformation” by “reshaping” this time not only the organization but the people who make up this organization. The transformation of the whole media industry has just really begun, and no-one has silver bullet on how to build and redefine organizational culture that can transform its core business and products to thrive in the new emerging AI-powered world.
  • (ii) For IA, cultivate an open mindset to “grapple with changes.
    Some of these media groups are familiar to challenges. The media industry has become used to grappling with change. AI is innately networked. It requires a skill set, knowledge base, defined roles, systematic appraisal, and a culture that relates the technologies to editorial or marketing. When fully integrated, pervasive, and operating at scale, AI could have high value in certain areas such as audience engagement, story discovery, and labour efficiency.

Nice forecasts but what concrete ideas can be sought and applied?

Well in a very pragmatic way, I have selected a shortlist of concepts and ideas that will build my “strategic roadmap”.

  • Concept #1: Among many of the best ideas that I have found in the report. I have selected the concept of “augmented journalism”. For me, it means to combine human editorial insights with AI. First, my unique aim will be to make this “augmented journalism” tangible.
  • Project #1: Explore the abilities given by ChatGPT to make journalists’ work more efficient. (Outsourcing)
  • Project #2: Create an automatic tagging/entity extraction. This Named-entity recognition (NER) system in Natural language processing (NLP) should be extended to any text documents among the company from support mails to news. (Tinkering)

For Project #2, I have made already several attempts available both on this Blog and on my GitHub account. Check the post “Extending Streamlit usage to create data science applications and other type of applications” at https://flaven.fr/2021/06/extending-streamlit-usage-to-create-data-science-applications-and-other-type-of-applications/

So, in this post, I will focus more on Project #1: Explore the abilities given by ChatGPT to make journalists’ work more efficient. (Outsourcing)

I have tried to use both Node and Python to explore ChatGPT API, but my preference goes to Python as it enables to implement many useful libraries such as Streamlit (UX), Spacy (NLP), Pandas and so on…. Choosing Python also gives also the opportunity to host Python apps on Azure to share them with users and give naturally a more homogeneous development environment “Python-centric”.

3. Alphabetization

Once for all, my purpose is always to provide users with seamless and powerful tools to work with. It is part of I have called “Alphabetization”. Alphabetization that brings proving tools according to usages instead of widening the cultural between IA and regular people who have just curiosity for it but no technical skills to explore.

That what seasoned tech engineers does not always understand! It is also mainly the reason I am choosing Streamlit so make the AI usages are lively available to anyone.

4. Selecting use cases for ChatGPT Prompts

For Chat GPT, I have chosen the following examples and made it available through Streamlit with the help of Python Class.

These multi purposes use case are both for Journalists (summary, tag extracting) or P.O (Product Owners) to explain code or ease Project Management.


# cases 3, 6, 9, 10, 11, 12, 17, 21, 22, 23, 39
3 :: Summarize for a 2nd grader
6 :: English to other languages
9 :: Parse unstructured data
10 :: Classification
11 :: Python to natural language
12 :: Movie to Emoji
17 :: Keywords
21 :: TL;DR summarization
22 :: Python bug fixer
23 :: Spreadsheet creator
39 :: Notes to summary

Most of the examples have been taken from the following source. It contains all the case studies available for Chat GPT.
Source: https://platform.openai.com/examples

4. Implementing ChatGPT Prompts use cases into Streamlit (project_3_streamlit)

You can find all files for each project on my GitHub account. See https://github.com/bflaven/ia_usages/tree/master/ai_chatgpt_prompts/project_3_streamlit

Let’s start with the most successful result in my opinion. Having selected a few use cases (see the list above), I wanted to be able to build a ChatGPT-Streamlit application that makes it easy to select and implement each of these ChatGPT examples.

So, this app kill several birds with one stone! Check 010_project_3_python_streamlit_app_chatgpt_api.py

This demonstrates through a POC the possible outsourcing strategy. The result must still doubtless be questioned. Indeed, basing its entire AI strategy on Chat GPT induces possible strategic threats in terms of independence and data security for any organization.

But it is concrete proof that many routine, repetitive, even thankless tasks or tasks beyond the cognitive abilities of humans will obviously be delegated or entrusted, under human supervision and validation, to AI while freeing at the same time working time for journalists (Tasks vs. Jobs). Example: the summary, tagging and indexing of hundreds of thousands of photo, video, or text documents.

  1. It explores concretely the abilities given by ChatGPT to make anyone’ work more efficient so that illustrating the concept of “augmented journalism” or even “augmented PO”.
  2. In a breeze, the Python Class created to execute ChatGPT prompts enables to add some examples taken from ChatGPT, that’s a heck of a time saving.

How-to manage the ChatGPT’s license (OPENAI_API_KEY) in Streamlit or Chainlit
The very first requirement to build up an app was to know how to manage the ChatGPT’s license (OPENAI_API_KEY) in Streamlit. Here is a quick tip on the existing 2 ways to handle the license:

  1. WAY_1: how-to manage the OPENAI_API_KEY
    In streamlit, this way to load the OPENAI_API_KEY value, use .env with the module python-dotenv and then it is easy to use the same for Chainlit.
  2. WAY_2: how-to manage the OPENAI_API_KEY
    In streamlit only, you can use a global config file name config.toml specific for your app.

I go for the WAY_1 for my POC but here is the how-to on the WAY_2.


# WAY_2: how-to manage the OPENAI_API_KEY

# 1.Create a folder within your director where you have the code name as ".streamlit"

mkdir .streamlit

# 2.Create a file name as "secrets.toml" under the folder ".streamlit"

cd .streamlit
touch secrets.toml

# See https://docs.streamlit.io/streamlit-community-cloud/get-started/deploy-an-app/connect-to-data-sources/secrets-management

# 3.Assign the key in the “ secrets.toml”

OPENAI_API_KEY = 'YOUR_OPENAI_API_KEY'
# See: https://docs.streamlit.io/library/advanced-features/configuration


# Everything is accessible via the st.secrets dict:

st.write("OPENAI_API_KEY:", st.secrets["OPENAI_API_KEY"])
st.write("DB password:", st.secrets["db_password"])
st.write("My cool secrets:", st.secrets["my_cool_secrets"]["things_i_like"])

# And the root-level secrets are also accessible as environment variables:

st.write(
"Has environment variables been set:",
os.environ["db_username"] == st.secrets["db_username"],
)

5. Documentation for ChatGPT API with Python (project_1_python_documentation_chatgpt_api)

You can find all files for each project on my GitHub account. See https://github.com/bflaven/ia_usages/tree/master/ai_chatgpt_prompts/project_1_python_documentation_chatgpt_api

A quick overview on how-to use ChatGPT API with Python with some important commands.


# MAIN INFOS REQUIRED
# Go to the path
cd /Users/brunoflaven/Documents/01_work/blog_articles/ai_chatgpt_prompts/project_1_python_documentation_chatgpt_api/

# python
pip install openai

# Do not forget to get your OPENAI_API_KEY
YOUR_OPENAI_API_KEY

# Option 1: OpenAI API not as environmental variable
# Option 2: OpenAI API as an environmental variable (recommended)


# WORKING WITH CURL
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer YOUR_OPENAI_API_KEY" \
-H "OpenAI-Organization: org-L2P-YOUR_OPENAI_ORGANIZATION"

6. Documentation for ChatGPT API with Node (project_2_node_documentation_chatgpt_api)


A quick overview on how-to use ChatGPT API with Node with some important commands.

You can find all files for each project on my GitHub account. See https://github.com/bflaven/ia_usages/tree/master/ai_chatgpt_prompts/project_2_node_documentation_chatgpt_api


# MAIN INFOS REQUIRED
# go to path
cd /Users/brunoflaven/Documents/01_work/blog_articles/ai_chatgpt_prompts/project_2_node_documentation_chatgpt_api/

# node
npm init
npm install openai

Source: https://community.openai.com/t/unable-to-receive-response-by-using-api-in-nodejs/21924
Source: https://github.com/topics/chatgpt3
Source: https://medium.com/codingthesmartway-com-blog/a-beginners-guide-to-integrating-chatgpt-with-node-js-9daf8557234

7. Attempt with Chainlit, serious competitor for Streamlit (project_4_chainlit)

A little python newcomer and a competitor for Streamlit to watch closely. Chainlist is dedicated to IA and to enable to quickly streamline your app building process.

You can find all files for each project on my GitHub account. See https://github.com/bflaven/ia_usages/tree/master/ai_chatgpt_prompts/project_4_chainlit

Videos

#1 ChatGPT with Streamlit: Two ways to manage the ChatGPT API KEY license with Streamlit with the .env & the secrets.toml file
Cypress

#2 ChatGPT with Streamlit: Leverage on ChatGPT examples with Python

#3 ChatGPT with Streamlit: In Streamlit, load with a Python Class all the ChatGPT examples

#4 ChatGPT with Node:

More infos