Compare commits

5 Commits
main ... pdf

Author SHA1 Message Date
a1b75f0132 Update README.md 2023-07-19 11:01:47 +08:00
6605503e68 Merge branch 'pdf' of https://github.com/datawhalechina/prompt-engineering-for-developers into pdf 2023-07-18 11:07:47 +08:00
8137a304b3 Finish PE 2 2023-07-18 11:07:32 +08:00
bcb1c5c156 Finish PE 2 2023-07-18 11:03:56 +08:00
bedf5d0f8d Merge pull request #63 from datawhalechina/main
do some update for LangChain
2023-07-17 23:03:15 +08:00
3 changed files with 35 additions and 1239 deletions

View File

@ -178,7 +178,7 @@ LLM 正在逐步改变人们的生活,而对于开发者,如何基于 LLM
- [玉琳-项目发起人](https://github.com/Sophia-Huang)(内容创作者-Datawhale成员
- [Joye](https://Joyenjoye.com)(内容创作者-数据科学家)
- [高立业](https://github.com/0-yy-0)(内容创作者-DataWhale成员-算法工程师)
- AaronZ内容创作者)
- [Zhang Yixin](https://github.com/YixinZ-NUS)(内容创作者-IT爱好者)
- [万礼行](https://github.com/leason-wan)(内容创作者-视频翻译者)
- [仲泰](https://github.com/ztgg0228)(内容创作者-Datawhale成员
- [魂兮](https://github.com/wisdom-pan)(内容创作者-前端工程师)

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,33 @@
import os
import codecs
import json
def add_toc(ipynb_file):
f = codecs.open(ipynb_file, 'r')
source = f.read()
y = json.loads(source)
toc = ["\n"]
for item in y["cells"]:
if item["cell_type"]=='markdown':
if len(item["source"]) == 0:
continue
# print(item["source"])
item_start = item['source'][0].strip("\n")
if item_start.startswith("#"):
l = len(item_start.split()[0])
if l<=3 and l>1:
name = " ".join(item_start.split(" ")[1:])
tag = "-".join(item_start.split(" ")[1:])
tab = " "*(l-2)
toc.append(f' {tab}- [{name}](#{tag})\n')
y["cells"][0]['source']= y["cells"][0]['source'][0:1]
y["cells"][0]['source'].extend(toc)
f = codecs.open(ipynb_file, 'w')
f.write(json.dumps(y))
f.close()
for file in os.listdir("."):
if file.endswith("ipynb") and file[0].isdigit():
add_toc(file)