RickyIG commited on
Commit
f1bc138
·
1 Parent(s): 68c3199

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -3,7 +3,7 @@ import openai
3
  import sys
4
 
5
  import gradio as gr
6
-
7
  import json
8
  import requests
9
  from tenacity import retry, wait_random_exponential, stop_after_attempt
@@ -12,6 +12,21 @@ from tenacity import retry, wait_random_exponential, stop_after_attempt
12
  GPT_MODEL = "gpt-3.5-turbo-1106"
13
  openai.api_key = os.environ['OPENAI_API_KEY']
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Now let's define the function specification:
16
  functions = [
17
  {
@@ -151,22 +166,6 @@ def first_call(init_prompt, user_input):
151
  # Let's see what we got back before continuing
152
  return assistant_message, cost1
153
 
154
- from IPython import get_ipython
155
-
156
- def exec_python(cell):
157
- ipython = get_ipython()
158
- result = ipython.run_cell(cell)
159
- log = str(result.result)
160
- if result.error_before_exec is not None:
161
- log += f"\n{result.error_before_exec}"
162
- if result.error_in_exec is not None:
163
- log += f"\n{result.error_in_exec}"
164
- prompt = """You are a genius math tutor, Python code expert, and a helpful assistant.
165
- answer = {ans}
166
-
167
- Please answer user questions very well with explanations and match it with the multiple choices question.
168
- """.format(ans = log)
169
- return log
170
 
171
  def second_prompt_build(prompt, log):
172
  prompt_second = prompt.format(ans = log)
 
3
  import sys
4
 
5
  import gradio as gr
6
+ from IPython import get_ipython
7
  import json
8
  import requests
9
  from tenacity import retry, wait_random_exponential, stop_after_attempt
 
12
  GPT_MODEL = "gpt-3.5-turbo-1106"
13
  openai.api_key = os.environ['OPENAI_API_KEY']
14
 
15
+ def exec_python(cell):
16
+ ipython = get_ipython()
17
+ result = ipython.run_cell(cell)
18
+ log = str(result.result)
19
+ if result.error_before_exec is not None:
20
+ log += f"\n{result.error_before_exec}"
21
+ if result.error_in_exec is not None:
22
+ log += f"\n{result.error_in_exec}"
23
+ prompt = """You are a genius math tutor, Python code expert, and a helpful assistant.
24
+ answer = {ans}
25
+
26
+ Please answer user questions very well with explanations and match it with the multiple choices question.
27
+ """.format(ans = log)
28
+ return log
29
+
30
  # Now let's define the function specification:
31
  functions = [
32
  {
 
166
  # Let's see what we got back before continuing
167
  return assistant_message, cost1
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
  def second_prompt_build(prompt, log):
171
  prompt_second = prompt.format(ans = log)