Sunday, April 19, 2026

Create simple AI Agent using Microsoft Autogen and Ollama(OpenSource) to plot a Stock Chart.

Picture 1

Just share share what I found out today. Both Microsoft Autogen and Ollama are open source, hence they are free to try out in own laptop. 

Firstly, need to install Autogen and Ollama(in laptop also) in python.

The code to create the agent is simple as below.

from autogen import AssistantAgent, UserProxyAgent

config_list = [

{

    "model":"kimi-k2.5:cloud",

    "base_url": "http://localhost:11434/v1",

            "api_key": "ollama",

}

]

assistant = AssistantAgent("assistant", llm_config={"config_list": config_list})

user_proxy = UserProxyAgent("user_proxy", code_execution_config={"work_dir":"coding","use_docker": False})

user_proxy.initiate_chat(assistant, message="Plot a chart of NVDA and TESLA stock price change YTD. Get information using yfinance. Save the graph as Stock1.png")


The output is as below when the code is run.


A graph as shown in Picture 1 is drawn and save as .png file.


Reference

https://www.youtube.com/watch?v=DMYCJe1vBVA

No comments:

Post a Comment