summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--continuedev/src/continuedev/core/sdk.py26
-rw-r--r--continuedev/src/continuedev/recipes/CreatePipelineRecipe/steps.py6
-rw-r--r--continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py2
-rw-r--r--continuedev/src/continuedev/steps/chroma.py2
-rw-r--r--continuedev/src/continuedev/steps/core/core.py2
-rw-r--r--continuedev/src/continuedev/steps/draft/migration.py2
-rw-r--r--continuedev/src/continuedev/steps/main.py4
-rw-r--r--extension/package-lock.json4
-rw-r--r--extension/package.json2
-rw-r--r--extension/scripts/continuedev-0.1.1-py3-none-any.whlbin59915 -> 58089 bytes
10 files changed, 29 insertions, 21 deletions
diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py
index d1f731da..e44c1eee 100644
--- a/continuedev/src/continuedev/core/sdk.py
+++ b/continuedev/src/continuedev/core/sdk.py
@@ -1,4 +1,6 @@
from abc import ABC, abstractmethod
+import asyncio
+from functools import cached_property
from typing import Coroutine, Union
import os
@@ -29,15 +31,21 @@ class Models:
def __init__(self, sdk: "ContinueSDK"):
self.sdk = sdk
- async def starcoder(self):
- api_key = await self.sdk.get_user_secret(
- 'HUGGING_FACE_TOKEN', 'Please add your Hugging Face token to the .env file')
- return HuggingFaceInferenceAPI(api_key=api_key)
-
- async def gpt35(self):
- api_key = await self.sdk.get_user_secret(
- 'OPENAI_API_KEY', 'Please add your OpenAI API key to the .env file')
- return OpenAI(api_key=api_key, default_model="gpt-3.5-turbo")
+ @cached_property
+ def starcoder(self):
+ async def load_starcoder():
+ api_key = await self.sdk.get_user_secret(
+ 'HUGGING_FACE_TOKEN', 'Please add your Hugging Face token to the .env file')
+ return HuggingFaceInferenceAPI(api_key=api_key)
+ return asyncio.get_event_loop().run_until_complete(load_starcoder())
+
+ @cached_property
+ def gpt35(self):
+ async def load_gpt35():
+ api_key = await self.sdk.get_user_secret(
+ 'OPENAI_API_KEY', 'Please add your OpenAI API key to the .env file')
+ return OpenAI(api_key=api_key, default_model="gpt-3.5-turbo")
+ return asyncio.get_event_loop().run_until_complete(load_gpt35())
class ContinueSDK(AbstractContinueSDK):
diff --git a/continuedev/src/continuedev/recipes/CreatePipelineRecipe/steps.py b/continuedev/src/continuedev/recipes/CreatePipelineRecipe/steps.py
index 6a2f4aed..6dd9396f 100644
--- a/continuedev/src/continuedev/recipes/CreatePipelineRecipe/steps.py
+++ b/continuedev/src/continuedev/recipes/CreatePipelineRecipe/steps.py
@@ -30,7 +30,7 @@ class SetupPipelineStep(Step):
async def run(self, sdk: ContinueSDK):
sdk.context.set("api_description", self.api_description)
- source_name = (await sdk.models.gpt35()).complete(
+ source_name = sdk.models.gpt35.complete(
f"Write a snake_case name for the data source described by {self.api_description}: ").strip()
filename = f'{source_name}.py'
@@ -92,7 +92,7 @@ class ValidatePipelineStep(Step):
if "Traceback" in output or "SyntaxError" in output:
output = "Traceback" + output.split("Traceback")[-1]
file_content = await sdk.ide.readFile(os.path.join(workspace_dir, filename))
- suggestion = (await sdk.models.gpt35()).complete(dedent(f"""\
+ suggestion = sdk.models.gpt35.complete(dedent(f"""\
```python
{file_content}
```
@@ -104,7 +104,7 @@ class ValidatePipelineStep(Step):
This is a brief summary of the error followed by a suggestion on how it can be fixed by editing the resource function:"""))
- api_documentation_url = (await sdk.models.gpt35()).complete(dedent(f"""\
+ api_documentation_url = sdk.models.gpt35.complete(dedent(f"""\
The API I am trying to call is the '{sdk.context.get('api_description')}'. I tried calling it in the @resource function like this:
```python
{file_content}
diff --git a/continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py b/continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py
index 82876a08..5994aa89 100644
--- a/continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py
+++ b/continuedev/src/continuedev/recipes/WritePytestsRecipe/main.py
@@ -38,7 +38,7 @@ class WritePytestsRecipe(Step):
"{self.instructions}"
Here is a complete set of pytest unit tests:""")
- tests = (await sdk.models.gpt35()).complete(prompt)
+ tests = sdk.models.gpt35.complete(prompt)
await sdk.apply_filesystem_edit(AddFile(filepath=path, content=tests))
diff --git a/continuedev/src/continuedev/steps/chroma.py b/continuedev/src/continuedev/steps/chroma.py
index 7bb9389e..058455b2 100644
--- a/continuedev/src/continuedev/steps/chroma.py
+++ b/continuedev/src/continuedev/steps/chroma.py
@@ -56,7 +56,7 @@ class AnswerQuestionChroma(Step):
Here is the answer:""")
- answer = (await sdk.models.gpt35()).complete(prompt)
+ answer = sdk.models.gpt35.complete(prompt)
# Make paths relative to the workspace directory
answer = answer.replace(await sdk.ide.getWorkspaceDirectory(), "")
diff --git a/continuedev/src/continuedev/steps/core/core.py b/continuedev/src/continuedev/steps/core/core.py
index 250ced8b..dfd765eb 100644
--- a/continuedev/src/continuedev/steps/core/core.py
+++ b/continuedev/src/continuedev/steps/core/core.py
@@ -135,7 +135,7 @@ class Gpt35EditCodeStep(Step):
prompt = self._prompt.format(
code=rif.contents, user_request=self.user_input, file_prefix=segs[0], file_suffix=segs[1])
- completion = str((await sdk.models.gpt35()).complete(prompt))
+ completion = str(sdk.models.gpt35.complete(prompt))
eot_token = "<|endoftext|>"
completion = completion.removesuffix(eot_token)
diff --git a/continuedev/src/continuedev/steps/draft/migration.py b/continuedev/src/continuedev/steps/draft/migration.py
index b386bed8..f3b36b5e 100644
--- a/continuedev/src/continuedev/steps/draft/migration.py
+++ b/continuedev/src/continuedev/steps/draft/migration.py
@@ -13,7 +13,7 @@ class MigrationStep(Step):
recent_edits = await sdk.ide.get_recent_edits(self.edited_file)
recent_edits_string = "\n\n".join(
map(lambda x: x.to_string(), recent_edits))
- description = await (await sdk.models.gpt35()).complete(f"{recent_edits_string}\n\nGenerate a short description of the migration made in the above changes:\n")
+ description = await sdk.models.gpt35.complete(f"{recent_edits_string}\n\nGenerate a short description of the migration made in the above changes:\n")
await sdk.run([
"cd libs",
"poetry run alembic revision --autogenerate -m " + description,
diff --git a/continuedev/src/continuedev/steps/main.py b/continuedev/src/continuedev/steps/main.py
index 69c98bd4..81a1e3a9 100644
--- a/continuedev/src/continuedev/steps/main.py
+++ b/continuedev/src/continuedev/steps/main.py
@@ -144,7 +144,7 @@ class FasterEditHighlightedCodeStep(Step):
for rif in rif_with_contents:
rif_dict[rif.filepath] = rif.contents
- completion = (await sdk.models.gpt35()).complete(prompt)
+ completion = sdk.models.gpt35.complete(prompt)
# Temporarily doing this to generate description.
self._prompt = prompt
@@ -239,7 +239,7 @@ class StarCoderEditHighlightedCodeStep(Step):
for rif in rif_with_contents:
prompt = self._prompt.format(
code=rif.contents, user_request=self.user_input)
- completion = str((await sdk.models.starcoder()).complete(prompt))
+ completion = str(sdk.models.starcoder.complete(prompt))
eot_token = "<|endoftext|>"
if completion.endswith(eot_token):
completion = completion[:completion.rindex(eot_token)]
diff --git a/extension/package-lock.json b/extension/package-lock.json
index 0b0e063b..c6f953c3 100644
--- a/extension/package-lock.json
+++ b/extension/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "continue",
- "version": "0.0.23",
+ "version": "0.0.24",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "continue",
- "version": "0.0.23",
+ "version": "0.0.24",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",
diff --git a/extension/package.json b/extension/package.json
index c979a435..a44b5d36 100644
--- a/extension/package.json
+++ b/extension/package.json
@@ -14,7 +14,7 @@
"displayName": "Continue",
"pricing": "Free",
"description": "Refine code 10x faster",
- "version": "0.0.23",
+ "version": "0.0.24",
"publisher": "Continue",
"engines": {
"vscode": "^1.74.0"
diff --git a/extension/scripts/continuedev-0.1.1-py3-none-any.whl b/extension/scripts/continuedev-0.1.1-py3-none-any.whl
index e9d03c6e..5be92214 100644
--- a/extension/scripts/continuedev-0.1.1-py3-none-any.whl
+++ b/extension/scripts/continuedev-0.1.1-py3-none-any.whl
Binary files differ