in workshop/dotnet/App/backend/Controllers/ChatController.cs [51:90]
private async Task<AzureAIAgent> GetAzureAIAgent()
{
var credential = GetDefaultAzureCredential();
var projectClient = new AIProjectClient(_connectionString, credential);
var clientProvider = AzureAIClientProvider.FromConnectionString(_connectionString, credential);
ConnectionResponse bingConnection = await projectClient.GetConnectionsClient().GetConnectionAsync(_groundingWithBingConnectionId);
var connectionId = bingConnection.Id;
ToolConnectionList connectionList = new ToolConnectionList
{
ConnectionList = { new ToolConnection(connectionId) }
};
BingGroundingToolDefinition bingGroundingTool = new BingGroundingToolDefinition(connectionList);
var definition = await _agentsClient.CreateAgentAsync(
_deploymentName,
instructions:
"""
Your responsibility is to find the stock sentiment for a given Stock, emitting advice in a creative and funny tone.
RULES:
- Report a stock sentiment scale from 1 to 10 where stock sentiment is 1 for sell and 10 for buy.
- Only use current data reputable sources such as Yahoo Finance, MarketWatch, Fidelity and similar.
- Provide the stock sentiment scale in your response and a recommendation to buy, hold or sell.
- Include the reasoning behind your recommendation.
- Be sure to cite the source of the information.
""",
tools:
[
bingGroundingTool
]);
var agent = new AzureAIAgent(definition, clientProvider)
{
Kernel = _kernel,
};
return agent;
}