microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
31.24k stars 4.56k forks source link

[Issue]: Local Ollama function call without docker get error #2727

Closed lugq1990 closed 4 months ago

lugq1990 commented 4 months ago

Describe the issue

Hi there,

Per running the example to use Ollama functionality with liteLLM from the document side that I found that if we don't config the code_execution_config, then will get error:

sample code:

user_proxy = UserProxyAgent('user_proxy', 
                            is_termination_msg=lambda x: x.get('content', '') and "TERMINATE" in x.get('content', ''),
                            human_input_mode='NEVER',
                            max_consecutive_auto_reply=1, 
                            )

Get output log

RuntimeError: Code execution is set to be run in docker (default behaviour) but docker is not running.
The options available are:
- Make sure docker is running (advised approach for code execution)
- Set "use_docker": False in code_execution_config
- Set AUTOGEN_USE_DOCKER to "0/False/no" in your environment variables

Steps to reproduce

With the document code as sample to use LiteLLM


config_list = [
    {
        'model': 'NotRequired',
        'base_url': "http://localhost:4000",
        'api_key': 'NotRequired'
    }
]

assistent = AssistantAgent('assistant', llm_config={'config_list': config_list})

agent = ConversableAgent('agent', llm_config=config_list[0])

# user_proxy = UserProxyAgent('user_proxy', code_execution_config={'work_dir': 'code', 'use_docker': False})

# agent.initiate_chat(assistent, message='what could you do for me?')
# 
# ---> with func call

chatbot = AssistantAgent(
    name="chatbot",
    system_message="""For currency exchange tasks,
        only use the functions you have been provided with.
        Output 'TERMINATE' when an answer has been provided.
        Do not include the function name or result in the JSON.
        Example of the return JSON is:
        {
            "parameter_1_name": 100.00,
            "parameter_2_name": "ABC",
            "parameter_3_name": "DEF",
        }.
        Another example of the return JSON is:
        {
            "parameter_1_name": "GHI",
            "parameter_2_name": "ABC",
            "parameter_3_name": "DEF",
            "parameter_4_name": 123.00,
        }. """,

    llm_config=config_list[0],
)

user_proxy = UserProxyAgent('user_proxy', 
                            is_termination_msg=lambda x: x.get('content', '') and "TERMINATE" in x.get('content', ''),
                            human_input_mode='NEVER',
                            max_consecutive_auto_reply=1, 
                            )

cu = Literal['USD', 'EUR']

def exchange_rate(baes: cu, new:cu) -> float:
    if baes == new:
        return 1.0
    elif baes == "USD" and new == 'EUR':
        return 1/ 1.1
    elif baes == 'EUR' and new == "USD":
        return 1.1
    else:
        raise ValueError("Not good")

@user_proxy.register_for_execution()
@chatbot.register_for_llm(description='Currency exchange calculator.') 
def currency_calculator(
    base_amount: Annotated[float, "Amount of currency in base_currency"],
    base_currency: Annotated[cu, "Base currency"] = "USD",
    quote_currency: Annotated[cu, "Quote currency"] = "EUR",
) -> str:
    quote_amount = exchange_rate(base_currency, quote_currency) * base_amount
    return f"{format(quote_amount, '.2f')} {quote_currency}"

res = user_proxy.initiate_chat(chatbot, message='How much is 123.45 EUR in USD?', summary_method='reflection_with_llm')

wiil get error:

RuntimeError: Code execution is set to be run in docker (default behaviour) but docker is not running.
The options available are:
- Make sure docker is running (advised approach for code execution)
- Set "use_docker": False in code_execution_config
- Set AUTOGEN_USE_DOCKER to "0/False/no" in your environment variables

Screenshots and logs

RuntimeError: Code execution is set to be run in docker (default behaviour) but docker is not running. The options available are:

Additional Information

No response

ekzhu commented 4 months ago

We have moved on to use code executors: https://microsoft.github.io/autogen/docs/tutorial/code-executors

lugq1990 commented 4 months ago

Ok, with code executors to make it work