Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
migrate to using completions endpoint by default (#628)
Charles Packer070c0123c625
diff --git a/docs/lmstudio.md b/docs/lmstudio.mdindex 2314aec3b..80f0ba3af 100644--- a/docs/lmstudio.md+++ b/docs/lmstudio.md@@ -6,6 +6,12 @@**Context Overflow Policy = Stop at limit**: If you see "Context Overflow Policy" inside LM Studio's "Tools" panel on the right side (below "Server Model Settings"), set it to **Stop at limit**. The default setting "Keep the system prompt ... truncate middle" will break MemGPT.+!!! note "Update your LM Studio"++ The current `lmstudio` backend will only work if your LM Studio is version 0.2.9 or newer.++ If you are on a version of LM Studio older than 0.2.9 (<= 0.2.8), select `lmstudio-legacy` as your backend type.+<img width="911" alt="image" src="https://github.com/cpacker/MemGPT/assets/5475622/d499e82e-348c-4468-9ea6-fd15a13eb7fa">1. Download [LM Studio](https://lmstudio.ai/) and the model you want to test withdiff --git a/memgpt/cli/cli_config.py b/memgpt/cli/cli_config.pyindex 787d6bb59..010326e41 100644--- a/memgpt/cli/cli_config.py+++ b/memgpt/cli/cli_config.py@@ -60,7 +60,7 @@ def configure_llm_endpoint(config: MemGPTConfig):model_endpoint_type = "azure"model_endpoint = get_azure_credentials()["azure_endpoint"]else: # local models- backend_options = ["webui", "webui-legacy", "llamacpp", "koboldcpp", "ollama", "lmstudio", "vllm", "openai"]+ backend_options = ["webui", "webui-legacy", "llamacpp", "koboldcpp", "ollama", "lmstudio", "lmstudio-legacy", "vllm", "openai"]default_model_endpoint_type = Noneif config.model_endpoint_type in backend_options:# set from previous configdiff --git a/memgpt/local_llm/chat_completion_proxy.py b/memgpt/local_llm/chat_completion_proxy.pyindex dae3d9ca0..8a1954f18 100644--- a/memgpt/local_llm/chat_completion_proxy.py+++ b/memgpt/local_llm/chat_completion_proxy.py@@ -89,7 +89,9 @@ def get_chat_completion(elif endpoint_type == "webui-legacy":result, usage = get_webui_completion_legacy(endpoint, prompt, context_window, grammar=grammar_name)elif endpoint_type == "lmstudio":- result, usage = get_lmstudio_completion(endpoint, prompt, context_window)+ result, usage = get_lmstudio_completion(endpoint, prompt, context_window, api="completions")+ elif endpoint_type == "lmstudio-legacy":+ result, usage = get_lmstudio_completion(endpoint, prompt, context_window, api="chat")elif endpoint_type == "llamacpp":result, usage = get_llamacpp_completion(endpoint, prompt, context_window, grammar=grammar_name)elif endpoint_type == "koboldcpp":diff --git a/memgpt/local_llm/constants.py b/memgpt/local_llm/constants.pyindex bcdf830e5..b53b6ead6 100644--- a/memgpt/local_llm/constants.py+++ b/memgpt/local_llm/constants.py@@ -4,6 +4,7 @@ DEFAULT_ENDPOINTS = {"koboldcpp": "http://localhost:5001","llamacpp": "http://localhost:8080","lmstudio": "http://localhost:1234",+ "lmstudio-legacy": "http://localhost:1234","ollama": "http://localhost:11434","webui-legacy": "http://localhost:5000","webui": "http://localhost:5000",diff --git a/memgpt/local_llm/lmstudio/api.py b/memgpt/local_llm/lmstudio/api.pyindex 183e440e9..2c6af47e1 100644--- a/memgpt/local_llm/lmstudio/api.py+++ b/memgpt/local_llm/lmstudio/api.py@@ -10,7 +10,7 @@ LMSTUDIO_API_COMPLETIONS_SUFFIX = "/v1/completions"# TODO move to "completions" by default, not "chat"-def get_lmstudio_completion(endpoint, prompt, context_window, settings=SIMPLE, api="chat"):+def get_lmstudio_completion(endpoint, prompt, context_window, settings=SIMPLE, api="completions"):"""Based on the example for using LM Studio as a backend from https://github.com/lmstudio-ai/examples/tree/main/Hello%2C%20world%20-%20OpenAI%20python%20client"""from memgpt.utils import printd