dhuynh95 commited on
Commit
f848c2c
1 Parent(s): 35efbd8

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +69 -0
  2. original_huberman.csv +130 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import time
4
+ import openai
5
+
6
+ from llama_index import StorageContext, load_index_from_storage
7
+ import os
8
+
9
+ import pandas as pd
10
+
11
+ openai.api_key = os.getenv("OPENAI_API_KEY")
12
+ passwd = os.getenv("PASSWD_SECRET")
13
+
14
+ df = pd.read_csv("original_huberman.csv")
15
+
16
+ storage_context = StorageContext.from_defaults(persist_dir="./storage")
17
+ # load index
18
+ index = load_index_from_storage(storage_context)
19
+
20
+ query_engine = index.as_query_engine(similarity_top_k=4)
21
+
22
+ def get_podcast_and_youtube(response):
23
+ podcasts = []
24
+ for node in response.source_nodes:
25
+ podcast = node.node.extra_info["filename"].split("/")[-1].split(".")[0]
26
+ podcasts.append(podcast)
27
+
28
+ mask = df.podcast.apply(lambda x: x in podcasts)
29
+ return df.loc[mask]
30
+
31
+ with gr.Blocks() as demo:
32
+ gr.Markdown("<h1><center>HuberChat</center></h1>")
33
+ gr.Markdown("<p align='center'><img src='https://yt3.googleusercontent.com/5ONImZvpa9_hYK12Xek2E2JLzRc732DWsZMX2F-AZ1cTutTQLBuAmcEtFwrCgypqJncl5HrV2w=s900-c-k-c0x00ffffff-no-rj' height='50' width='95'></p>")
34
+ gr.Markdown("<p align='center' style='font-size: 20px;'>Hi! I am Andrew HuberChat, a chatbot trained to answer neurobiology.</p>")
35
+ with gr.Row().style():
36
+ with gr.Column(scale=0.85):
37
+ msg = gr.Textbox(
38
+ show_label=False,
39
+ placeholder="Enter text and press enter. The url must contain the media type. e.g, https://example.com/example.jpg",
40
+ lines=1,
41
+ ).style(container=False)
42
+ with gr.Column(scale=0.15, min_width=0):
43
+ btn2 = gr.Button("Send").style(full_height=True)
44
+ gr.Examples(
45
+ examples=["What is love?",
46
+ "Why should I get sunlight exposure?",
47
+ "How to be more motivated?"
48
+ ],
49
+ inputs=msg
50
+ )
51
+ chatbot = gr.Chatbot().style(height=250)
52
+
53
+ clear = gr.Button("Clear")
54
+
55
+ def respond(message, chat_history):
56
+ response = query_engine.query(message)
57
+ bot_message = response.response
58
+ for i, row in get_podcast_and_youtube(response).iterrows():
59
+ bot_message += f"\n\n\n Source: {row.podcast} \n\n Link: {row.youtube_id}"
60
+ chat_history.append((message, bot_message))
61
+ time.sleep(1)
62
+ return "", chat_history
63
+
64
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
65
+ btn2.click(respond, [msg, chatbot], [msg, chatbot])
66
+ clear.click(lambda: None, None, chatbot, queue=False)
67
+
68
+ if __name__ == "__main__":
69
+ demo.launch(auth=("mithril", passwd))
original_huberman.csv ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,podcast,youtube_id
2
+ 0,how-psilocybin-can-rewire-our-brain-its-therapeutic-benefits-and-its-risks,https://www.youtube.com/watch?v=eIxVfln02Ss
3
+ 1,dr-noam-sobel-how-smells-influence-our-hormones-health-and-behavior,https://youtu.be/cS7cNaBrkxo
4
+ 2,science-based-mental-training-and-visualization-for-improved-learning,https://youtu.be/0RYyQRQFgFk
5
+ 3,dr-matthew-macdougall-neuralink-and-technologies-to-enhance-human-brains,https://youtu.be/3ZGItIAUQmI
6
+ 4,the-science-of-healthy-hair-hair-loss-and-how-to-regrow-hair,https://youtu.be/6ZrlsVx85ek
7
+ 5,dr-elissa-epel-control-stress-for-healthy-eating-metabolism-and-aging,https://youtu.be/ulHrUVV3Kq4
8
+ 6,leverage-dopamine-to-overcome-procrastination-and-optimize-effort,https://youtu.be/K-TW2Chpz4k
9
+ 7,dr-peter-attia-improve-vitality-emotional-and-physical-health-and-lifespan,https://youtu.be/ufsIA5NARIo
10
+ 8,dr-satchin-panda-intermittent-fasting-to-improve-health-cognition-and-longevity,https://youtu.be/7R3-3HR6-u4
11
+ 9,how-to-optimize-your-water-quality-and-intake-for-health,https://youtu.be/at37Y8rKDlA
12
+ 10,dr-oded-rechavi-genes-and-the-inheritance-of-memories-across-generations,https://youtu.be/CDUetQMKM6g
13
+ 11,dr-andy-galpin-optimal-nutrition-and-supplementation-for-fitness,https://youtu.be/q37ARYnRDGc
14
+ 12,how-to-breathe-correctly-for-optimal-health-mood-learning-and-performance,https://youtu.be/x4m_PdFbu-s
15
+ 13,guest-series-dr-andy-galpin-maximize-recovery-to-achieve-fitness-and-performance-goals,https://youtu.be/juD99_sPWGU
16
+ 14,dr-gina-poe-use-sleep-to-enhance-learning-memory-and-emotional-state,https://youtu.be/BMTt8gSl13s
17
+ 15,dr-andy-galpin-optimize-your-training-program-for-fitness-and-longevity,https://youtu.be/UIy-WQCZd4M
18
+ 16,how-to-stop-headaches-using-science-based-approaches,https://youtu.be/CGjdgy0cwGk
19
+ 17,dr-andy-galpin-how-to-build-physical-endurance-and-lose-fat,https://youtu.be/oNkDA2F7CjM
20
+ 18,dr-sara-gottfried-how-to-optimize-female-hormone-health-for-vitality-and-longevity,https://youtu.be/GVRDGQhoEYQ
21
+ 19,dr-andy-galpin-optimal-protocols-to-build-strength-and-grow-muscles,https://youtu.be/CyDLbrZK75U
22
+ 20,how-to-optimize-fertility-in-males-and-females,https://youtu.be/O1YRwWmue4Y
23
+ 21,dr-andy-galpin-how-to-assess-improve-all-aspects-of-your-fitness,https://youtu.be/zEYE-vcVKy8
24
+ 22,rick-rubin-how-to-access-your-creativity,https://youtu.be/ycOBZZeVeAc
25
+ 23,developing-a-rational-approach-to-supplementation-for-health-and-performance,https://youtu.be/tLS6t3FVOTI
26
+ 24,dr-sam-harris-using-meditation-to-focus-view-consciousness-and-expand-your-mind,https://youtu.be/-wIt_WsJGfw
27
+ 25,jocko-willink-how-to-become-resilient-forge-your-identity-and-lead-others,https://youtu.be/__RAXBLt1iM
28
+ 26,the-science-of-creativity-and-how-to-enhance-creative-innovation,https://youtu.be/KPlJcD-o-4Q
29
+ 27,dr-kyle-gillett-tools-for-hormone-optimization-in-males,https://youtu.be/O640yAgq5f8
30
+ 28,using-caffeine-to-optimize-mental-and-physical-performance,https://youtu.be/iw97uvIge7c
31
+ 29,dr-lex-fridman-navigating-conflict-finding-purpose-and-maintaining-drive,https://youtu.be/6I5I56uVvLw
32
+ 30,dr-chris-palmer-diet-nutrition-for-mental-health,https://youtu.be/xjEFo3a1AnI
33
+ 31,science-based-tools-for-increasing-happiness,https://youtu.be/LTGGyQS1fZE
34
+ 32,dr-layne-norton-the-science-of-eating-for-health-fat-loss-and-lean-muscle,https://youtu.be/K4Ze-Sp6aUE
35
+ 33,how-meditation-works-and-science-based-effective-meditations,https://youtu.be/wTBSGgbIvsY
36
+ 34,dr-eddie-chang-the-science-of-learning-and-speaking-languages,https://youtu.be/Z7MU6zrAXsM
37
+ 35,fitness-toolkit-protocol-and-tools-to-optimize-physical-health,https://youtu.be/q1Ss8sTbFBY
38
+ 36,dr-nolan-williams-psychedelics-and-neurostimulation-for-brain-rewiring,https://youtu.be/X4QE6t-MkYE
39
+ 37,the-effects-of-cannabis-marijuana-on-the-brain-and-body,https://youtu.be/gXvuJu1kt48
40
+ 38,dr-casey-halpern-biology-and-treatments-for-compulsive-eating-and-behaviors,https://www.youtube.com/watch?v=Nr5xb-QCBGA
41
+ 39,nicotines-effects-on-the-brain-and-body-and-how-to-quit-smoking-or-vaping,https://youtu.be/uXs-zPc63kM
42
+ 40,dr-david-anderson-the-biology-of-aggression-mating-and-arousal,https://youtu.be/uxZFl4BDOGk
43
+ 41,focus-toolkit-tools-to-improve-your-focus-and-concentration,https://youtu.be/yb5zpo5WDG4
44
+ 42,dr-erich-jarvis-the-neuroscience-of-speech-language-and-music,https://youtu.be/LVxL_p_kToc
45
+ 43,what-alcohol-does-to-your-body-brain-health,https://youtu.be/DkS1pkKpILY
46
+ 44,dr-peter-attia-exercise-nutrition-hormones-for-vitality-and-longevity,https://youtu.be/DTCmprPCDqc
47
+ 45,sleep-toolkit-tools-for-optimizing-sleep-and-sleep-wake-timing,https://youtu.be/h2aWYjSA1Jc
48
+ 46,dr-emily-balcetis-tools-for-setting-and-achieving-goals,https://www.youtube.com/watch?v=7YGZZcXqKxE
49
+ 47,the-science-and-treatment-of-bipolar-disorder,https://www.youtube.com/watch?v=m_OazsImOiI
50
+ 48,dr-charles-zuker-the-biology-of-taste-perception-and-sugar-craving,https://youtu.be/UChhXiFPRgg
51
+ 49,optimize-and-control-your-brain-chemistry-to-improve-health-and-performance,https://www.youtube.com/watch?v=T65RDBiB5Hs
52
+ 50,jeff-cavaliere-optimize-your-exercise-program-with-science-based-tools,https://youtu.be/UNCwdFxPtE8
53
+ 51,the-science-and-treatment-of-obsessive-compulsive-disorder,https://youtu.be/OadokY8fcAA
54
+ 52,ido-portal-the-science-and-practice-of-movement,https://youtu.be/a9yFKPmPZ90
55
+ 53,improve-flexibility-with-research-supported-stretching-protocols,https://youtu.be/tkH2-_jMCSk
56
+ 54,dr-paul-conti-therapy-treating-trauma-and-other-life-challenges,https://youtu.be/IOl28gj_RXw
57
+ 55,the-science-and-process-of-healing-from-grief,https://www.youtube.com/watch?v=dzOvi0Aa2EA
58
+ 56,dr-wendy-suzuki-boost-attention-and-memory-with-science-based-tools,https://youtu.be/099hgtRoUZw
59
+ 57,understand-and-improve-memory-using-science-based-tools,https://youtu.be/szqPAPKE5tQ
60
+ 58,understanding-and-controlling-aggression,https://youtu.be/RBK5KLA5Jjg
61
+ 59,dr-rhonda-patrick-micronutrients-for-health-and-longevity,https://youtu.be/XcvhERcZpWw
62
+ 60,the-science-and-health-benefits-of-deliberate-heat-exposure,https://youtu.be/EQ3GjpGq5Y8
63
+ 61,using-light-sunlight-blue-light-and-red-light-to-optimize-health,https://youtu.be/UF0nqolsNZc
64
+ 62,how-to-optimize-your-hormones-for-health-and-vitality,https://youtu.be/ncSoor2Iw8k
65
+ 63,using-deliberate-cold-exposure-for-health-and-performance,https://youtu.be/pq6WHJzOkno
66
+ 64,dr-andy-galpin-how-to-build-strength-muscle-size-and-endurance,https://youtu.be/IAnhFUUCq6c
67
+ 65,controlling-sugar-cravings-and-metabolism-with-science-based-tools,https://youtu.be/VAEzZeaV5zM
68
+ 66,using-salt-to-optimize-mental-and-physical-performance,https://youtu.be/azb3Ih68awQ
69
+ 67,dr-justin-sonnenburg-how-to-build-maintain-and-repair-gut-health,https://youtu.be/ouCWNRvPk20
70
+ 68,how-to-enhance-your-gut-microbiome-for-brain-and-overall-health,https://youtu.be/15R2pMqU2ok
71
+ 69,dr-david-spiegel-using-hypnosis-to-enhance-mental-and-physical-health-and-performance,https://youtu.be/PctD-ki8dCc
72
+ 70,the-science-of-love-desire-and-attachment,https://youtu.be/gMRph_BvHB4
73
+ 71,using-play-to-rewire-and-improve-your-brain,https://youtu.be/BwyZIWeBpRw
74
+ 72,optimizing-workspace-for-productivity-focus-and-creativity,https://youtu.be/Ze2pc6NwsHQ
75
+ 73,dr-alia-crum-science-of-mindsets-for-health-performance,https://youtu.be/dFR_wFN23ZY
76
+ 74,the-science-of-setting-and-achieving-goals,https://youtu.be/t1F7EEGPQwo
77
+ 75,dr-jack-feldman-breathing-for-mental-physical-health-and-performance,https://youtu.be/GLgKkG44MGo
78
+ 76,the-science-of-making-and-breaking-habits,https://youtu.be/Wcs2PFz5q6g
79
+ 77,dr-david-sinclair-the-biology-of-slowing-and-reversing-aging,https://youtu.be/n9IxomBusuw
80
+ 78,science-of-social-bonding-in-family-friendship-and-romantic-love,https://youtu.be/RgAcOqVRfYA
81
+ 79,dr-david-berson-your-brains-logic-and-function,https://youtu.be/oC3fhUjg30E
82
+ 80,erasing-fears-and-traumas-based-on-the-modern-neuroscience-of-fear,https://youtu.be/31wjVhCcI5Y
83
+ 81,dr-david-buss-how-humans-select-and-keep-romantic-partners-in-short-and-long-term,https://youtu.be/HXzTbCEqCJc
84
+ 82,the-science-of-gratitude-and-how-to-build-a-gratitude-practice,https://youtu.be/KVjfFN89qvQ
85
+ 83,time-perception-and-entrainment-by-dopamine-serotonin-and-hormones,https://youtu.be/8IWDAqodDas
86
+ 84,dr-duncan-french-how-to-exercise-for-strength-gains-and-hormone-optimization,https://youtu.be/iMvtHqLmEkI
87
+ 85,using-your-nervous-system-to-enhance-your-immune-system,https://youtu.be/poOf8b2WE2g
88
+ 86,dr-samer-hattar-timing-light-food-exercise-for-better-sleep-energy-mood,https://youtu.be/oUu3f0ETMJQ
89
+ 87,nutrients-for-brain-health-and-performance,https://youtu.be/E7W4OQfJWdw
90
+ 88,effects-of-fasting-and-time-restricted-eating-on-fat-loss-and-health,https://youtu.be/9tRohh0gErM
91
+ 89,dr-craig-heller-using-temperature-for-performance-brain-and-body-health,https://youtu.be/77CdVSpnUX4
92
+ 90,controlling-your-dopamine-for-motivation-focus-and-satisfaction,https://youtu.be/QmOF0crdyRU
93
+ 91,dr-matthew-johnson-psychedelic-medicine,https://youtu.be/GzvzWO0NU50
94
+ 92,adhd-and-how-anyone-can-improve-their-focus,https://youtu.be/hFL6qRIJZ_Y
95
+ 93,healthy-eating-and-eating-disorders-anorexia-bulimia-binging,https://youtu.be/2XGREPnlI8U
96
+ 94,dr-robert-sapolsky-science-of-stress-testosterone-and-free-will,https://youtu.be/DtmwtjOoSYU
97
+ 95,understanding-and-conquering-depression,https://youtu.be/Xu1FMCxoEFc
98
+ 96,dr-anna-lembke-understanding-and-treating-addiction,https://youtu.be/p3JLaF_4Tz8
99
+ 97,how-to-control-your-sense-of-pain-and-pleasure,https://youtu.be/xmhsWAqP_0Y
100
+ 98,dr-matthew-walker-the-science-and-practice-of-perfecting-your-sleep,https://youtu.be/gbQFSMayJxk
101
+ 99,how-to-optimize-your-brain-body-function-and-health,https://youtu.be/rW9QKc-iFoY
102
+ 100,dr-lex-fridman-machines-creativity-and-love,https://youtu.be/VRvn3Oj5r3E
103
+ 101,maximizing-productivity-physical-and-mental-health-with-daily-tools,https://youtu.be/aXvDEmo6uS4
104
+ 102,the-science-of-hearing-balance-and-accelerated-learning,https://youtu.be/JVRyzYB9JSY
105
+ 103,karl-deisseroth-understanding-and-healing-the-mind,https://youtu.be/w9MXqXBZy9U
106
+ 104,how-smell-taste-and-pheromone-like-chemicals-control-you,https://youtu.be/Mwz8JprPeMc
107
+ 105,the-science-of-vision-eye-health-and-seeing-better,https://youtu.be/ObtW353d5i0
108
+ 106,how-to-build-endurance-in-your-brain-and-body,https://youtu.be/VQLU7gpk_X8
109
+ 107,science-of-muscle-growth-increasing-strength-and-muscular-recovery,https://youtu.be/XLr2RKoD-oY
110
+ 108,how-to-lose-fat-with-science-based-tools,https://youtu.be/GqPGXG5TlZw
111
+ 109,how-to-learn-skills-faster,https://youtu.be/xJ0IBzCjEPk
112
+ 110,supercharge-exercise-performance-and-recovery-with-cooling,https://youtu.be/xaE9XyMMAHY
113
+ 111,using-cortisol-and-adrenaline-to-boost-our-energy-and-immune-system,https://youtu.be/JPX8g8ibKFc
114
+ 112,how-to-control-your-metabolism-by-thyroid-and-growth-hormone,https://youtu.be/x7qbJeRxWGw
115
+ 113,how-our-hormones-control-our-hunger-eating-and-satiety,https://youtu.be/17O5mgXZ9ZU
116
+ 114,the-science-of-how-to-optimize-testosterone-and-estrogen,https://youtu.be/qJXKhu5UZwk
117
+ 115,biological-influences-on-sex-sex-differences-and-preferences,https://youtu.be/J7SrAEacyf8
118
+ 116,the-science-of-emotions-relationships,https://youtu.be/hcuMLQVAgEg
119
+ 117,how-to-increase-motivation-and-drive,https://youtu.be/vA50EK70whE
120
+ 118,how-foods-and-nutrients-control-our-moods,https://youtu.be/XfURDjegrAw
121
+ 119,tools-for-managing-stress-and-anxiety,https://youtu.be/ntfcfJ28eiU
122
+ 120,control-pain-and-heal-faster-with-your-brain,https://youtu.be/mcPSRWUYCv0
123
+ 121,optimize-your-learning-and-creativity-with-science-based-tools,https://youtu.be/uuP-1ioh4LY
124
+ 122,using-failures-movement-and-balance-to-learn-faster,https://youtu.be/hx3U64IXFOY
125
+ 123,how-to-focus-to-change-your-brain,https://youtu.be/LG53Vxum0as
126
+ 124,understanding-and-using-dreams-to-learn-and-to-forget,https://youtu.be/FFwA0QFmpQ4
127
+ 125,find-your-temperature-minimum-to-defeat-jetlag-shift-work-and-sleeplessness,https://youtu.be/NAATB55oxeQ
128
+ 126,using-science-to-optimize-sleep-learning-and-metabolism,https://youtu.be/nwSkFq4tyC0
129
+ 127,master-your-sleep-and-be-more-alert-when-awake,https://youtu.be/nm1TxQj9IsQ
130
+ 128,how-your-nervous-system-works-and-changes,https://youtu.be/H-XfCl-HpRM
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==3.28.3
2
+ llama_index==0.6.2
3
+ openai==0.27.6
4
+ pandas==2.0.1