Created
May 11, 2025 10:38
-
-
Save pavlovmilen/2e12d580dbd4d17d66d37ee65fe277fb to your computer and use it in GitHub Desktop.
market_research_team_run
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) | |
if isinstance(message, BaseChatMessage): | |
message_count += 1 | |
print(f'.................Message {message_count}.....................') | |
print(f"\033[93m........ Source: {message.source}\033[0m") | |
print(f"\033[94m{message.content}\033[0m") | |
if hasattr(message, 'models_usage') and message.models_usage is not None: | |
prompt = getattr(message.models_usage, 'prompt_tokens', 0) | |
completion = getattr(message.models_usage, 'completion_tokens', 0) | |
total_prompt_tokens += prompt | |
total_completion_tokens += completion | |
print(f"\033[91mInput tokens so far: {total_prompt_tokens}\033[0m") | |
print(f"\033[92mOutput tokens so far: {total_completion_tokens}\033[0m") | |
print(f"\033[91mTotal input tokens: {total_prompt_tokens}\033[0m") | |
print(f"\033[92mTotal output tokens: {total_completion_tokens}\033[0m") | |
await market_reserarch_agents_team.reset() | |
await runtime.stop() | |
print(f"\033[91mPrice of input tokens: £{total_prompt_tokens * 0.30 / 1000000}\033[0m") | |
print(f"\033[92mPrice of output tokens: £{total_completion_tokens * 1.20 / 1000000}\033[0m") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment