Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Claude doesn't include non-code in files (fixes #1030) #1116

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@

---

<div align="center">

<a href="vscode:extension/PythagoraTechnologies.gpt-pilot-vs-code" target="_blank"><img src="https://github.com/Pythagora-io/gpt-pilot/assets/10895136/5792143e-77c7-47dd-ad96-6902be1501cd" alt="Pythagora-io%2Fgpt-pilot | Trendshift" style="width: 185px; height: 55px;" width="185" height="55"/></a>

</div>

GPT Pilot is the core technology for the [Pythagora VS Code extension](https://bit.ly/3IeZxp6) that aims to provide **the first real AI developer companion**. Not just an autocomplete or a helper for PR messages but rather a real AI developer that can write full features, debug them, talk to you about issues, ask for review, etc.

---

📫 If you would like to get updates on future releases or just get in touch, join our [Discord server](https://discord.gg/HaqXugmxr9) or you [can add your email here](http://eepurl.com/iD6Mpo). 📬

---
Expand Down Expand Up @@ -97,9 +87,6 @@ If you are interested in our learnings during this project, you can check [our l
- **Python 3.9+**

# 🚦How to start using gpt-pilot?
👉 If you are using VS Code as your IDE, the easiest way to start is by downloading [GPT Pilot VS Code extension](https://bit.ly/3IeZxp6). 👈

Otherwise, you can use the CLI tool.

### If you're new to GPT Pilot:

Expand Down
19 changes: 9 additions & 10 deletions core/llm/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,16 @@ def __call__(self, text: str) -> str:
return blocks[0]


class OptionalCodeBlockParser:
class OptionalCodeBlockParser(MultiCodeBlockParser):
def __call__(self, text: str) -> str:
text = text.strip()
if text.startswith("```") and text.endswith("\n```"):
# Remove the first and last line. Note the first line may include syntax
# highlighting, so we can't just remove the first 3 characters.
text = "\n".join(text.splitlines()[1:-1]).strip()
elif "\n" not in text and text.startswith("`") and text.endswith("`"):
# Single-line code blocks are wrapped in single backticks
text = text[1:-1]
return text
blocks = super().__call__(text)
# FIXME: if there are more than 1 code block, this means the output actually contains ```,
# so re-parse this with that in mind
if len(blocks) > 1:
raise ValueError(f"Expected a single code block, got {len(blocks)}")
if len(blocks) == 0:
return text.strip()
return blocks[0]


class JSONParser:
Expand Down