Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
anpl4mc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ziyuan Nan
anpl4mc
Commits
f7a00c05
Commit
f7a00c05
authored
Oct 16, 2023
by
nzy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load content & remove duplicate exports statement
parent
2eb5805a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
anplc.py
+10
-1
lib.py
+2
-1
readme.md
+9
-2
No files found.
anplc.py
View file @
f7a00c05
...
...
@@ -5,6 +5,10 @@ import argparse
import
os
import
tempfile
import
asyncio
from
pathlib
import
Path
dest_lib
=
Path
(
"./descriptions"
)
fun_lib
=
Path
(
"./js"
)
def
doc_template
(
fun_name
):
return
f
"""
\
...
...
@@ -34,7 +38,12 @@ def input_content(content):
return
content
def
sketch
(
fun_name
):
code
=
input_content
(
sketch_template
(
fun_name
))
if
(
path
:
=
fun_lib
/
f
"{fun_name}.js"
)
.
exists
():
with
open
(
path
,
"r"
)
as
f
:
content
=
f
.
read
()
else
:
content
=
sketch_template
(
fun_name
)
code
=
input_content
(
content
)
create_sketch
(
fun_name
,
code
)
def
hole
(
fun_name
):
...
...
lib.py
View file @
f7a00c05
...
...
@@ -40,7 +40,8 @@ def create_sketch(fun_name, code):
for
hole
in
holes
:
final_code
.
append
(
f
"const {{ {hole} }} = require('./{hole}.js');"
)
final_code
.
append
(
code
)
final_code
.
append
(
f
"exports.{fun_name} = {fun_name};"
)
if
not
code
.
split
(
"
\n
"
)[
-
1
]
.
startswith
(
"exports"
):
final_code
.
append
(
f
"exports.{fun_name} = {fun_name};"
)
final_code
=
"
\n
"
.
join
(
final_code
)
with
open
(
fun_lib
/
f
"{fun_name}.js"
,
"w"
)
as
f
:
...
...
readme.md
View file @
f7a00c05
...
...
@@ -50,10 +50,17 @@ function test() {
### Import
生成的代码都在js文件夹中,可以使用一个repl bot调用,如目录下run.js所示。
### Debug
目前包含代码的合并。
对于
`sketch A`
,A依赖于
`hole [B, C]`
,如果想修改
`A`
的实现,可以直接
`python anplc.py sketch A`
。此时
`hole [B, C]`
已有的实现不会变化。
如果A中添加了新的
`hole D`
,则会创建
`hole D`
。
如果A中不再依赖一个
`hole C`
,目前需要手动删除A中的import语句,与js和description文件夹下的
`C.js C.json`
文件。
## Others
非windows系统下,请注释掉
`anplc.py`
第85行
`asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())`
此行为windows系统特有问题。
对于openai库的配置,请修改
`llm.py`
的开头,修改api_key与代理。
\ No newline at end of file
对于openai库的配置,请修改
`llm.py`
的开头,修改api_key与代理,更改模型在llm.py第51行的config中。
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment