summaryrefslogtreecommitdiff
path: root/continuedev/src/continuedev/steps
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-06-10 07:53:31 -0400
committerNate Sesti <sestinj@gmail.com>2023-06-10 07:53:31 -0400
commit262dffd21c4dac88050926d72b78f7e91a5df75b (patch)
treec361c4d95fd999df9a3c1cc950a07796780463fc /continuedev/src/continuedev/steps
parentc3b24a89105d22a5fa01400b7c9d5494a2d3ffc5 (diff)
downloadsncontinue-262dffd21c4dac88050926d72b78f7e91a5df75b.tar.gz
sncontinue-262dffd21c4dac88050926d72b78f7e91a5df75b.tar.bz2
sncontinue-262dffd21c4dac88050926d72b78f7e91a5df75b.zip
selection step of airflow recipe
Diffstat (limited to 'continuedev/src/continuedev/steps')
-rw-r--r--continuedev/src/continuedev/steps/input/nl_multiselect.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/continuedev/src/continuedev/steps/input/nl_multiselect.py b/continuedev/src/continuedev/steps/input/nl_multiselect.py
new file mode 100644
index 00000000..c3c832f5
--- /dev/null
+++ b/continuedev/src/continuedev/steps/input/nl_multiselect.py
@@ -0,0 +1,27 @@
+from typing import List, Union
+from ..core.core import WaitForUserInputStep
+from ...core.main import Step
+from ...core.sdk import ContinueSDK
+
+
+class NLMultiselectStep(Step):
+ hide: bool = True
+
+ prompt: str
+ options: List[str]
+
+ async def run(self, sdk: ContinueSDK):
+ user_response = (await sdk.run_step(WaitForUserInputStep(prompt=self.prompt))).text
+
+ def extract_option(text: str) -> Union[str, None]:
+ for option in self.options:
+ if option in text:
+ return option
+ return None
+
+ first_try = extract_option(user_response.lower())
+ if first_try is not None:
+ return first_try
+
+ gpt_parsed = await sdk.models.gpt35.complete(f"These are the available options are: [{', '.join(self.options)}]. The user requested {user_response}. This is the exact string from the options array that they selected:")
+ return extract_option(gpt_parsed) or self.options[0]