Spaces:
Build error
Build error
Commit
·
81862f9
1
Parent(s):
0460974
Improve formatting
Browse files- app.py +29 -1
- pinecone_utils.py +2 -0
app.py
CHANGED
|
@@ -7,6 +7,9 @@ ANSWER_TEMPLATE = """
|
|
| 7 |
<style>
|
| 8 |
.flex-container {{display: flex;}}
|
| 9 |
#info-card {{padding-left: 5px; overflow-y: auto; max-height: 200px;}}
|
|
|
|
|
|
|
|
|
|
| 10 |
</style>
|
| 11 |
<div class="flex-container">
|
| 12 |
<div id="img-card">
|
|
@@ -21,9 +24,34 @@ ANSWER_TEMPLATE = """
|
|
| 21 |
</div>
|
| 22 |
"""
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
# query = "How does Sam Harris manage his time?"
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
if len(question):
|
| 28 |
results = pinecone_utils.ask_pinecone(question=question)
|
| 29 |
|
|
|
|
| 7 |
<style>
|
| 8 |
.flex-container {{display: flex;}}
|
| 9 |
#info-card {{padding-left: 5px; overflow-y: auto; max-height: 200px;}}
|
| 10 |
+
h3 {{font-weight: 600; font-size: 1rem;}}
|
| 11 |
+
p {{font-weight: 400; font-size: 0.9rem;}}
|
| 12 |
+
p, h3 {{font-family: "Source Sans Pro", sans-serif; line-height: 1.6; color: rgb(49, 51, 63);}}
|
| 13 |
</style>
|
| 14 |
<div class="flex-container">
|
| 15 |
<div id="img-card">
|
|
|
|
| 24 |
</div>
|
| 25 |
"""
|
| 26 |
|
| 27 |
+
components.html(
|
| 28 |
+
"""<img style="display: block;margin-left: auto;margin-right: auto;" src="https://media0.giphy.com/media/4ei1ADTekyd9UkS3X1/giphy.gif?cid=ecf05e47yhyiaac31vpfhvellkdb6l13mfew5c91y2aheftk&rid=giphy.gif&ct=s" height="150">""",
|
| 29 |
+
height=150,
|
| 30 |
+
)
|
| 31 |
+
header = """
|
| 32 |
+
## Join in on your favourite conversation
|
| 33 |
+
|
| 34 |
+
Here's a chatGPT style model, that has access to transcripts of all Making Sense episodes.
|
| 35 |
+
You can either ask it a full question (such as `How did Twitter work with the FBI?`) or just keywords (`saint augustine free will`).
|
| 36 |
+
|
| 37 |
+
"""
|
| 38 |
+
|
| 39 |
+
st.markdown(header)
|
| 40 |
+
|
| 41 |
+
st.text("")
|
| 42 |
+
st.text("")
|
| 43 |
+
st.text("")
|
| 44 |
+
|
| 45 |
+
question = st.text_input(
|
| 46 |
+
"Ask Sam a question!",
|
| 47 |
+
value="Is solution to the risk of a nuclear war possible even in theory?",
|
| 48 |
+
)
|
| 49 |
# query = "How does Sam Harris manage his time?"
|
| 50 |
|
| 51 |
+
st.text("")
|
| 52 |
+
st.text("")
|
| 53 |
+
st.text("")
|
| 54 |
+
|
| 55 |
if len(question):
|
| 56 |
results = pinecone_utils.ask_pinecone(question=question)
|
| 57 |
|
pinecone_utils.py
CHANGED
|
@@ -2,6 +2,7 @@ import functools
|
|
| 2 |
import pinecone
|
| 3 |
import openai
|
| 4 |
import pandas as pd
|
|
|
|
| 5 |
|
| 6 |
from local_secrets import secrets
|
| 7 |
|
|
@@ -19,6 +20,7 @@ def _get_index() -> pinecone.Index:
|
|
| 19 |
return pinecone.Index("sense")
|
| 20 |
|
| 21 |
|
|
|
|
| 22 |
def ask_pinecone(question: str, max_results=20) -> list[dict]:
|
| 23 |
index = _get_index()
|
| 24 |
question_vec = openai.Embedding.create(input=question, engine=TARGET_MODEL)["data"][
|
|
|
|
| 2 |
import pinecone
|
| 3 |
import openai
|
| 4 |
import pandas as pd
|
| 5 |
+
import streamlit as st
|
| 6 |
|
| 7 |
from local_secrets import secrets
|
| 8 |
|
|
|
|
| 20 |
return pinecone.Index("sense")
|
| 21 |
|
| 22 |
|
| 23 |
+
@st.cache(show_spinner=False)
|
| 24 |
def ask_pinecone(question: str, max_results=20) -> list[dict]:
|
| 25 |
index = _get_index()
|
| 26 |
question_vec = openai.Embedding.create(input=question, engine=TARGET_MODEL)["data"][
|