diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-09-05 10:14:16 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-09-05 10:14:16 -0700 |
commit | c9d96be5615b9d193a1eeff9ab00da7ca0fe0b6b (patch) | |
tree | d3d6f5261869a503d76d4e8e23f87cf52c28462f /continuedev | |
parent | 3fe2d88356888a174610ddc6c724f6d53701981f (diff) | |
download | sncontinue-c9d96be5615b9d193a1eeff9ab00da7ca0fe0b6b.tar.gz sncontinue-c9d96be5615b9d193a1eeff9ab00da7ca0fe0b6b.tar.bz2 sncontinue-c9d96be5615b9d193a1eeff9ab00da7ca0fe0b6b.zip |
feat: :sparkles: support browser-based IDEs with createMemoryRouter
Diffstat (limited to 'continuedev')
-rw-r--r-- | continuedev/src/continuedev/libs/llm/together.py | 24 |
1 files changed, 20 insertions, 4 deletions
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 |