Skip to content

Version 0.3.2

Choose a tag to compare

@beansrowning beansrowning released this 01 May 20:43
· 179 commits to master since this release
2f4c046

New Features

OpenAI Provider

I have no use for this, but one can now use standard OpenAI as a provider if you have API access. It works functionally the same, and just extends the AzureOpenAI class to ignore using Azure Entra ID for auth.

@agent_callable() and @async_agent_callable

Despite OpenAI "encouraging you to define your schemas directly", this is painful and duplicative when most of the metadata needed is already present if you document your code well. Humans manually producing JSON entries for their functions sounds like an anti-pattern to me.

You can, of course, always use Pydantic, but then you're still creating more duplication and one must then pass the Pydantic object thru as kwargs to the callable before evaluating. Safer? I guess. Easier? No, not really.

So scratch all of that. This is some syntactic sugar which auto-generates a nice JSON payload for your tool, provided you've added type-hints to your arguments. You'll only need to bring two additional arguments:

  • description: What the LLM will see as the description of your tool; what it does and how to use it.
  • variable_description: A dict with keys for each arg, and values giving a short description of that arg

It's pretty smart about figuring out how to code up lists, dicts, literals, unions, etc. Your mileage may vary, and when in doubt, you can always do it the old fashioned way.

Example

import agents
from typing import Optional

class MyAgent(agents.Agent):
  @agents.async_agent_callable("A function that returns 'hello, x' when called.", {"x": "The second word in the statement to return"})
  async def hello_world(self, x: Optional[str] = None):
    if x is None:
      x = "world"
    return "hello, {x}"

Changes

  • Fixes issue where StructuredReturnAgent warned at init if a different stopping condition is used (now will only warn once per session)
  • Allows kwargs passed to BatchProcessor to pass through to Agent, allowing for static formatting strings across batches
  • Fixes #14
  • Fixes #15
  • Added a single unit test

Full Changelog: v0.3.1...v0.3.2