Skip to content

Commit 8f14888

Browse files
committed
Update 024 Bots - Building an OpenAI Twitter News Bot with Python.ipynb
1 parent 4bd997c commit 8f14888

File tree

1 file changed

+11
-44
lines changed

1 file changed

+11
-44
lines changed

08 Natural Language Processing/024 Bots - Building an OpenAI Twitter News Bot with Python.ipynb

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,57 +25,24 @@
2525
"import requests\n",
2626
"import random\n",
2727
"\n",
28-
"# # Set API Keys and Authentification\n",
29-
"# logging.info('Setting NewsAPI API Key')\n",
30-
"# NEWSAPI_API_KEY = <your API key> # replace with own API key\n",
28+
"# Set API Keys and Authentification\n",
29+
"logging.info('Setting NewsAPI API Key')\n",
30+
"NEWSAPI_API_KEY = <your API key> # replace with own API key\n",
3131
"\n",
32-
"# logging.info('Setting OpenAI API Key')\n",
33-
"# openai.api_key = <your API key> # replace with own API key\n",
32+
"logging.info('Setting OpenAI API Key')\n",
33+
"openai.api_key = <your API key> # replace with own API key\n",
3434
"\n",
35-
"# logging.info('Setting Twitter API Key')\n",
36-
"# auth=tweepy.OAuthHandler(<your API key>,\n",
37-
"# <your API secret>)\n",
38-
"# auth.set_access_token(<your access token>,\n",
39-
"# <your access secret>)\n",
40-
"# twitter_api=tweepy.API(auth)\n",
35+
"logging.info('Setting Twitter API Key')\n",
36+
"auth=tweepy.OAuthHandler(<your API key>,\n",
37+
" <your API secret>)\n",
38+
"auth.set_access_token(<your access token>,\n",
39+
" <your access secret>)\n",
40+
"twitter_api=tweepy.API(auth)\n",
4141
"\n",
4242
"CSV_NEWS_NAME = 'news_log.csv'\n",
4343
"CSV_FACTS_NAME = 'facts_log.csv'"
4444
]
4545
},
46-
{
47-
"cell_type": "code",
48-
"execution_count": 61,
49-
"metadata": {},
50-
"outputs": [],
51-
"source": [
52-
"from azure.identity import AzureCliCredential\n",
53-
"from azure.keyvault.secrets import SecretClient\n",
54-
"import tweepy\n",
55-
"from azure.storage.blob import BlobServiceClient\n",
56-
"import io\n",
57-
"import pandas as pd\n",
58-
"import openai\n",
59-
"\n",
60-
"\n",
61-
"# Set up the Azure Key Vault client and retrieve the Blob Storage account credentials\n",
62-
"keyvault_name = 'keyvaultforbot'\n",
63-
"client = SecretClient(f\"https://{keyvault_name}.vault.azure.net/\", AzureCliCredential())\n",
64-
"NEWSAPI_API_KEY = client.get_secret('newsapi-api-key').value\n",
65-
"#### Twitter Auth\n",
66-
"def twitter_auth():\n",
67-
" auth=tweepy.OAuthHandler(client.get_secret('twitter-api-key').value,\n",
68-
" client.get_secret('twitter-api-secret').value)\n",
69-
" auth.set_access_token(client.get_secret('twitter-access-token').value,\n",
70-
" client.get_secret('twitter-access-secret').value)\n",
71-
" twitter_api=tweepy.API(auth)\n",
72-
" logging.info('Twitter API ready')\n",
73-
" return twitter_api\n",
74-
"\n",
75-
"##### OpenAI API Key\n",
76-
"openai.api_key = client.get_secret('openai-api-key').value"
77-
]
78-
},
7946
{
8047
"attachments": {},
8148
"cell_type": "markdown",

0 commit comments

Comments
 (0)