Commit 94c564ec by nzy

Fix multiline input and show all codes to user

parent b464f74c
...@@ -108,7 +108,7 @@ black, blue, red, green, yellow, grey, pink, orange, teal, maroon = range(10) ...@@ -108,7 +108,7 @@ black, blue, red, green, yellow, grey, pink, orange, teal, maroon = range(10)
funs_list, queue = [], [name] funs_list, queue = [], [name]
while len(queue) != 0: while len(queue) != 0:
fun = queue.pop(0) fun = queue.pop(0)
if fun in self.funs: if (fun in self.funs) and (fun not in funs_list):
funs_list.append(fun) funs_list.append(fun)
queue.extend(name for name in self.funs[fun].dependencies) queue.extend(name for name in self.funs[fun].dependencies)
return funs_list return funs_list
...@@ -145,7 +145,7 @@ black, blue, red, green, yellow, grey, pink, orange, teal, maroon = range(10) ...@@ -145,7 +145,7 @@ black, blue, red, green, yellow, grey, pink, orange, teal, maroon = range(10)
return [f.name for f in self.funs.values() if not f.code] return [f.name for f in self.funs.values() if not f.code]
def user_known_funs(self) -> list[str]: def user_known_funs(self) -> list[str]:
return [f.name for f in self.funs.values() if f.code_from_user or f.prompt_from_user] return [f.name for f in self.funs.values()]
def to_python(self, name: Optional[str] = None, for_user=False) -> str: def to_python(self, name: Optional[str] = None, for_user=False) -> str:
funs_name = reversed(self.find_dependencies(name or self.entry)) funs_name = reversed(self.find_dependencies(name or self.entry))
......
...@@ -11,6 +11,7 @@ import openai ...@@ -11,6 +11,7 @@ import openai
import time import time
import os import os
import pickle import pickle
import sys
colors = ["#000000", "#0000FF", "#FF0000", "#008000", "#FFFF00", colors = ["#000000", "#0000FF", "#FF0000", "#008000", "#FFFF00",
"#808080", "#FFC0CB", "#FFA500", "#008080", "#800000"] "#808080", "#FFC0CB", "#FFA500", "#008080", "#800000"]
...@@ -60,12 +61,7 @@ def rich_dumps(obj): ...@@ -60,12 +61,7 @@ def rich_dumps(obj):
def multiline_input(): def multiline_input():
buffer = '' buffer = sys.stdin.read()
while True:
print("[blue]->[/blue]", end="")
line = input()
if not line: break
buffer += line + "\n"
return buffer return buffer
sys_str = "[bold red]SYSTEM: [/bold red]" sys_str = "[bold red]SYSTEM: [/bold red]"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment