Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d7be26f
feat: Add VS Code Language Model API integration (#80)
ankit-apk Aug 15, 2025
21405f6
refactor: Address PR feedback for VS Code LM API integration
ankit-apk Aug 18, 2025
1fead53
cleanup: Remove unused files after merging changes
ankit-apk Aug 18, 2025
c63fe7f
fix: Register VS Code LM commands and fix compilation issues
ankit-apk Aug 18, 2025
a89a3e5
chore: Update .gitignore to exclude test artifacts
ankit-apk Aug 18, 2025
5409c08
docs: Update PR description with test results and review feedback
ankit-apk Aug 18, 2025
5e6e33a
refactor: address PR feedback - simplify implementation
ankit-apk Aug 18, 2025
1232c08
fix: update code review example to pass tests
ankit-apk Aug 18, 2025
58d3c14
refactor: address all PR review feedback
ankit-apk Aug 18, 2025
cb42de1
refactor: address all PR review feedback
ankit-apk Aug 18, 2025
8a4d65b
Merge branch 'feature/vscode-lm-api-integration' of https://github.co…
ankit-apk Aug 18, 2025
7bd1a65
Merge upstream/main - resolve conflicts in VS Code LM API integration
ankit-apk Aug 24, 2025
9d46562
merge upstream/main
ultmaster Sep 2, 2025
c6b019a
revert bump version
ultmaster Sep 2, 2025
fb71b55
refactor vscode command
ultmaster Sep 2, 2025
16741ef
Add comments
ultmaster Sep 2, 2025
fa49518
fix command bugs
ultmaster Sep 2, 2025
458e505
fix example
ultmaster Sep 2, 2025
6e05d27
restore tags and version
ultmaster Sep 2, 2025
b26db04
restore tags and version
ultmaster Sep 2, 2025
1ad65d8
Merge branch 'feature/vscode-lm-api-integration' of https://github.co…
ultmaster Sep 2, 2025
7097dbb
fix tests
ultmaster Sep 2, 2025
743b6e6
revert
ultmaster Sep 2, 2025
9cfdf9f
minor fix
ultmaster Sep 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/vscode/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ The following settings mainly control the language model used for POML testing f
}
```

**Options:** `openai`, `openaiResponse`, `microsoft`, `anthropic`, `google`
**Options:** `vscode`, `openai`, `openaiResponse`, `microsoft`, `anthropic`, `google`
**Default:** `openai`

!!! note

If you have GitHub Copilot enabled in VS Code, you can set this to `vscode` to use VS Code's Language Model API. The API URL and API Key settings will be ignored in this case.

### Model Name

```json
Expand All @@ -59,9 +63,12 @@ The following settings mainly control the language model used for POML testing f
}
```

**Default:** `gpt-4o`
**Default:** `gpt-4o`

For Azure OpenAI, use the deployment name. For other providers, use the model code name.

For GitHub Copilot in VS Code, the model name will be used as the family name to select the model. See [this guide](https://code.visualstudio.com/api/extension-guides/ai/language-model) for explanations of model families.

### Temperature

```json
Expand Down
26 changes: 26 additions & 0 deletions examples/110_code_review.poml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- POML example for code review with educational comments -->
<poml>
<!-- The role tag defines the AI assistant's expertise and perspective -->
<role>You are a senior software engineer with expertise in Python, web security, and best practices.</role>

<!-- The task tag specifies what the AI should do -->
<task>Review the provided Python Flask application for security vulnerabilities, performance issues, and code quality.</task>

<!-- The document tag includes external files. The parser attribute specifies how to read the file -->
<code inline="false" lang="python">
<document src="assets/110_sample_code.py" parser="txt" />
</code>

<!-- Use paragraphs to provide additional context or instructions -->
<p>Focus on security vulnerabilities, performance optimizations, and Python best practices.</p>

<!-- The output-format tag structures the expected response -->
<output-format>
Provide a structured code review with:
<list listStyle="decimal">
<item>Critical security issues</item>
<item>Performance improvements</item>
<item>Code quality suggestions</item>
</list>
</output-format>
</poml>
85 changes: 85 additions & 0 deletions examples/assets/110_sample_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import hashlib
import sqlite3

from flask import Flask, render_template_string, request

