wendru18 commited on
Commit
5838cbb
·
0 Parent(s):

first commit

Browse files
Files changed (2) hide show
  1. README.md +12 -0
  2. main.ipynb +70 -0
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ask-reddit-gpt
2
+
3
+ AskRedditGPT is a tool that takes in a query, sends it over to Reddit, and returns an answer based on data from the relevant posts and comments found in Reddit.
4
+
5
+ ## Methodology
6
+
7
+ 1. Take in query $q$ from user.
8
+ 2. Get $N$ topics from $q$ using GPT.
9
+ 3. Determine $S$, which is a set of subreddits best-suited to answer $N$ topics.
10
+ 4. Search $q \in S$.
11
+ 5. Retrieve a set of segments that can answer $q$.
12
+ 6. Summarise segments using GPT and return answer to user.
main.ipynb ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 30,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import pandas as pd\n",
10
+ "import praw\n",
11
+ "import os\n",
12
+ "\n",
13
+ "pd.set_option('max_colwidth', 100)\n",
14
+ "pd.set_option('display.max_columns', None)"
15
+ ]
16
+ },
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": 1,
20
+ "metadata": {},
21
+ "outputs": [],
22
+ "source": [
23
+ "REDDIT_CLIENT_ID = os.environ.get('REDDIT_CLIENT_ID')\n",
24
+ "REDDIT_CLIENT_SECRET = os.environ.get('REDDIT_CLIENT_SECRET')\n",
25
+ "REDDIT_USER_AGENT = os.environ.get('REDDIT_USER_AGENT')\n",
26
+ "\n",
27
+ "reddit = praw.Reddit(client_id=REDDIT_CLIENT_ID, client_secret=REDDIT_CLIENT_SECRET, user_agent=REDDIT_USER_AGENT)"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "code",
32
+ "execution_count": 233,
33
+ "metadata": {},
34
+ "outputs": [],
35
+ "source": [
36
+ "posts = []\n",
37
+ "comments = []\n",
38
+ "\n",
39
+ "query = \"Which place sells the best pastizzis in Malta?\"\n",
40
+ "\n",
41
+ "for post in reddit.subreddit(\"all\").search(\"Malta cuisine\", limit=200):\n",
42
+ " posts.append([post.title, post.subreddit, post.selftext, post.created])\n",
43
+ "\n",
44
+ "posts = pd.DataFrame(posts,columns=['title', 'subreddit', 'text', 'created'])"
45
+ ]
46
+ }
47
+ ],
48
+ "metadata": {
49
+ "kernelspec": {
50
+ "display_name": "Python 3",
51
+ "language": "python",
52
+ "name": "python3"
53
+ },
54
+ "language_info": {
55
+ "codemirror_mode": {
56
+ "name": "ipython",
57
+ "version": 3
58
+ },
59
+ "file_extension": ".py",
60
+ "mimetype": "text/x-python",
61
+ "name": "python",
62
+ "nbconvert_exporter": "python",
63
+ "pygments_lexer": "ipython3",
64
+ "version": "3.8.0"
65
+ },
66
+ "orig_nbformat": 4
67
+ },
68
+ "nbformat": 4,
69
+ "nbformat_minor": 2
70
+ }