This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
az_client = AsyncOpenAI( | |
api_key=os.environ.get("AZURE_OPEN_AI_API_KEY_SWEDEN"), # Use your OpenAI API key | |
base_url=os.environ.get("AZURE_OPEN_AI_API_ENDPOINT_SWEDEN"), | |
) | |
gpt_model_client = AzureOpenAIChatCompletionClient( | |
model="gpt-4.1-mini-2025-04-14", | |
api_version="2024-06-01", | |
azure_deployment="gpt-4.1-mini", | |
azure_endpoint=os.environ.get("AZURE_OPEN_AI_API_ENDPOINT_SWEDEN"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from azure.storage.blob import BlobServiceClient | |
from datetime import datetime | |
from dotenv import load_dotenv | |
load_dotenv() | |
connection_string = os.getenv('storage_connection_string') | |
def upload_ai_report(report_summary: str, ticker: str): | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
from dotenv import load_dotenv | |
from autogen_agentchat.agents import AssistantAgent | |
from autogen_agentchat.base import TaskResult | |
from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination | |
from autogen_agentchat.messages import BaseChatMessage | |
from autogen_agentchat.teams import SelectorGroupChat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime = SingleThreadedAgentRuntime() | |
runtime.start() | |
message_count = 0 | |
total_prompt_tokens = 0 | |
total_completion_tokens = 0 | |
async for message in market_reserarch_agents_team.run_stream(task="Hello, I would like to know if a stock with ticker=MSFT is a good pick for me to invest in this year?"): | |
if isinstance(message, TaskResult): | |
print("Stop Reason:", message.stop_reason) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gpt_model_client = AzureOpenAIChatCompletionClient( | |
model="gpt-4.1-mini-2025-04-14", | |
api_version="2024-06-01", | |
azure_deployment="gpt-4.1-mini", | |
azure_endpoint=os.environ.get("AZURE_OPEN_AI_API_ENDPOINT_SWEDEN"), | |
#azure_ad_token_provider=token_provider, # Optional if you choose key-based authentication. | |
api_key=os.environ.get("AZURE_OPEN_AI_API_KEY_SWEDEN"), | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
market_reserarch_agents_team = SelectorGroupChat( | |
[planning_agent, doji_agent, alpha_vantage_news_sentiment_agent, alpha_vantage_company_info_agent, fomc_summary_fetch_agent, peer_valuation_modeling_agent, report_generator_agent, report_upload_agent], | |
termination_condition=termination, | |
allow_repeated_speaker=True, | |
model_client=gpt_model_client, | |
selector_prompt=selector_prompt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selector_prompt = """Select an agent to perform task. | |
{roles} | |
Current conversation context: | |
{history} | |
Read the above conversation, then select an agent from {participants} to perform the next task. | |
Make sure the planner agent has assigned tasks before other agents start working. | |
Only select one agent at a time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doji_tool = FunctionTool(get_finance_data, description="Download last 60 days of OHLCV data") | |
doji_agent = AssistantAgent( | |
name="doji_agent", | |
model_client=gpt_model_client, | |
description="Spot daily doji patterns", | |
system_message=""" | |
You retrieve OHLCV data via doji_tool and detect doji candlesticks. | |
A daily bar is a doji when abs(Open – Close) ≤ 0.10 × (High – Low). | |
Steps: (1) call the tool, (2) run the test, (3) return a list of dates or an empty list if none. | |
Output strictly: comma-separated ISO dates. Provide explanations for the doji dates""", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
planning_agent = AssistantAgent( | |
"PlanningAgent", | |
description="An agent for planning tasks, this agent should be the first to engage when given a new task.", | |
model_client=gpt_model_client, | |
system_message=""" | |
You are a planning agent. | |
Your job is to break down complex tasks into smaller, manageable subtasks. | |
Your team members are: | |
doji_agent: Identify doji patterns in stock data using doji_tool | |
alpha_vantage_news_sentiment_agent: Search for a news sentiment about a stock using the search tool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// extract data as a string: | |
private string GetStringContentFromCrimeDataAIModel(List<CrimesAtLocationResponse> results, string postcode) | |
{ | |
if(results == null || !results.Any()) | |
{ | |
return "No data found"; | |
} | |
results = results.OrderBy(x => x.month).ToList(); |
NewerOlder