From 7a86f6a41b16d94f676bf327d35fb768854becb4 Mon Sep 17 00:00:00 2001 From: Nate Sesti <33237525+sestinj@users.noreply.github.com> Date: Sat, 16 Sep 2023 22:08:01 -0700 Subject: Refactor helper (#481) * feat: :sparkles: add stop_tokens option to LLM * work on refactoring in headless mode * feat: :sparkles: headless mode refactors * chore: :fire: remove test.py --- docs/docs/reference/Models/anthropic.md | 1 + docs/docs/reference/Models/ggml.md | 1 + docs/docs/reference/Models/hf_inference_api.md | 1 + docs/docs/reference/Models/hf_tgi.md | 1 + docs/docs/reference/Models/llamacpp.md | 1 + docs/docs/reference/Models/maybe_proxy_openai.md | 1 + docs/docs/reference/Models/ollama.md | 1 + docs/docs/reference/Models/openai.md | 1 + docs/docs/reference/Models/queued.md | 1 + docs/docs/reference/Models/replicate.md | 1 + docs/docs/reference/Models/text_gen_interface.md | 1 + docs/docs/reference/Models/together.md | 1 + docs/docs/reference/config.md | 2 +- docs/docs/walkthroughs/headless-mode.md | 37 +++++++++++++++--------- 14 files changed, 36 insertions(+), 15 deletions(-) (limited to 'docs') diff --git a/docs/docs/reference/Models/anthropic.md b/docs/docs/reference/Models/anthropic.md index 3f405d39..e2c6f683 100644 --- a/docs/docs/reference/Models/anthropic.md +++ b/docs/docs/reference/Models/anthropic.md @@ -31,6 +31,7 @@ Claude 2 is not yet publicly released. You can request early access [here](https + diff --git a/docs/docs/reference/Models/ggml.md b/docs/docs/reference/Models/ggml.md index 3369df6f..d02f6d05 100644 --- a/docs/docs/reference/Models/ggml.md +++ b/docs/docs/reference/Models/ggml.md @@ -34,6 +34,7 @@ config = ContinueConfig( + diff --git a/docs/docs/reference/Models/hf_inference_api.md b/docs/docs/reference/Models/hf_inference_api.md index 6e5aeeca..e7857b21 100644 --- a/docs/docs/reference/Models/hf_inference_api.md +++ b/docs/docs/reference/Models/hf_inference_api.md @@ -33,6 +33,7 @@ config = ContinueConfig( + diff --git a/docs/docs/reference/Models/hf_tgi.md b/docs/docs/reference/Models/hf_tgi.md index 3ea28730..ab3f4d61 100644 --- a/docs/docs/reference/Models/hf_tgi.md +++ b/docs/docs/reference/Models/hf_tgi.md @@ -18,6 +18,7 @@ import ClassPropertyRef from '@site/src/components/ClassPropertyRef.tsx'; + diff --git a/docs/docs/reference/Models/llamacpp.md b/docs/docs/reference/Models/llamacpp.md index c1c5e4f9..ae4b6e62 100644 --- a/docs/docs/reference/Models/llamacpp.md +++ b/docs/docs/reference/Models/llamacpp.md @@ -38,6 +38,7 @@ config = ContinueConfig( + diff --git a/docs/docs/reference/Models/maybe_proxy_openai.md b/docs/docs/reference/Models/maybe_proxy_openai.md index 651cbdba..c080b54d 100644 --- a/docs/docs/reference/Models/maybe_proxy_openai.md +++ b/docs/docs/reference/Models/maybe_proxy_openai.md @@ -39,6 +39,7 @@ These classes support any models available through the OpenAI API, assuming your + diff --git a/docs/docs/reference/Models/ollama.md b/docs/docs/reference/Models/ollama.md index 9f92c850..f0370b45 100644 --- a/docs/docs/reference/Models/ollama.md +++ b/docs/docs/reference/Models/ollama.md @@ -29,6 +29,7 @@ config = ContinueConfig( + diff --git a/docs/docs/reference/Models/openai.md b/docs/docs/reference/Models/openai.md index d9c440b7..f28e0598 100644 --- a/docs/docs/reference/Models/openai.md +++ b/docs/docs/reference/Models/openai.md @@ -47,6 +47,7 @@ Options for serving models locally with an OpenAI-compatible server include: + diff --git a/docs/docs/reference/Models/queued.md b/docs/docs/reference/Models/queued.md index 2499e03b..231aa4dc 100644 --- a/docs/docs/reference/Models/queued.md +++ b/docs/docs/reference/Models/queued.md @@ -31,6 +31,7 @@ config = ContinueConfig( + diff --git a/docs/docs/reference/Models/replicate.md b/docs/docs/reference/Models/replicate.md index 041f4c2b..83bfd383 100644 --- a/docs/docs/reference/Models/replicate.md +++ b/docs/docs/reference/Models/replicate.md @@ -34,6 +34,7 @@ If you don't specify the `model` parameter, it will default to `replicate/llama- + diff --git a/docs/docs/reference/Models/text_gen_interface.md b/docs/docs/reference/Models/text_gen_interface.md index 7ca38b36..d910bee2 100644 --- a/docs/docs/reference/Models/text_gen_interface.md +++ b/docs/docs/reference/Models/text_gen_interface.md @@ -32,6 +32,7 @@ config = ContinueConfig( + diff --git a/docs/docs/reference/Models/together.md b/docs/docs/reference/Models/together.md index 1a13cbbc..6838ba36 100644 --- a/docs/docs/reference/Models/together.md +++ b/docs/docs/reference/Models/together.md @@ -34,6 +34,7 @@ config = ContinueConfig( + diff --git a/docs/docs/reference/config.md b/docs/docs/reference/config.md index a96dc2ac..f867ee1e 100644 --- a/docs/docs/reference/config.md +++ b/docs/docs/reference/config.md @@ -11,7 +11,7 @@ Continue can be deeply customized by editing the `ContinueConfig` object in `~/. - + diff --git a/docs/docs/walkthroughs/headless-mode.md b/docs/docs/walkthroughs/headless-mode.md index 92382d77..d4f90264 100644 --- a/docs/docs/walkthroughs/headless-mode.md +++ b/docs/docs/walkthroughs/headless-mode.md @@ -5,23 +5,32 @@ To use headless mode: 1. `pip install continuedev` (using a virtual environment is recommended) -2. Create a config file (see the [`ContinueConfig` Reference](../reference/config.md) for all options) that includes the [Policy](../customization/other-configuration.md#custom-policies) you want to run -3. Import `continuedev` and call `start_headless_session` with either the path to your config file, or an instance of `ContinueConfig` +2. Import `continuedev` and call `run_step_headless` with the `Step` you would like to run Example: +Say you have the following file (`/path/to/file.py`): + ```python -from continuedev.headless import start_headless_session -from continuedev.core.config import ContinueConfig -from continuedev.core.models import Models -import asyncio - -config = ContinueConfig( - models=Models(...), - override_policy=MyPolicy() -) -asyncio.run(start_headless_session(config)) +def say_hello(name: str): + print(f"Hello, {name}") +``` + +and this function is imported and used in multiple places throughout your codebase. But the name parameter is new, and you need to change the function call everywhere it is used. You can use the script below to edit all usages of the function in your codebase: -# Alternatively, pass the path to a config file -asyncio.run(start_headless_session("/path/to/config.py")) +```python +from continuedev.headless import run_step_headless +from continuedev.models.main import Position, PositionInFile +from continuedev.plugins.steps.refactor import RefactorReferencesStep + +step = RefactorReferencesStep( + user_input="", + symbol_location=PositionInFile( + filepath="/path/to/file.py", + position=Position(line=0, character=5), + ), +) +run_step_headless(step=step) ``` + +Here we use Continue's built-in `RefactorReferencesStep`. By passing it the location (filepath and position) of the symbol (function, variable, etc.) that we want to update, Continue will automatically find all references to that symbol and prompt an LLM to make the edit requested in the `user_input` field. -- cgit v1.2.3-70-g09d2