add altair
Browse files
app.py
CHANGED
@@ -15,12 +15,13 @@ app = marimo.App(width="medium")
|
|
15 |
|
16 |
@app.cell(hide_code=True)
|
17 |
def __():
|
|
|
18 |
import textwrap
|
19 |
|
20 |
import ell
|
21 |
-
import os
|
22 |
-
import openai
|
23 |
import marimo as mo
|
|
|
|
|
24 |
return ell, mo, openai, os, textwrap
|
25 |
|
26 |
|
@@ -69,9 +70,7 @@ def __():
|
|
69 |
# so we first execute the previous statements
|
70 |
if len(stmts) > 1:
|
71 |
exec(
|
72 |
-
compile(
|
73 |
-
ast.Module(body=stmts[:-1]), filename="<ast>", mode="exec"
|
74 |
-
),
|
75 |
globals,
|
76 |
locals,
|
77 |
)
|
@@ -88,6 +87,7 @@ def __():
|
|
88 |
else:
|
89 |
# otherwise we just execute the entire code
|
90 |
return exec(script, globals, locals)
|
|
|
91 |
return (exec_with_result,)
|
92 |
|
93 |
|
@@ -96,7 +96,6 @@ def __(ell, exec_with_result, mo):
|
|
96 |
def code_fence(code):
|
97 |
return f"```python\n\n{code}\n\n```"
|
98 |
|
99 |
-
|
100 |
@ell.tool()
|
101 |
def execute_code(code: str):
|
102 |
"""
|
@@ -113,6 +112,7 @@ def __(ell, exec_with_result, mo):
|
|
113 |
code_fence(result if result is not None else output),
|
114 |
]
|
115 |
return mo.md("\n\n".join(results))
|
|
|
116 |
return code_fence, execute_code
|
117 |
|
118 |
|
@@ -128,12 +128,12 @@ def __(client, ell, execute_code, mo, model):
|
|
128 |
for message in messages
|
129 |
]
|
130 |
|
131 |
-
|
132 |
def my_model(messages, config):
|
133 |
response = custom_chatbot(messages, config)
|
134 |
if response.tool_calls:
|
135 |
return response.tool_calls[0]()
|
136 |
return mo.md(response.text)
|
|
|
137 |
return custom_chatbot, my_model
|
138 |
|
139 |
|
|
|
15 |
|
16 |
@app.cell(hide_code=True)
|
17 |
def __():
|
18 |
+
import os
|
19 |
import textwrap
|
20 |
|
21 |
import ell
|
|
|
|
|
22 |
import marimo as mo
|
23 |
+
import openai
|
24 |
+
|
25 |
return ell, mo, openai, os, textwrap
|
26 |
|
27 |
|
|
|
70 |
# so we first execute the previous statements
|
71 |
if len(stmts) > 1:
|
72 |
exec(
|
73 |
+
compile(ast.Module(body=stmts[:-1]), filename="<ast>", mode="exec"),
|
|
|
|
|
74 |
globals,
|
75 |
locals,
|
76 |
)
|
|
|
87 |
else:
|
88 |
# otherwise we just execute the entire code
|
89 |
return exec(script, globals, locals)
|
90 |
+
|
91 |
return (exec_with_result,)
|
92 |
|
93 |
|
|
|
96 |
def code_fence(code):
|
97 |
return f"```python\n\n{code}\n\n```"
|
98 |
|
|
|
99 |
@ell.tool()
|
100 |
def execute_code(code: str):
|
101 |
"""
|
|
|
112 |
code_fence(result if result is not None else output),
|
113 |
]
|
114 |
return mo.md("\n\n".join(results))
|
115 |
+
|
116 |
return code_fence, execute_code
|
117 |
|
118 |
|
|
|
128 |
for message in messages
|
129 |
]
|
130 |
|
|
|
131 |
def my_model(messages, config):
|
132 |
response = custom_chatbot(messages, config)
|
133 |
if response.tool_calls:
|
134 |
return response.tool_calls[0]()
|
135 |
return mo.md(response.text)
|
136 |
+
|
137 |
return custom_chatbot, my_model
|
138 |
|
139 |
|