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

[FR/Q] How do I comment a line of the snippet from being included in the snippet? #1195

Open
NightMachinery opened this issue Mar 24, 2024 · 1 comment

Comments

@NightMachinery
Copy link

NightMachinery commented Mar 24, 2024

I have this snippet:

# -*- mode: snippet -*-
# name: llm-c3o
# key: <l
# uuid: <l
# --
#+begin_src jupyter-python :kernel py_base :session claude_1 :async yes :exports both
res = openai_chat_complete(
    ##
    model="OR:anthropic/claude-3-opus:beta",
    # model="OR:anthropic/claude-3-sonnet:beta",
    # model="OR:anthropic/claude-3-haiku:beta",
    # model="OR:mistralai/mistral-large",
    # model="OR:perplexity/sonar-medium-online",
    # model="gpt-4-turbo",
    # model="gpt-4-0314",
    # model="gpt-4-0613",
    # model="claude-3-opus-20240229",
    ##
    messages=[
        # {"role": "system", "content": \"""Output your changes in the unified diff format.\"""},
        {"role": "user", "content": r\"""
        `%`$0
        \"""},
    ],
    temperature=0,
    max_tokens=4000,
    interactive=True,
)

print_chat_streaming(res, copy_mode=None) # "chat2"
bell_gpt()
#+end_src

I want to comment some of the model=... lines such that they remain in the snippet file, but are never expanded. (I.e., if we treat the above snippet template as code, I want to add some comments to it.)

@dericbytes
Copy link

dericbytes commented Apr 12, 2024

I know a hack that works. Run elisp code that returns an empty string

# key: dm
# name: delete-me-1
# --
This
is`(progn "ignore me" "")`
a
test.

You can create your own function to make it look neater

# key: dm2
# name: delete-me-2
# --
This
is a `(yas-comment "really")`good
second example.

create elisp function (best to change function name to avoid naming conflict)

(defun yas-comment (msg)
  "Ignore MSG. Return an empty string"
    "") 

You will need to escape and unescape your quotes. You can do that by selecting the region and running a function.
http://xahlee.info/emacs/emacs/elisp_escape_quotes.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants