To see TypeChat in action, check out the examples found in this directory.
Each example shows how TypeChat handles natural language input, and maps to validated JSON as output. Most example inputs run on both GPT 3.5 and GPT 4.
We are working to reproduce outputs with other models.
Generally, models trained on both code and natural language text have high accuracy.
We recommend reading each example in the following order.
| Name | Description |
| ---- | ----------- |
| [Sentiment](https://github.com/microsoft/TypeChat/tree/main/examples/sentiment) | A sentiment classifier which categorizes user input as negative, neutral, or positive. This is TypeChat's "hello world!" |
| [Coffee Shop](https://github.com/microsoft/TypeChat/tree/main/examples/coffeeShop) | An intelligent agent for a coffee shop. This sample translates user intent is translated to a list of coffee order items.
| [Calendar](https://github.com/microsoft/TypeChat/tree/main/examples/calendar) | An intelligent scheduler. This sample translates user intent into a sequence of actions to modify a calendar. |
| [Restaurant](https://github.com/microsoft/TypeChat/tree/main/examples/restaurant) | An intelligent agent for taking orders at a restaurant. Similar to the coffee shop example, but uses a more complex schema to model more complex linguistic input. The prose files illustrate the line between simpler and more advanced language models in handling compound sentences, distractions, and corrections. This example also shows how we can use TypeScript to provide a user intent summary. |
| [Math](https://github.com/microsoft/TypeChat/tree/main/examples/math) | Translate calculations into simple programs given an API that can perform the 4 basic mathematical operators. This example highlights TypeChat's program generation capabilities. |
| [Music](https://github.com/microsoft/TypeChat/tree/main/examples/music) | An app for playing music, creating playlists, etc. on Spotify through natural language. Each user intent is translated into a series of actions in JSON which correspond to a simple dataflow program, where each step can consume data produced from previous step. |
## Step 1: Configure your development environment
### Option 1: Local Machine
You can experiment with these TypeChat examples on your local machine with just Node.js.
Ensure [Node.js (18.16.0 LTS or newer)](https://nodejs.org/en) or newer is installed.
```
git clone https://github.com/microsoft/TypeChat
cd TypeChat
npm install
```
### Option 2: GitHub Codespaces
GitHub Codespaces enables you to try TypeChat quickly in a development environment hosted in the cloud.
On the TypeChat repository page:
1. Click the green button labeled `<> Code`
2. Select the `Codespaces` tab.
3. Click the green `Create codespace` button.
<details>
<summary>If this is your first time creating a codespace, read this.</summary>
If this is your first time creating a codespace on this repository, GitHub will take a moment to create a dev container image for your session.
Once the image has been created, the browser will load Visual Studio Code in a developer environment automatically configured with the necessary prerequisites, TypeChat cloned, and packages installed.
Remember that you are running in the cloud, so all changes you make to the source tree must be committed and pushed before destroying the codespace. GitHub accounts are usually configured to automatically delete codespaces that have been inactive for 30 days.
For more information, see the [GitHub Codespaces Overview](https://docs.github.com/en/codespaces/overview)
</details>
## Step 2: Build TypeChat Samples
Build TypeChat and the examples by running the following command in the repository root:
```
npm run build-all
```
## Step 3: Configure environment variables
Currently, the examples are running on OpenAI or Azure OpenAI endpoints.
To use an OpenAI endpoint, include the following environment variables:
| Variable | Value |
|----------|-------|
| `OPENAI_MODEL`| The OpenAI model name (e.g. `gpt-3.5-turbo` or `gpt-4`) |
| `OPENAI_API_KEY` | Your OpenAI API key |
| `OPENAI_ENDPOINT` | OpenAI API Endpoint - *optional*, defaults to `"https://api.openai.com/v1/chat/completions"` |
| `OPENAI_ORGANIZATION` | OpenAI Organization - *optional*, defaults to `""` |
To use an Azure OpenAI endpoint, include the following environment variables:
| Variable | Value |
|----------|-------|
| `AZURE_OPENAI_ENDPOINT` | The full URL of the Azure OpenAI REST API (e.g. `https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/chat/completions?api-version=2023-05-15`) |
| `AZURE_OPENAI_API_KEY` | Your Azure OpenAI API key |
We recommend setting environment variables by creating a `.env` file in the root directory of the project that looks like the following:
```
# For OpenAI
OPENAI_MODEL=...
OPENAI_API_KEY=...
# For Azure OpenAI
AZURE_OPENAI_ENDPOINT=...
AZURE_OPENAI_API_KEY=...
```
## Step 4: Run the examples
Examples can be found in the `examples` directory.
To run an example interactively, type `node ./dist/main.js` from the example's directory and enter requests when prompted. Type `quit` or `exit` to end the session. You can also open in VS Code the selected example's directory and press <kbd>F5</kbd> to launch it in debug mode.
Note that there are various sample "prose" files (e.g. `input.txt`) provided in each `src` directory that can give a sense of what you can run.
To run an example with one of these input files, run `node ./dist/main.js <input-file-path>`.
For example, in the `coffeeShop` directory, you can run:
```
node ./dist/main.js ./dist/input.txt
```
没有合适的资源?快使用搜索试试~ 我知道了~
简化自然语言接口构建的库:TypeChat
共158个文件
py:36个
json:32个
ts:30个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 72 浏览量
2024-01-16
14:33:48
上传
评论
收藏 230KB ZIP 举报
温馨提示
TypeChat库旨在使构建自然语言接口变得容易。通过这个项目,开发者可以更简单地构建具有自然语言交互能力的应用和系统。TypeChat 提供了一种更便捷的方式来集成自然语言处理功能,帮助用户轻松地与系统进行交互
资源推荐
资源详情
资源评论
收起资源包目录
简化自然语言接口构建的库:TypeChat (158个子文件)
5.3.0_dist_css_bootstrap.min.css 227KB
styles.css 2KB
noscript-styles.css 115B
musicLibrary.db 20KB
.gitignore 3KB
.gitignore 203B
.gitignore 5B
callback.html 277B
healthData.ipynb 4KB
math.ipynb 4KB
music.ipynb 4KB
calendar.ipynb 3KB
coffeeShop.ipynb 3KB
restaurant.ipynb 3KB
sentiment.ipynb 2KB
.eleventy.js 2KB
interactivity.js 1KB
package-lock.json 90KB
package-lock.json 84KB
package-lock.json 1KB
devcontainer.json 1KB
package.json 1KB
package.json 632B
package.json 568B
launch.json 557B
launch.json 557B
launch.json 557B
launch.json 557B
launch.json 557B
launch.json 557B
pyrightconfig.json 538B
package.json 457B
package.json 456B
package.json 456B
package.json 455B
package.json 454B
package.json 450B
tsconfig.json 374B
tsconfig.json 373B
tsconfig.json 373B
tsconfig.json 373B
tsconfig.json 373B
tsconfig.json 373B
docsTOC.json 323B
package.json 322B
tsconfig.json 317B
headernav.json 310B
tsconfig.json 289B
jsconfig.json 252B
LICENSE 1KB
introducing-typechat.md 7KB
introduction.md 7KB
README.md 6KB
examples.md 5KB
faq.md 4KB
README.md 4KB
SECURITY.md 3KB
README.md 3KB
techniques.md 2KB
README.md 2KB
README.md 2KB
README.md 1KB
README.md 1KB
README.md 958B
README.md 870B
migrations.md 747B
README.md 614B
SUPPORT.md 499B
CODE_OF_CONDUCT.md 444B
docs.njk 2KB
blog.njk 2KB
index.njk 1KB
index.njk 1KB
header-prologue.njk 1KB
index.njk 836B
base.njk 779B
footer.njk 503B
doc-page.njk 58B
client.py 16KB
python_type_to_ts_nodes.py 12KB
schema.py 7KB
program.py 6KB
spotipyWrapper.py 5KB
coffeeshop_deprecated.py 4KB
coffeeshop.py 4KB
schema.py 4KB
ts_node_to_string.py 4KB
translator.py 3KB
schema.py 3KB
translator.py 3KB
schema.py 2KB
model.py 2KB
ts_type_nodes.py 2KB
demo.py 2KB
schema.py 2KB
demo.py 2KB
validator.py 2KB
demo.py 1KB
__init__.py 1KB
hello_world.py 1024B
共 158 条
- 1
- 2
资源评论
UnknownToKnown
- 粉丝: 1w+
- 资源: 713
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功