From deb291c1b225425cba543dd3b4c5557089abfb59 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 27 Aug 2023 22:11:52 -0700 Subject: fix: :bug: fix togetherAI model json parsing --- continuedev/src/continuedev/core/models.py | 1 + continuedev/src/continuedev/libs/llm/together.py | 5 +++-- continuedev/src/continuedev/server/gui.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'continuedev/src') diff --git a/continuedev/src/continuedev/core/models.py b/continuedev/src/continuedev/core/models.py index a8c97622..f03a8f29 100644 --- a/continuedev/src/continuedev/core/models.py +++ b/continuedev/src/continuedev/core/models.py @@ -46,6 +46,7 @@ MODEL_MODULE_NAMES = { "AnthropicLLM": "anthropic", "ReplicateLLM": "replicate", "Ollama": "ollama", + "LlamaCpp": "llamacpp", } diff --git a/continuedev/src/continuedev/libs/llm/together.py b/continuedev/src/continuedev/libs/llm/together.py index 9a28de2d..4baf0b6c 100644 --- a/continuedev/src/continuedev/libs/llm/together.py +++ b/continuedev/src/continuedev/libs/llm/together.py @@ -112,11 +112,12 @@ class TogetherLLM(LLM): "data: [DONE]" ): continue - if json_chunk.startswith("data: "): - json_chunk = json_chunk[6:] + chunks = json_chunk.split("\n") for chunk in chunks: if chunk.strip() != "": + if chunk.startswith("data: "): + chunk = chunk[6:] json_chunk = json.loads(chunk) if "choices" in json_chunk: yield { diff --git a/continuedev/src/continuedev/server/gui.py b/continuedev/src/continuedev/server/gui.py index 51dad8ed..08c5efc5 100644 --- a/continuedev/src/continuedev/server/gui.py +++ b/continuedev/src/continuedev/server/gui.py @@ -255,7 +255,9 @@ class GUIProtocolServer(AbstractGUIProtocolServer): # Replace default with either new one or existing from unused_models for unused_model in unused_models: if model_class == unused_model.__class__.__name__ and ( - "model" not in model or model["model"] == unused_model.model + "model" not in model + or model["model"] == unused_model.model + and model["model"].startswith("gpt") ): models.default = unused_model -- cgit v1.2.3-70-g09d2