Here's my method for creating the agent:
{
string openAIAPIKey = "My-super secret API Key";
OpenAIConfig llmConfig = new OpenAIConfig(openAIAPIKey, "gpt-4-turbo");
TypeSafeFunctionCall tools = new TypeSafeFunctionCall();
MiddlewareAgent<ConversableAgent> weatherAgent = new ConversableAgent(
name: "weatherAgent",
systemMessage: "Only use the tools you have been provided with. Reply TERMINATE when the task is done.",
llmConfig: new ConversableAgentConfig {
Temperature = 0,
ConfigList = new[] { llmConfig },
FunctionContracts = new[]
{
tools.WeatherReportFunctionContract,
tools.GetLocalizationFunctionContract,
tools.GetDateFunctionContract
}
},
humanInputMode: HumanInputMode.NEVER,
functionMap: new Dictionary<string, Func<string, Task<string>>>
{
{ tools.WeatherReportFunctionContract.Name, tools.WeatherReportWrapper },
{ tools.GetLocalizationFunctionContract.Name, tools.GetLocalizationWrapper },
{ tools.GetDateFunctionContract.Name, tools.GetDateWrapper }
}).RegisterPrintMessage();
MiddlewareAgent<UserProxyAgent> userProxy = new UserProxyAgent(
name: "userProxy",
isTermination: async (messages, token) => messages.LastOrDefault()?.GetContent() == null ? false : (messages.LastOrDefault().GetContent().Contains("TERMINATE") ? true : false),
humanInputMode: HumanInputMode.AUTO,
defaultReply: "If you send the \"Final Answer\" reply TERMINATE. Otherwise, reply CONTINUE and the \"Thought\", \"Action\", \"Action input\" or \"Observation\" of the current step."
).RegisterPrintMessage();