GianJSX commited on
Commit
1da5fb5
·
1 Parent(s): ae663ee

test code smith

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -1,6 +1,7 @@
1
  from AssistantService import GPTAssistant
2
  from openai.error import AuthenticationError
3
  import streamlit as st
 
4
  import configparser
5
  import os
6
 
@@ -66,7 +67,19 @@ if 'output_format' in st.session_state:
66
  st.write("Complete the API key field")
67
  except AuthenticationError:
68
  st.write("Invalid API key")
69
-
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  if 'code_generated' in st.session_state:
72
  python_function_label = st.write("Here is your python function:")
@@ -76,11 +89,5 @@ if 'code_generated' in st.session_state:
76
  if full_content and test_code:
77
  html_data = full_content
78
  result = None
79
- exec(st.session_state['code_generated_exec'], globals())
80
- if result:
81
- st.write("data extracted successfully")
82
- # show data in table
83
- st.table(result)
84
- else:
85
- st.write("error extracting data")
86
 
 
1
  from AssistantService import GPTAssistant
2
  from openai.error import AuthenticationError
3
  import streamlit as st
4
+ from langsmith.run_helpers import traceable
5
  import configparser
6
  import os
7
 
 
67
  st.write("Complete the API key field")
68
  except AuthenticationError:
69
  st.write("Invalid API key")
70
+
71
+ @traceable(run_type="tool")
72
+ def test_the_code(code, full_content):
73
+ exec(code, globals())
74
+ if result:
75
+ st.write("data extracted successfully")
76
+ # show data in table
77
+ st.table(result)
78
+ else:
79
+ st.write("error extracting data")
80
+
81
+ return result or "error"
82
+
83
 
84
  if 'code_generated' in st.session_state:
85
  python_function_label = st.write("Here is your python function:")
 
89
  if full_content and test_code:
90
  html_data = full_content
91
  result = None
92
+ test_the_code(st.session_state['code_generated_exec'], full_content=full_content)
 
 
 
 
 
 
93