ezelikman / parsel Goto Github PK
View Code? Open in Web Editor NEWCode for Parsel ๐ - generate complex programs with language models
Code for Parsel ๐ - generate complex programs with language models
On the following input (calc_no_tests_no_args.ss):
given a string containing numbers and operators in reverse polish notation, calculate the result. The expression is given as a list of numbers and operators. Each number may be one of the following: integer, float. You can assume that the expression is always valid.
I get the following backtrace:
python3 parsel.py ./programs/calc_no_tests_no_args.ss -g -n
python3 parsel.py ./programs/calc_no_tests_no_args.ss -g -n
Added args: ['rpn_calculator(expression)', 'stack = []', 'for item in expression:', 'if is_number(item):', 'stack.append(item)', 'else:', 'stack.append(apply_operator(item, stack.pop(), stack.pop()))', 'return stack.pop()']
Added args: ['calculate_rpn(expression)', 'stack = []', 'for item in expression:', "if item in '+-*/':", 'b = stack.pop()', 'a = stack.pop()', 'stack.append(eval(a + item + b))', 'else:', 'stack.append(item)', 'return stack[0]']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for item in expression:', 'if is_number(item):', 'stack.append(item)', 'else:', 'stack.append(apply_operator(item, stack.pop(), stack.pop()))', 'return stack.pop()']
Added args: ['rpn(expression)', 'stack = []', 'for item in expression:', "if item in ['+', '-', '*', '/']:", 'a = stack.pop()', 'b = stack.pop()', "if item == '+':", 'stack.append(a + b)', "elif item == '-':", 'stack.append(a - b)', "elif item == '*':", 'stack.append(a * b)', "elif item == '/':", 'stack.append(a / b)', 'else:', 'stack.append(item)', 'return stack.pop()']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for i in expression:', "if i in ['+', '-', '*', '/']:", 'a = stack.pop()', 'b = stack.pop()', "if i == '+':", 'stack.append(a + b)', "elif i == '-':", 'stack.append(b - a)', "elif i == '*':", 'stack.append(a * b)', "elif i == '/':", 'stack.append(b / a)', 'else:', 'stack.append(i)', 'return stack.pop()']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for i in expression:', "if i in ['+', '-', '*', '/']:", 'a = stack.pop()', 'b = stack.pop()', "if i == '+':", 'stack.append(a + b)', "elif i == '-':", 'stack.append(a - b)', "elif i == '*':", 'stack.append(a * b)', "elif i == '/':", 'stack.append(a / b)', 'else:', 'stack.append(i)', 'return stack.pop()']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for element in expression:', "if element in ['+', '-', '*', '/']:", 'a = stack.pop()', 'b = stack.pop()', "if element == '+':", 'stack.append(a + b)', "elif element == '-':", 'stack.append(a - b)', "elif element == '*':", 'stack.append(a * b)', "elif element == '/':", 'stack.append(a / b)', 'else:', 'stack.append(element)', 'return stack.pop()']
Added args: ['rpn_calculator(expression)', 'stack = []', 'for element in expression:', 'if is_number(element):', 'stack.append(element)', 'else:', 'b = stack.pop()', 'a = stack.pop()', 'stack.append(apply_operator(element, a, b))', 'return stack.pop()']
Traceback (most recent call last):
File "/Users/haldar/parsel/parsel.py", line 650, in <module>
parsel(codegen, args.source_file, allow_autofill=args.allow_autofill, should_expand=args.allow_expand, debug=debug, add_name_and_args=args.add_name_and_args)
File "/Users/haldar/parsel/parsel.py", line 617, in parsel
_, defined_fns = get_graph(program)
File "/Users/haldar/parsel/graph.py", line 42, in get_graph
for cur_line in program:
TypeError: 'NoneType' object is not iterable
The Lean and VirtualHome tests as outlined in the README do not run by simply changing the mode in __init__.py
.
Implementing SCC 0 {'select_airport_cities'}
Implementing SCC 1 {'sky_city_cost'}
Trying 8 completions
Calling Codex!
8 completions 500 tokens each
Error The model: `code-davinci-002` does not exist
Trying 16 completions
Calling Codex!
8 completions 500 tokens each
Error The model: `code-davinci-002` does not exist
Trying 32 completions
Calling Codex!
8 completions 500 tokens each
Error The model: `code-davinci-002` does not exist
Trying 64 completions
Calling Codex!
8 completions 500 tokens each
Error The model: `code-davinci-002` does not exist
Traceback (most recent call last):
File "/content/parsel/parsel.py", line 650, in <module>
parsel(codegen, args.source_file, allow_autofill=args.allow_autofill, should_expand=args.allow_expand, debug=debug, add_name_and_args=args.add_name_and_args)
File "/content/parsel/parsel.py", line 622, in parsel
defined_fns = parsel_graph(defined_fns, codegen, allow_autofill, should_expand, debug)
File "/content/parsel/parsel.py", line 590, in parsel_graph
implement_scc(scc_idx, sccs, implemented_sccs, scc_edges, defined_fns, codegen, allow_autofill, should_expand, debug, sample_only)
File "/content/parsel/parsel.py", line 496, in implement_scc
dependencies_str += implement_scc(edge, sccs, implemented_sccs, scc_edges, defined_fns, codegen, allow_autofill, should_expand, debug)
File "/content/parsel/parsel.py", line 537, in implement_scc
raise error
File "/content/parsel/parsel.py", line 506, in implement_scc
fn.implement(codegen, num_completions=num_completions)
File "/content/parsel/fn.py", line 103, in implement
self.implementations = codex.generate(
File "/content/parsel/codex.py", line 70, in generate
completions = openai.Completion.create(
File "/usr/local/lib/python3.10/dist-packages/openai/api_resources/completion.py", line 25, in create
return super().create(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py", line 230, in request
resp, got_stream = self._interpret_response(result, stream)
File "/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py", line 624, in _interpret_response
self._interpret_response_line(
File "/usr/local/lib/python3.10/dist-packages/openai/api_requestor.py", line 687, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: The model: `code-davinci-002` does not exist
I logged in and tried to run the cell with command !python3 parsel.py programs/problem_solving.ss
I did something like:
cleanLines = []
with open('requirements.txt', 'r') as req_file:
for line in req_file:
cline = line.split('==')[0].strip()
print(line.split('==')[0].strip())
cleanLines.append(cline)
with open('requirements_clean.txt', 'w') as newFile:
for line in cleanLines:
newFile.write(f'{line}\n')
but deleted the 3 anaconda packages since I have miniconda they seemed redundant and now get stuck on colorama
Collecting colorama
Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
ERROR: Could not find a version that satisfies the requirement conda (from versions: 3.0.6, 3.5.0, 3.7.0, 3.17.0, 4.0.0, 4.0.1, 4.0.2, 4.0.3, 4.0.4, 4.0.5, 4.0.7, 4.0.8, 4.0.9, 4.1.2, 4.1.6, 4.2.6, 4.2.7, 4.3.13, 4.3.16)
ERROR: No matching distribution found for conda
Could you push a more "generic" requirements.txt with the minimal packages needed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.