Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function calling upgrade #1443

Merged
merged 7 commits into from
Jan 31, 2024
Merged

Function calling upgrade #1443

merged 7 commits into from
Jan 31, 2024

Conversation

davorrunje
Copy link
Collaborator

@davorrunje davorrunje commented Jan 29, 2024

Why are these changes needed?

Two improvements related to recent feedback from Discord:

  • async/sync mixing of functions and chat initiations works now for all combinations. Previously it was silently ignored in some cases which caused an exception to be raised later making it hard to debug.
  • an additional utility function register_function was added to simplify the registration of functions without decorators.
def currency_calculator(
  base: Annotated[Currency, "Base currency: amount and currency symbol"],
  quote_currency: Annotated[CurrencySymbol, "Quote currency symbol"] = "USD",
) -> Currency:
  quote_amount = exchange_rate(base.currency, quote_currency) * base.amount
  return Currency(amount=quote_amount, currency=quote_currency)

autogen.agentchat.register_function(
    currency_calculator,
    caller=chatbot,
    executor=user_proxy,
    description="Currency exchange calculator.",
)

Related issue number

Checks

…ations and register_function added to simplify registration of functions without decorators
@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (0107b52) 32.69% compared to head (9b007bd) 45.70%.

Files Patch % Lines
autogen/agentchat/conversable_agent.py 84.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1443       +/-   ##
===========================================
+ Coverage   32.69%   45.70%   +13.00%     
===========================================
  Files          42       42               
  Lines        5019     5039       +20     
  Branches     1151     1220       +69     
===========================================
+ Hits         1641     2303      +662     
+ Misses       3248     2552      -696     
- Partials      130      184       +54     
Flag Coverage Δ
unittests 45.62% <85.18%> (+12.96%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In notebooks, when calling initiate_chat and a_initiate_chat we can use the with Cache.disk() as cache context to make user aware of the cache feature. So we can gradually get rid of the legacy cache_seed setting in llm_config.

@sonichi
Copy link
Contributor

sonichi commented Jan 30, 2024

I guess the test failure is due to a recent change #1471

@afourney
Copy link
Member

I guess the test failure is due to a recent change #1471

Yes. Just remove the "Tool Call Id: ...\n" lines from the content fields of the test.

@davorrunje
Copy link
Collaborator Author

I guess the test failure is due to a recent change #1471

Yes. Just remove the "Tool Call Id: ...\n" lines from the content fields of the test.

Yup, that was it. Thanx!

@sonichi sonichi added this pull request to the merge queue Jan 31, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 31, 2024
@sonichi sonichi added this pull request to the merge queue Jan 31, 2024
Merged via the queue into main with commit a2d4b47 Jan 31, 2024
50 of 56 checks passed
@davorrunje davorrunje deleted the add-register-function branch January 31, 2024 22:12
whiskyboy pushed a commit to whiskyboy/autogen that referenced this pull request Apr 17, 2024
* function calling upgraded: async/sync mixing works now for all combinations and register_function added to simplify registration of functions without decorators

* polishing

* fixing tests

---------

Co-authored-by: Eric Zhu <[email protected]>
Co-authored-by: Chi Wang <[email protected]>
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.

None yet

5 participants