app = Flask(__name__)


# Database connection
def get_db():
conn = sqlite3.connect("users.db")
return conn


@app.route("/login", methods=["POST"])
def login():
username = request.form["username"]
password = request.form["password"]

# Security issue: SQL injection vulnerability
query = f"SELECT * FROM users WHERE username = '{username}' AND password = '{password}'"

conn = get_db()
cursor = conn.cursor()
cursor.execute(query)
user = cursor.fetchone()

if user:
# Security issue: password stored in plain text
return f"Welcome {username}!"
else:
return "Invalid credentials"


@app.route("/search")
def search():
query = request.args.get("q", "")

# Security issue: XSS vulnerability
template = f"<h1>Search Results for: {query}</h1>"
return render_template_string(template)


@app.route("/admin")
def admin_panel():
# Security issue: No authentication check
conn = get_db()
cursor = conn.cursor()
cursor.execute("SELECT * FROM users")
users = cursor.fetchall()

# Performance issue: Loading all users at once
return str(users)


def process_data(data):
result = []
# Performance issue: Inefficient nested loops
for i in range(len(data)):
for j in range(len(data)):
if data[i] == data[j] and i != j:
result.append(data[i])
return result


class UserManager:
def __init__(self):
self.users = []

def add_user(self, name, email, password):
# Maintainability issue: No input validation
user = {"name": name, "email": email, "password": password} # Security issue: storing plain password
self.users.append(user)

def find_user(self, email):
# Performance issue: Linear search
for user in self.users:
if user["email"] == email:
return user
return None


if __name__ == "__main__":
# Security issue: Debug mode in production
app.run(debug=True, host="0.0.0.0")
108 changes: 108 additions & 0 deletions examples/expects/110_code_review.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
===== human =====

# Role

You are a senior software engineer with expertise in Python, web security, and best practices.

# Task

Review the provided Python Flask application for security vulnerabilities, performance issues, and code quality.

```python
import hashlib
import sqlite3

from flask import Flask, render_template_string, request

app = Flask(__name__)


# Database connection
def get_db():
conn = sqlite3.connect("users.db")
return conn


@app.route("/login", methods=["POST"])
def login():
username = request.form["username"]
password = request.form["password"]

# Security issue: SQL injection vulnerability
query = f"SELECT * FROM users WHERE username = '{username}' AND password = '{password}'"

conn = get_db()
cursor = conn.cursor()
cursor.execute(query)
user = cursor.fetchone()

if user:
# Security issue: password stored in plain text
return f"Welcome {username}!"
else:
return "Invalid credentials"


@app.route("/search")
def search():
query = request.args.get("q", "")

# Security issue: XSS vulnerability
template = f"<h1>Search Results for: {query}</h1>"
return render_template_string(template)


@app.route("/admin")
def admin_panel():
# Security issue: No authentication check
conn = get_db()
cursor = conn.cursor()
cursor.execute("SELECT * FROM users")
users = cursor.fetchall()

# Performance issue: Loading all users at once
return str(users)


def process_data(data):
result = []
# Performance issue: Inefficient nested loops
for i in range(len(data)):
for j in range(len(data)):
if data[i] == data[j] and i != j:
result.append(data[i])
return result


class UserManager:
def __init__(self):
self.users = []

def add_user(self, name, email, password):
# Maintainability issue: No input validation
user = {"name": name, "email": email, "password": password} # Security issue: storing plain password
self.users.append(user)

def find_user(self, email):
# Performance issue: Linear search
for user in self.users:
if user["email"] == email:
return user
return None


if __name__ == "__main__":
# Security issue: Debug mode in production
app.run(debug=True, host="0.0.0.0")

```

Focus on security vulnerabilities, performance optimizations, and Python best practices.

# Output Format

Provide a structured code review with:

1. Critical security issues
2. Performance improvements
3. Code quality suggestions
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,15 @@
"type": "string",
"description": "Language Model Provider",
"enum": [
"vscode",
"openai",
"openaiResponse",
"microsoft",
"anthropic",
"google"
],
"enumItemLabels": [
"VS Code LM (GitHub Copilot)",
"OpenAI Chat Completion",
"OpenAI Response API",
"Azure OpenAI",
Expand Down
Loading
Loading