@@ -35,32 +35,40 @@ def ax_query(self, query, cell=None):
35
35
if self .api_key :
36
36
if cell :
37
37
# REFINE
38
- ...
39
- ipython = get_ipython ()
40
- last_cell = ipython .history_manager .input_hist_parsed [- 1 ]
41
- print (f"Last executed cell:\n { last_cell } " )
42
38
feedback = "" # TODO: add feedback according to interface
43
39
result = self .ax .pic .refine (query = query , code = cell , feedback = feedback )
44
40
else :
45
41
# GENERATE FROM SCRATCH
46
42
result = self .ax .pic .generate (query = query )
47
43
48
- display (HTML (result .thought_text ))
49
-
50
- try :
51
- # When running in colab
52
- from google .colab import _frontend # type: ignore
53
-
54
- _frontend .create_scratch_cell (
55
- f"""# { query } \n { result .code } """ , bottom_pane = True
56
- )
57
- except Exception as e :
58
- # When running in jupyter
59
- get_ipython ().set_next_input (f"{ result .code } " , replace = False )
44
+ # Process output
45
+ output = result .thought_text .replace ("\n " , "<br>" )
46
+ html_content = (
47
+ "<div style='font-family: Arial, sans-serif; line-height: 1.5;'>"
48
+ )
49
+ html_content += (
50
+ f"<div style='color: #6EB700;'><strong>AX:</strong> { output } </div>"
51
+ )
52
+ display (HTML (html_content ))
53
+
54
+ # Process code
55
+ # remove last three lines (saving file)
56
+ if result .code :
57
+ code = "\n " .join (result .code .split ("\n " )[:- 3 ] + ["c" ])
58
+ try :
59
+ # When running in colab
60
+ from google .colab import _frontend # type: ignore
61
+
62
+ _frontend .create_scratch_cell (
63
+ f"""# { query } \n { code } """ , bottom_pane = True
64
+ )
65
+ except Exception as e :
66
+ # When running in jupyter
67
+ get_ipython ().set_next_input (f"{ code } " , replace = False )
60
68
61
69
else :
62
70
print (
63
- "Please set your Axiomatic API key first with the command %ax_api API_KEY. Request the api key at our Customer Service."
71
+ "Please set your Axiomatic API key first with the command %ax_api API_KEY and restart the kernel . Request the api key at our Customer Service."
64
72
)
65
73
66
74
def ax_fix (self , query , cell = None ):
0 commit comments