im commited on
Commit
6f0fc7c
·
1 Parent(s): e719624

change intro screen, agents returns links to sources

Browse files
Files changed (3) hide show
  1. agent.py +2 -1
  2. app.py +20 -6
  3. socratic.py +1 -1
agent.py CHANGED
@@ -17,13 +17,14 @@ class Agent:
17
  tool.handle_tool_error = _handle_error
18
  self._tools = tools
19
  system_message = SystemMessage(
20
- content="You are a web researcher who uses search engines to look up information.")
21
  prompt = OpenAIFunctionsAgent.create_prompt(system_message=system_message)
22
  agent = OpenAIFunctionsAgent(llm=llm, tools=tools, prompt=prompt)
23
  self.agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, max_iterations=max_iterations)
24
 
25
  def run(self, query):
26
  try:
 
27
  return self.agent_executor.run(query)
28
  except Exception as e:
29
  msg = f"Agent encounter an error.\n\n Error: {str(e)}"
 
17
  tool.handle_tool_error = _handle_error
18
  self._tools = tools
19
  system_message = SystemMessage(
20
+ content="You are a web researcher who uses search engines to look up information and list references to sources.")
21
  prompt = OpenAIFunctionsAgent.create_prompt(system_message=system_message)
22
  agent = OpenAIFunctionsAgent(llm=llm, tools=tools, prompt=prompt)
23
  self.agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, max_iterations=max_iterations)
24
 
25
  def run(self, query):
26
  try:
27
+ query = query + [" Along with your answer, return a list of markdown formated references to the sources used in following format: <example>[^1]: [name](link)</example>"]
28
  return self.agent_executor.run(query)
29
  except Exception as e:
30
  msg = f"Agent encounter an error.\n\n Error: {str(e)}"
app.py CHANGED
@@ -5,8 +5,9 @@ from agent import Agent
5
  from common import get_llm
6
  import sys
7
  import time
 
8
 
9
- logging.basicConfig(stream=sys.stdout, level=logging.INFO)
10
 
11
  # --- APPLICATION ---
12
 
@@ -40,7 +41,7 @@ def init_session() -> None:
40
 
41
 
42
  def get_random_question():
43
- return "What is the size of the Moon?"
44
 
45
 
46
  def show_intro_screen():
@@ -49,11 +50,9 @@ def show_intro_screen():
49
  description = """\
50
  You ask, 'What's the meaning of life?' and our trio of digital philosophers fetch real-time
51
  wisdom faster than you can say 'Immanuel Kant.' Whether you’re curious about science, or even the nuances of
52
- modern art, Soratiq has you covered. Your feedback shapes the conversation, making it an educational journey
53
- tailored just for you. So why settle for small talk? Dive into Soratiq today and elevate your discourse!
54
  """
55
  st.caption(description)
56
- st.divider()
57
 
58
  if st.session_state.question is None:
59
  question = st.text_input(label='Paste your question. E.g. "What is the size of the moon?"',
@@ -70,6 +69,21 @@ def show_intro_screen():
70
  if col2.button(label="QuestionRoll", help="The button generates a random question for the user to ponder or discuss. This should be a fun and engaging experience, sparking curiosity."):
71
  question = get_random_question()
72
  set_user_question(question)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  else:
74
  if st.session_state.question is not None:
75
  st.subheader(f"*{st.session_state.question}*")
@@ -213,4 +227,4 @@ if __name__ == "__main__":
213
 
214
  # TODO: publish/access dialog debug logs, so the user can dig into the details
215
  # TODO: possible answers to the question - like 'double check your answer' or 'make the answer sound like a pirate' etc
216
- # TODO: return sources used by the agent - explicitly publish them in the dialog
 
5
  from common import get_llm
6
  import sys
7
  import time
8
+ import random
9
 
10
+ logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
11
 
12
  # --- APPLICATION ---
13
 
 
41
 
42
 
43
  def get_random_question():
44
+ return "What is the size of the Moon?" if random.randint(1,10) % 3 == 0 else "What is love?"
45
 
46
 
47
  def show_intro_screen():
 
50
  description = """\
51
  You ask, 'What's the meaning of life?' and our trio of digital philosophers fetch real-time
52
  wisdom faster than you can say 'Immanuel Kant.' Whether you’re curious about science, or even the nuances of
53
+ modern art, Soratiq has you covered.
 
54
  """
55
  st.caption(description)
 
56
 
57
  if st.session_state.question is None:
58
  question = st.text_input(label='Paste your question. E.g. "What is the size of the moon?"',
 
69
  if col2.button(label="QuestionRoll", help="The button generates a random question for the user to ponder or discuss. This should be a fun and engaging experience, sparking curiosity."):
70
  question = get_random_question()
71
  set_user_question(question)
72
+
73
+ st.divider()
74
+ with st.expander("Who are they? What's going on?"):
75
+ st.markdown("""\
76
+ Imagine you've just stepped into an intellectual arena that's as engaging as a top-tier debate club and as lively as your favorite coffeehouse. Like the brainstorming session you've always dreamed of.
77
+ - First up, **you're the Maestro**. With a simple thumbs-up or down, you steer this conversation, helping to sculpt the dialogue into something meaningful. Your feedback is the compass.
78
+
79
+ - Next, we have **Socrates and Theaetetus**, your co-pilots in this philosophical flight. They serve up questions designed to delve deep into the core of the matter.
80
+
81
+ - **Plato's on board too**, adding a layer of logical critique to ensure our dialogue doesn't go off the rails.
82
+
83
+ - Finally, meet the **Agent**, our whiz at rapid information retrieval. This isn't just Googling; think of it as real-time fact-checking with a dash of AI brilliance, you'd think it had a Ph.D. in Searchology.
84
+
85
+ Try `QuestionRoll` and get a random question to watch how it goes. [More details](https://princeton-nlp.github.io/SocraticAI/)
86
+ """)
87
  else:
88
  if st.session_state.question is not None:
89
  st.subheader(f"*{st.session_state.question}*")
 
227
 
228
  # TODO: publish/access dialog debug logs, so the user can dig into the details
229
  # TODO: possible answers to the question - like 'double check your answer' or 'make the answer sound like a pirate' etc
230
+ # TODO: get rid of autogenerated 'Footnote' header in agent's references
socratic.py CHANGED
@@ -49,7 +49,7 @@ class SocraticGPT:
49
  Immediately provide the answer if nobody has objections to the solution. If they encounter any issues with the validity of their answer, they should re-evaluate their reasoning and calculations. Before providing the final answer, every participant has to accept the solution or reject it with a clear explaination. Do not provide the answer if someone has reasonable objections to it.
50
  The final answer should begin with the phrase: <answer>insert your answer</answer>.
51
 
52
- The dialog must be formatted using Markdown.
53
 
54
  The problem statement is as follows: ''' {question} '''.
55
  """
 
49
  Immediately provide the answer if nobody has objections to the solution. If they encounter any issues with the validity of their answer, they should re-evaluate their reasoning and calculations. Before providing the final answer, every participant has to accept the solution or reject it with a clear explaination. Do not provide the answer if someone has reasonable objections to it.
50
  The final answer should begin with the phrase: <answer>insert your answer</answer>.
51
 
52
+ The dialog answers must be markdown formatted.
53
 
54
  The problem statement is as follows: ''' {question} '''.
55
  """