From c9d96be5615b9d193a1eeff9ab00da7ca0fe0b6b Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 5 Sep 2023 10:14:16 -0700 Subject: feat: :sparkles: support browser-based IDEs with createMemoryRouter --- continuedev/src/continuedev/libs/llm/together.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'continuedev') diff --git a/continuedev/src/continuedev/libs/llm/together.py b/continuedev/src/continuedev/libs/llm/together.py index 1b91ec43..a9db70c6 100644 --- a/continuedev/src/continuedev/libs/llm/together.py +++ b/continuedev/src/continuedev/libs/llm/together.py @@ -3,6 +3,7 @@ from typing import Callable, Optional import aiohttp +from ...core.main import ContinueCustomException from ..llm import LLM from ..util.logging import logger from .prompts.chat import llama2_template_messages @@ -80,7 +81,22 @@ class TogetherLLM(LLM): ) as resp: text = await resp.text() j = json.loads(text) - if "choices" not in j["output"]: - raise Exception(text) - if "output" in j: - return j["output"]["choices"][0]["text"] + try: + if "choices" not in j["output"]: + raise Exception(text) + if "output" in j: + return j["output"]["choices"][0]["text"] + except Exception as e: + j = await resp.json() + if "error" in j: + if j["error"].startswith("invalid hexlify value"): + raise ContinueCustomException( + message=f"Invalid Together API key:\n\n{j['error']}", + title="Together API Error", + ) + else: + raise ContinueCustomException( + message=j["error"], title="Together API Error" + ) + + raise e -- cgit v1.2.3-70-g09d2