From dd95670e40323bf25d62381c097fec6e38f7fb65 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Thu, 12 Oct 2023 13:54:29 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20add=20python=20path=20to=20globa?= =?UTF-8?q?l=20vscode=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extension/src/activation/activate.ts | 4 ++-- server/continuedev/libs/llm/base.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts index edd13137a..e025e0faf 100644 --- a/extension/src/activation/activate.ts +++ b/extension/src/activation/activate.ts @@ -42,7 +42,7 @@ function addPythonPathForConfig() { const pathToAdd = extensionContext?.extensionPath; if (analysisPaths && pathToAdd && !analysisPaths.includes(pathToAdd)) { analysisPaths.push(pathToAdd); - pythonConfig.update("analysis.extraPaths", analysisPaths); + pythonConfig.update("analysis.extraPaths", analysisPaths, vscode.ConfigurationTarget.Global); } if ( @@ -51,7 +51,7 @@ function addPythonPathForConfig() { !autoCompletePaths.includes(pathToAdd) ) { autoCompletePaths.push(pathToAdd); - pythonConfig.update("autoComplete.extraPaths", autoCompletePaths); + pythonConfig.update("autoComplete.extraPaths", autoCompletePaths, vscode.ConfigurationTarget.Global); } } diff --git a/server/continuedev/libs/llm/base.py b/server/continuedev/libs/llm/base.py index c10ef7155..4ba33101e 100644 --- a/server/continuedev/libs/llm/base.py +++ b/server/continuedev/libs/llm/base.py @@ -1,5 +1,6 @@ import ssl from textwrap import dedent +from time import time from typing import Any, Callable, Coroutine, Dict, Generator, List, Optional, Union import aiohttp @@ -428,15 +429,36 @@ Settings: completion = "" # Use the template_messages function if it exists and do a raw completion + ti = time() + tf = None if self.template_messages is None: async for chunk in self._stream_chat(messages=messages, options=options): yield chunk if "content" in chunk: completion += chunk["content"] + if tf is None: + tf = time() + ttft = tf - ti + posthog_logger.capture_event("time_to_first_token", { + "model": self.model, + "model_class": self.__class__.__name__, + "time": ttft, + "tokens": self.count_tokens(sum(m["content"] for m in messages)) + }) + else: async for chunk in self._stream_complete(prompt=prompt, options=options): yield {"role": "assistant", "content": chunk} completion += chunk + if tf is None: + tf = time() + ttft = tf - ti + posthog_logger.capture_event("time_to_first_token", { + "model": self.model, + "model_class": self.__class__.__name__, + "time": ttft, + "tokens": self.count_tokens(prompt) + }) # if log: # self.write_log(f"Completion: \n\n{completion}")