Skip to content

Comments

feat: Add ModelsLab model client (autogen-ext)#7245

Open
adhikjoshi wants to merge 3 commits intomicrosoft:mainfrom
adhikjoshi:feat/add-modelslab-client
Open

feat: Add ModelsLab model client (autogen-ext)#7245
adhikjoshi wants to merge 3 commits intomicrosoft:mainfrom
adhikjoshi:feat/add-modelslab-client

Conversation

@adhikjoshi
Copy link

feat: Add ModelsLab chat completion client to autogen-ext

Summary

Adds ModelsLabChatCompletionClient to autogen-ext, giving AutoGen agents access to ModelsLab's uncensored Llama 3.1 8B and 70B models with 128K context windows via an OpenAI-compatible API.

What is ModelsLab?

ModelsLab is an AI API platform providing uncensored language models at competitive pricing — ideal for agents performing creative writing, research, and tasks where standard content filters are too limiting.

Files

New files

File Description
src/autogen_ext/models/modelslab/__init__.py Package exports
src/autogen_ext/models/modelslab/_client.py ModelsLabChatCompletionClient
tests/models/test_modelslab_client.py 15 test cases

Modified files (one-line patch)

src/autogen_ext/models/__init__.py:

+from autogen_ext.models.modelslab import ModelsLabChatCompletionClient

Implementation

Subclasses OpenAIChatCompletionClient with preset base_url, model_info, and MODELSLAB_API_KEY env var support:

class ModelsLabChatCompletionClient(OpenAIChatCompletionClient):
    def __init__(self, model="llama-3.1-8b-uncensored", api_key=None, ...):
        super().__init__(
            model=model,
            api_key=api_key or os.environ["MODELSLAB_API_KEY"],
            base_url="https://modelslab.com/uncensored-chat/v1",
            model_info=_MODELSLAB_MODEL_INFO[model],
            ...
        )

Pre-registered ModelInfo for both models (128K context, no vision, function calling enabled).

Usage

import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.models.modelslab import ModelsLabChatCompletionClient

model_client = ModelsLabChatCompletionClient(model="llama-3.1-8b-uncensored")

async def main():
    agent = AssistantAgent("assistant", model_client=model_client)
    await Console(agent.run_stream(task="Write a Python quicksort implementation."))

asyncio.run(main())

Models

Model Context Notes
llama-3.1-8b-uncensored 128K Default — fast
llama-3.1-70b-uncensored 128K Higher quality

Checklist

  • Subclasses OpenAIChatCompletionClient — same pattern as Azure client
  • Pre-registered ModelInfo for both models (context, capabilities)
  • MODELSLAB_API_KEY env var support with clear error message
  • Explicit api_key overrides env var
  • Custom model_info override accepted
  • 15 unit tests
  • Docstring with usage example, model table, API links
  • No new dependencies beyond autogen-ext[openai]

@adhikjoshi
Copy link
Author

I agree to the CLA. @microsoft-github-policy-service agree

@adhikjoshi
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant