EmbeddedAndrew commited on
Commit
b86230c
·
1 Parent(s): f86b5db

system prompt

Browse files
Files changed (2) hide show
  1. README.md +5 -2
  2. app.py +37 -3
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
- title: Dev
3
- emoji: 🔥
4
  colorFrom: blue
5
  colorTo: blue
6
  sdk: streamlit
@@ -10,4 +10,7 @@ pinned: false
10
  license: mit
11
  ---
12
 
 
 
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Research Questions
3
+ emoji: 📚
4
  colorFrom: blue
5
  colorTo: blue
6
  sdk: streamlit
 
10
  license: mit
11
  ---
12
 
13
+
14
+ A simple app to provide students feedback on their research questions.
15
+
16
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -4,10 +4,16 @@
4
 
5
  from langchain.callbacks.base import BaseCallbackHandler
6
  from langchain.chat_models import ChatOpenAI
7
- from langchain.schema import HumanMessage
8
  import streamlit as st
9
  import os
10
 
 
 
 
 
 
 
11
 
12
  class StreamHandler(BaseCallbackHandler):
13
  def __init__(self, container, initial_text="", display_method='markdown'):
@@ -54,16 +60,44 @@ def check_password():
54
 
55
 
56
 
 
 
57
  if check_password():
 
58
  query = st.text_input("Input your research question", value="How do biases in AI student evaluations compare to documented biases in human evaluations?")
59
  ask_button = st.button("ask")
60
 
61
  st.markdown("### GPT-3.5 response")
62
  chat_box = st.empty()
63
  stream_handler = StreamHandler(chat_box, display_method='write')
64
- chat = ChatOpenAI(max_tokens=25, streaming=True, callbacks=[stream_handler])
65
 
 
66
  #st.markdown("### together box")
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  if query and ask_button:
69
- response = chat([HumanMessage(content=query)])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  from langchain.callbacks.base import BaseCallbackHandler
6
  from langchain.chat_models import ChatOpenAI
7
+ from langchain.schema import HumanMessage, SystemMessage
8
  import streamlit as st
9
  import os
10
 
11
+ # from langchain.prompts.chat import (
12
+ # ChatPromptTemplate,
13
+ # SystemMessagePromptTemplate,
14
+ # HumanMessagePromptTemplate,
15
+ # )
16
+
17
 
18
  class StreamHandler(BaseCallbackHandler):
19
  def __init__(self, container, initial_text="", display_method='markdown'):
 
60
 
61
 
62
 
63
+
64
+
65
  if check_password():
66
+ st.markdown("Get instant feedback on your research question")
67
  query = st.text_input("Input your research question", value="How do biases in AI student evaluations compare to documented biases in human evaluations?")
68
  ask_button = st.button("ask")
69
 
70
  st.markdown("### GPT-3.5 response")
71
  chat_box = st.empty()
72
  stream_handler = StreamHandler(chat_box, display_method='write')
73
+ chat = ChatOpenAI(max_tokens=5000, streaming=True, callbacks=[stream_handler])
74
 
75
+ query_combined = "Please provide constructive feedback in English on this proposed research question, suggesting how it might be improved: <research_question>" + query + "</research_question>."
76
  #st.markdown("### together box")
77
+ messages = [
78
+ SystemMessage(
79
+ content="""You are a helpful research assistant that provides feedback to university students and researchers on their ideas for a research question, \
80
+ in particular for Masters students planning to write a Master's Thesis. A good research question should be narrow enough that it can be well-addressed in a 20-30 page \
81
+ literature review, and provides guidance to focus the literature review, and points towards specific areas of scientific literature that should be included. A good research question also provides guidance on the methodological (empirical) approach needed to answer the question. """
82
+ ),
83
+ HumanMessage(
84
+ content=query_combined
85
+ ),
86
+ ]
87
+ =
88
 
89
  if query and ask_button:
90
+ response = chat(messages) # [HumanMessage(content=query)])
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+