Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,6 @@ from tenacity import retry, stop_after_attempt, wait_random_exponential
|
|
10 |
|
11 |
|
12 |
|
13 |
-
#df = pd.read_json('https://www.dropbox.com/scl/fi/uh964d1k6woc9wo3l2slc/dyf_w_embeddings.json?rlkey=j23j5338n4e88kvvsmj7s7aff&dl=1')
|
14 |
df = pd.read_json('rw7.json')
|
15 |
|
16 |
GPT_MODEL = 'gpt-3.5-turbo'
|
@@ -18,7 +17,7 @@ EMBEDDING_MODEL = "text-embedding-ada-002"
|
|
18 |
@retry(wait=wait_random_exponential(min=1, max=5), stop=stop_after_attempt(6))
|
19 |
def ask_naive(query):
|
20 |
messages = [
|
21 |
-
{"role": "system", "content": "You are a
|
22 |
{"role": "user", "content": query},
|
23 |
]
|
24 |
response = openai.ChatCompletion.create(
|
@@ -74,10 +73,10 @@ def build_resources(psuedo_answer):
|
|
74 |
@retry(wait=wait_random_exponential(min=1, max=5), stop=stop_after_attempt(6))
|
75 |
def respond(question, textbook_samples):
|
76 |
messages = [
|
77 |
-
{"role": "system", "content": "You are a college
|
78 |
{"role": "user", "content": f"""Use markdown and emphasize important phrases in bold. Respond to the following question: {question}.
|
79 |
|
80 |
-
When
|
81 |
{textbook_samples}
|
82 |
""" }
|
83 |
]
|
@@ -102,7 +101,7 @@ This app responds to your questions by looking up the most relevant selections f
|
|
102 |
'''
|
103 |
|
104 |
outro_text = '''
|
105 |
-
**Caveats:** Like all apps that employ large language models, this one has the
|
106 |
|
107 |
**Behind the Scenes**
|
108 |
|
@@ -121,7 +120,7 @@ block = gr.Blocks(theme = 'bethecloud/storj_theme')
|
|
121 |
|
122 |
with block:
|
123 |
gr.Markdown("# Ask the Sociology 101 Textbook")
|
124 |
-
gr.Markdown("![](rw_cover.jpg)
|
125 |
gr.Markdown(intro_text)
|
126 |
|
127 |
# Define the input and output blocks
|
|
|
10 |
|
11 |
|
12 |
|
|
|
13 |
df = pd.read_json('rw7.json')
|
14 |
|
15 |
GPT_MODEL = 'gpt-3.5-turbo'
|
|
|
17 |
@retry(wait=wait_random_exponential(min=1, max=5), stop=stop_after_attempt(6))
|
18 |
def ask_naive(query):
|
19 |
messages = [
|
20 |
+
{"role": "system", "content": "You are a college sociology professor. Provide a very brief answer to this student question."},
|
21 |
{"role": "user", "content": query},
|
22 |
]
|
23 |
response = openai.ChatCompletion.create(
|
|
|
73 |
@retry(wait=wait_random_exponential(min=1, max=5), stop=stop_after_attempt(6))
|
74 |
def respond(question, textbook_samples):
|
75 |
messages = [
|
76 |
+
{"role": "system", "content": "You are a college professor who excels at explaining topics to students. Start with a direct answer to the question. Then, definition/overview of the concept's essence; break it down into understandable pieces; use clear language and structure. Where appropriate, provide connections and comparisons to related terms. "},
|
77 |
{"role": "user", "content": f"""Use markdown and emphasize important phrases in bold. Respond to the following question: {question}.
|
78 |
|
79 |
+
When constructing the answer, use the following information from the textbook.
|
80 |
{textbook_samples}
|
81 |
""" }
|
82 |
]
|
|
|
101 |
'''
|
102 |
|
103 |
outro_text = '''
|
104 |
+
**Caveats:** Like all apps that employ large language models, this one has the possibility for bias and confabulation.
|
105 |
|
106 |
**Behind the Scenes**
|
107 |
|
|
|
120 |
|
121 |
with block:
|
122 |
gr.Markdown("# Ask the Sociology 101 Textbook")
|
123 |
+
gr.Markdown("![](https://huggingface.co/spaces/NealCaren/Ask101/resolve/main/rw_cover.jpg)
|
124 |
gr.Markdown(intro_text)
|
125 |
|
126 |
# Define the input and output blocks
|