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 +++- extension/react-app/src/components/ModelSelect.tsx | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) 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 diff --git a/extension/react-app/src/components/ModelSelect.tsx b/extension/react-app/src/components/ModelSelect.tsx index 9699847c..9134cd7d 100644 --- a/extension/react-app/src/components/ModelSelect.tsx +++ b/extension/react-app/src/components/ModelSelect.tsx @@ -60,7 +60,7 @@ const MODEL_INFO: { title: string; class: string; args: any }[] = [ title: "TogetherAI", class: "TogetherLLM", args: { - model: "gpt-4", + model: "togethercomputer/CodeLlama-13b-Instruct", api_key: "", }, }, -- cgit v1.2.3-70-g09d2