跳至内容

笔记本

GenAIScript Markdown Notebook目前用于编写GenAIScript文档。

Screenshot of a Visual Studio Code notebook interface showing an interactive code execution. The text at the top says "Let's start with a simple hello world program." Below is a code cell with the prompt "$ Say "hello!" in emojis" which has been executed in 1.3 seconds, indicated by a checkmark and the time. There are two outputs: one labeled 'user' with the text "Say "hello!" in emojis" and another labeled 'assistant' with a waving hand emoji followed by an exclamation mark.

它允许运行脚本片段并将结果内联到markdown中,就像这样:

$`Write a 3 emoji story.`
👤 user
Write a 3 emoji story.
🤖 assistant
🌱 🌻 🌞

将Markdown作为笔记本编辑

第一步是使用GenAIScript笔记本打开要编辑的markdown文件。

  1. 在Visual Studio Code中,右键点击任意Markdown (.md)或MDX文件 (.mdx)
  2. 选择打开方式…
  3. 选择 GenAIScript Markdown Notebook

运行代码片段

你可以通过点击运行单元格按钮或按下Shift+Enter来运行任何JavaScript单元格。代码会像在工作区中的GenAIScript脚本一样被执行。

$`Write a one sentence poem.`
👤 user
Write a one sentence poem.
🤖 assistant
In the still of the night, the stars whisper secrets to the dreaming earth.

页面配置

您可以在前置元数据中提供全局配置设置。前置元数据以三个破折号 --- 开始和结束,位于Markdown文件的顶部。

---
title: My genai notebook
genaiscript:
model: openai:gpt-3.5-turbo
...
---

模型、提供商、温度、…

您可以从script中指定LLM配置元数据。

---
genaiscript:
provider: openai
model: openai:gpt-3.5-turbo
temperature: 0
---

文件

您可以指定要包含在笔记本中的文件,可以是单个条目或数组。支持通配符模式。 文件路径是相对于工作区根目录的。

---
genaiscript:
files: src/samples/*.md
---

env.files 变量可用于引用笔记本中的文件。

def("FILE", env.files)
$`Summarize FILE using exclusively emojis.`
👤 user
FILE:
```md file="src/samples/markdown.md"
---
title: What is Markdown? - Understanding Markdown Syntax
description: Learn about Markdown, a lightweight markup language for formatting plain text, its syntax, and how it differs from WYSIWYG editors.
keywords: Markdown, markup language, formatting, plain text, syntax
sidebar: mydoc_sidebar
---
What is Markdown?
Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents. Created by John Gruber in 2004, Markdown is now one of the world’s most popular markup languages.
Using Markdown is different than using a WYSIWYG editor. In an application like Microsoft Word, you click buttons to format words and phrases, and the changes are visible immediately. Markdown isn’t like that. When you create a Markdown-formatted file, you add Markdown syntax to the text to indicate which words and phrases should look different.
For example, to denote a heading, you add a number sign before it (e.g., # Heading One). Or to make a phrase bold, you add two asterisks before and after it (e.g., **this text is bold**). It may take a while to get used to seeing Markdown syntax in your text, especially if you’re accustomed to WYSIWYG applications. The screenshot below shows a Markdown file displayed in the Visual Studio Code text editor....
```
Summarize FILE using exclusively emojis.
🤖 assistant
📝 Markdown is a lightweight markup language created by John Gruber in 2004. It allows users to add formatting to plaintext documents using simple syntax. Unlike WYSIWYG editors, Markdown requires users to add specific symbols to indicate formatting, such as using # for headings and \*\* for bold text. Despite the initial adjustment period, Markdown has become one of the most popular markup languages in the world.