Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: Asyncify model listing for Together (#2286)

Matthew Zhouc54b557ca160
diff --git a/letta/schemas/providers.py b/letta/schemas/providers.py
index 52066b8d2..651f9b213 100644
--- a/letta/schemas/providers.py
+++ b/letta/schemas/providers.py
@@ -1027,14 +1027,24 @@ class TogetherProvider(OpenAIProvider):
def list_llm_models(self) -> List[LLMConfig]:
from letta.llm_api.openai import openai_get_model_list
- response = openai_get_model_list(self.base_url, api_key=self.api_key)
+ models = openai_get_model_list(self.base_url, api_key=self.api_key)
+ return self._list_llm_models(models)
+
+ async def list_llm_models_async(self) -> List[LLMConfig]:
+ from letta.llm_api.openai import openai_get_model_list_async
+
+ models = await openai_get_model_list_async(self.base_url, api_key=self.api_key)
+ return self._list_llm_models(models)
+
+ def _list_llm_models(self, models) -> List[LLMConfig]:
+ pass
# TogetherAI's response is missing the 'data' field
# assert "data" in response, f"OpenAI model query response missing 'data' field: {response}"
- if "data" in response:
- data = response["data"]
+ if "data" in models:
+ data = models["data"]
else:
- data = response
+ data = models
configs = []
for model in data:
diff --git a/tests/test_providers.py b/tests/test_providers.py
index 44846d096..96010e9a1 100644
--- a/tests/test_providers.py
+++ b/tests/test_providers.py
@@ -178,6 +178,23 @@ def test_together():
# assert embedding_models[0].handle == f"{provider.name}/{embedding_models[0].embedding_model}"
+async def test_together_async():
+ provider = TogetherProvider(
+ name="together",
+ api_key=model_settings.together_api_key,
+ default_prompt_formatter=model_settings.default_prompt_formatter,
+ )
+ models = await provider.list_llm_models_async()
+ assert len(models) > 0
+ assert models[0].handle == f"{provider.name}/{models[0].model}"
+
+ # TODO: We don't have embedding models on together for CI
+ # embedding_models = provider.list_embedding_models()
+ # assert len(embedding_models) > 0
+ # assert embedding_models[0].handle == f"{provider.name}/{embedding_models[0].embedding_model}"
+
+
# TODO: Add back in, difficulty adding this to CI properly, need boto credentials
# def test_anthropic_bedrock():
# from letta.settings import model_settings