feat: ✨ testing improved prompting for stablecode

This commit is contained in:
Nate Sesti 2023-08-08 20:18:40 -07:00
parent adae79d98d
commit 6112f26888
7 changed files with 24 additions and 11 deletions

View file

@ -55,7 +55,7 @@ class ContinueSDK(AbstractContinueSDK):
formatted_err = '\n'.join(traceback.format_exception(e))
msg_step = MessageStep(
name="Invalid Continue Config File", message=formatted_err)
msg_step.description = f"Falling back to default config settings.\n```\n{formatted_err}\n```\n\nIt's possible this error was caused by an update to the Continue config format. If you'd like to see the new recommended default `config.py`, check [here](https://github.com/continuedev/continue/blob/main/continuedev/src/continuedev/libs/constants/default_config.py)."
msg_step.description = f"Falling back to default config settings due to the following error in `~/.continue/config.py`.\n```\n{formatted_err}\n```\n\nIt's possible this was caused by an update to the Continue config format. If you'd like to see the new recommended default `config.py`, check [here](https://github.com/continuedev/continue/blob/main/continuedev/src/continuedev/libs/constants/default_config.py)."
sdk.history.add_node(HistoryNode(
step=msg_step,
observation=None,

View file

@ -37,10 +37,17 @@ class ReplicateLLM(LLM):
pass
async def complete(self, prompt: str, with_history: List[ChatMessage] = None, **kwargs):
output = self._client.run(self.model, input={"message": prompt})
completion = ''
for item in output:
completion += item
def helper():
output = self._client.run(self.model, input={"message": prompt})
completion = ''
for item in output:
completion += item
return completion
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(helper)
completion = future.result()
return completion

View file

@ -56,7 +56,8 @@ class DefaultPolicy(Policy):
MessageStep(name="Welcome to Continue", message=dedent("""\
- Highlight code section and ask a question or give instructions
- Use `cmd+m` (Mac) / `ctrl+m` (Windows) to open Continue
- Use `/help` to ask questions about how to use Continue""")) >>
- Use `/help` to ask questions about how to use Continue
- [Customize Continue](https://continue.dev/docs/customization) (e.g. use your own API key) by typing '/config'.""")) >>
WelcomeStep() >>
StepsOnStartupStep())

View file

@ -10,6 +10,7 @@ import difflib
from pydantic import validator
from ....libs.llm.ggml import GGML
from ....libs.llm.replicate import ReplicateLLM
from ....models.main import Range
from ....libs.llm.maybe_proxy_openai import MaybeProxyOpenAI
from ....models.filesystem_edit import EditDiff, FileEdit, FileEditWithFullContents, FileSystemEdit
@ -512,6 +513,9 @@ Please output the code to be inserted at the cursor in order to fulfill the user
if isinstance(model_to_use, GGML):
messages = [ChatMessage(
role="user", content=f"```\n{rif.contents}\n```\n\nUser request: \"{self.user_input}\"\n\nThis is the code after changing to perfectly comply with the user request. It does not include any placeholder code, only real implementations:\n\n```\n", summary=self.user_input)]
elif isinstance(model_to_use, ReplicateLLM):
messages = [ChatMessage(
role="user", content=f"// Previous implementation\n\n{rif.contents}\n\n// Updated implementation (after following directions: {self.user_input})\n\n", summary=self.user_input)]
generator = model_to_use.stream_chat(
messages, temperature=sdk.config.temperature, max_tokens=max_tokens)

View file

@ -59,12 +59,12 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
"data": data
})
async def _receive_json(self, message_type: str, timeout: int = 20) -> Any:
async def _receive_json(self, message_type: str, timeout: int = 10) -> Any:
try:
return await asyncio.wait_for(self.sub_queue.get(message_type), timeout=timeout)
except asyncio.TimeoutError:
raise Exception(
"GUI Protocol _receive_json timed out after 20 seconds")
"GUI Protocol _receive_json timed out after 10 seconds")
async def _send_and_receive_json(self, data: Any, resp_model: Type[T], message_type: str) -> T:
await self._send_json(message_type, data)

View file

@ -165,12 +165,12 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
"data": data
})
async def _receive_json(self, message_type: str, timeout: int = 20) -> Any:
async def _receive_json(self, message_type: str, timeout: int = 10) -> Any:
try:
return await asyncio.wait_for(self.sub_queue.get(message_type), timeout=timeout)
except asyncio.TimeoutError:
raise Exception(
f"IDE Protocol _receive_json timed out after 20 seconds: {message_type}")
f"IDE Protocol _receive_json timed out after 10 seconds: {message_type}")
async def _send_and_receive_json(self, data: Any, resp_model: Type[T], message_type: str) -> T:
await self._send_json(message_type, data)

View file

@ -10,7 +10,8 @@ const initialState: FullState = {
hide: false,
description: `- Highlight code section and ask a question or give instructions
- Use \`cmd+m\` (Mac) / \`ctrl+m\` (Windows) to open Continue
- Use \`/help\` to ask questions about how to use Continue`,
- Use \`/help\` to ask questions about how to use Continue
- [Customize Continue](https://continue.dev/docs/customization) (e.g. use your own API key) by typing '/config'.`,
system_message: null,
chat_context: [],
manage_own_chat_context: false,