sanket03 commited on
Commit
d01e6d1
·
1 Parent(s): 6d27b9f

Added Modular Structure and Stock Analyser usecase application

Browse files
.github/workflows/main.yaml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face Space
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ # to run this workflow manually from the Actions tab
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ sync-to-hub:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+ lfs: false
17
+
18
+ - name: Ignore large files
19
+ run : git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch "Rag_Documents/layout-parser-paper.pdf"' HEAD
20
+
21
+ - name: Push to hub
22
+ env:
23
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
24
+ run: git push --force https://sanket03:[email protected]/spaces/sanket03/AgnoAIAgents main
25
+
README.md CHANGED
@@ -1,2 +1,16 @@
1
- # agno-ai-agents
2
- Examples of Agents build with Agno AI Framework
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: AgnoAgenticAI
3
+ emoji: 🐨
4
+ colorFrom: blue
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.42.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ short_description: Refined AgnoAgenticAI
12
+ ---
13
+
14
+ ### End To End Agentic AI Projects
15
+
16
+
app.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from src.agnoai.main import load_agno_agenticai_app
2
+
3
+
4
+ if __name__=="__main__":
5
+ load_agno_agenticai_app()
requirements.txt CHANGED
@@ -13,4 +13,6 @@ duckduckgo-search
13
  yfinance
14
  sqlalchemy
15
  fastapi[standard]
 
 
16
 
 
13
  yfinance
14
  sqlalchemy
15
  fastapi[standard]
16
+ groq
17
+ langchain_core
18
 
src/__init__.py ADDED
File without changes
src/agnoai/LLMs/__init__.py ADDED
File without changes
src/agnoai/LLMs/groqllm.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from agno.models.groq import Groq
4
+
5
+ class GroqLLM:
6
+ def __init__(self,user_controls_input):
7
+ self.user_controls_input=user_controls_input
8
+
9
+ def get_llm_model(self):
10
+ try:
11
+ groq_api_key=self.user_controls_input['GROQ_API_KEY']
12
+ selected_groq_model=self.user_controls_input['selected_groq_model']
13
+ if groq_api_key=='' and os.environ["GROQ_API_KEY"] =='':
14
+ st.error("Please Enter the Groq API KEY")
15
+
16
+ llm = Groq(api_key=groq_api_key, id=selected_groq_model)
17
+
18
+ except Exception as e:
19
+ raise ValueError(f"Error Occurred with Exception : {e}")
20
+ return llm
src/agnoai/LLMs/openaillm.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from agno.models.openai import OpenAIChat
4
+
5
+ class OpenAILLM:
6
+ def __init__(self,user_controls_input):
7
+ self.user_controls_input=user_controls_input
8
+
9
+ def get_llm_model(self):
10
+ try:
11
+ openai_api_key=self.user_controls_input['OPENAI_API_KEY']
12
+ selected_openai_model=self.user_controls_input['selected_openai_model']
13
+ if openai_api_key=='' and os.environ["OPENAI_API_KEY"] =='':
14
+ st.error("Please Enter the OpenAI API KEY")
15
+
16
+ llm = OpenAIChat(api_key=openai_api_key, id=selected_openai_model)
17
+
18
+ except Exception as e:
19
+ raise ValueError(f"Error Occurred with Exception : {e}")
20
+ return llm
src/agnoai/__init__.py ADDED
File without changes
src/agnoai/aiagents/__init__.py ADDED
File without changes
src/agnoai/aiagents/agents.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from agno.agent import Agent
2
+ from agno.models.openai import OpenAIChat
3
+ from agno.embedder.openai import OpenAIEmbedder
4
+ from agno.tools.duckduckgo import DuckDuckGoTools
5
+ from agno.tools.yfinance import YFinanceTools
6
+
7
+ class Agents:
8
+ def __init__(self, user_controls_input, model):
9
+ self.user_controls_input=user_controls_input
10
+ self.model = model
11
+
12
+ def web_agent(self):
13
+ web_aiagent = Agent(
14
+ name="Web Agent",
15
+ role="Search the web for information",
16
+ # model=self.user_controls_input["selected_llm"],
17
+ model=self.model,
18
+ tools=[DuckDuckGoTools()],
19
+ instructions="Always include sources",
20
+ show_tool_calls=True,
21
+ markdown=True,
22
+ )
23
+ return web_aiagent
24
+
25
+ def finance_agent(self):
26
+ finance_aiagent = Agent(
27
+ name="Finance Agent",
28
+ role="Get Financial Data",
29
+ # model=self.user_controls_input["selected_llm"],
30
+ model=self.model,
31
+ tools=[YFinanceTools(stock_price=True, analyst_recommendations=True,stock_fundamentals=True,company_info=True)],
32
+ instructions="Use tables to display data",
33
+ show_tool_calls=True,
34
+ markdown=True,
35
+ )
36
+ return finance_aiagent
37
+
38
+ def agent_team(self):
39
+ agent_aiteam = Agent(
40
+ team = [self.web_agent(), self.finance_agent()],
41
+ # model = self.user_controls_input["selected_llm"],
42
+ model=self.model,
43
+ instructions=["Always include sources", "Use tables to display data"],
44
+ show_tool_calls=True,
45
+ markdown=True,
46
+ )
47
+ return agent_aiteam
48
+
49
+
50
+
src/agnoai/aiagents/multiagents.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # from agents import Agents
2
+ # from agno.agent import Agent
3
+
4
+
5
+ # class MultiAgents:
6
+ # def __init__(self, Agents, user_controls_input):
7
+ # self.Agents = Agents()
8
+
9
+ # def agent_team(self):
src/agnoai/main.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import json
3
+ from src.agnoai.ui.streamlitui.loadui import LoadStreamlitUI
4
+ from src.agnoai.LLMs.groqllm import GroqLLM
5
+ from src.agnoai.LLMs.openaillm import OpenAILLM
6
+ from src.agnoai.aiagents.agents import Agents
7
+ from src.agnoai.ui.streamlitui.display_result import DisplayResultStreamlit
8
+
9
+ # Main Function
10
+ def load_agno_agenticai_app():
11
+
12
+ # Load UI
13
+ ui = LoadStreamlitUI()
14
+ user_input = ui.load_streamlit_ui()
15
+
16
+ if not user_input:
17
+ st.error("Error: Failed to load user input from the UI.")
18
+ return
19
+
20
+ # Text input for user message
21
+ if st.session_state.IsFetchButtonClicked:
22
+ user_message = st.session_state.timeframe
23
+ else :
24
+ user_message = st.chat_input("Enter your message:")
25
+
26
+ if user_message:
27
+ try:
28
+ if user_input['selected_llm']=='Groq':
29
+ obj_llm_config = GroqLLM(user_controls_input=user_input)
30
+ model = obj_llm_config.get_llm_model()
31
+
32
+ if not model:
33
+ st.error("Error: LLM model could not be initialized.")
34
+ return
35
+ elif user_input['selected_llm']=='OpenAI':
36
+ obj_llm_config = OpenAILLM(user_controls_input=user_input)
37
+ model = obj_llm_config.get_llm_model()
38
+
39
+ if not model:
40
+ st.error("Error: LLM model could not be initialized.")
41
+ return
42
+
43
+ ### Agents
44
+ agents = Agents(user_input, model)
45
+ agent_team = agents.agent_team()
46
+ DisplayResultStreamlit(agent_team, user_message).display_result_on_ui()
47
+
48
+
49
+ except Exception as e:
50
+ raise ValueError(f"Error Occurred with Exception : {e}")
src/agnoai/ui/__init__.py ADDED
File without changes
src/agnoai/ui/streamlitui/__init__.py ADDED
File without changes
src/agnoai/ui/streamlitui/display_result.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain_core.messages import HumanMessage,AIMessage,ToolMessage
3
+ import json
4
+
5
+ class DisplayResultStreamlit:
6
+ def __init__(self,agent_team,user_message):
7
+ self.agent_team = agent_team
8
+ self.user_message = user_message
9
+
10
+
11
+ def display_result_on_ui(self):
12
+ agent_team = self.agent_team
13
+ user_message = self.user_message
14
+
15
+ # # Streamlit Interface
16
+ # st.title("📈 Stock Analysis Expert")
17
+ # # Description of the application
18
+ # st.write("""
19
+ # Welcome to the Stock Analysis Expert dashboard! This interactive app helps you analyze stock performance using key technical indicators.
20
+ # You can explore historical stock data, visualize trends, and make informed investment decisions.
21
+ # """)
22
+
23
+ # # User Input
24
+ # user_input = st.text_input("Enter your question:")
25
+ # print(user_input)
26
+
27
+ # Display Response
28
+ if user_message:
29
+ with st.spinner("Thinking..."):
30
+ response = agent_team.run(user_message)
31
+ st.markdown(response.get_content_as_string())
32
+
33
+
src/agnoai/ui/streamlitui/loadui.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ from datetime import date
4
+
5
+ # from langchain_core.messages import AIMessage,HumanMessage
6
+ from src.agnoai.ui.uiconfigfile import Config
7
+
8
+ class LoadStreamlitUI:
9
+ def __init__(self):
10
+ self.config = Config()
11
+ self.user_controls = {}
12
+
13
+ def initialize_session(self):
14
+ return {
15
+ "current_step": "requirements",
16
+ "requirements": "",
17
+ "user_stories": "",
18
+ "po_feedback": "",
19
+ "generated_code": "",
20
+ "review_feedback": "",
21
+ "decision": None
22
+ }
23
+
24
+ def load_streamlit_ui(self):
25
+ st.set_page_config(page_title= "🤖 " + self.config.get_page_title(), layout="wide")
26
+ st.header("🤖 " + self.config.get_page_title())
27
+ st.session_state.timeframe = ''
28
+ st.session_state.IsFetchButtonClicked = False
29
+ st.session_state.IsSDLC = False
30
+
31
+ with st.sidebar:
32
+ # Get options from config
33
+ llm_options = self.config.get_llm_options()
34
+ usecase_options = self.config.get_usecase_options()
35
+
36
+ # LLM selection
37
+ self.user_controls["selected_llm"] = st.selectbox("Select LLM", llm_options)
38
+
39
+ if self.user_controls["selected_llm"] == 'Groq':
40
+ # Model selection
41
+ model_options = self.config.get_groq_model_options()
42
+ self.user_controls["selected_groq_model"] = st.selectbox("Select Model", model_options)
43
+ # API key input
44
+ self.user_controls["GROQ_API_KEY"] = st.session_state["GROQ_API_KEY"] = st.text_input("API Key",
45
+ type="password")
46
+ # Validate API key
47
+ if not self.user_controls["GROQ_API_KEY"]:
48
+ st.warning("⚠️ Please enter your GROQ API key to proceed. Don't have? refer : https://console.groq.com/keys ")
49
+
50
+ elif self.user_controls["selected_llm"] == 'OpenAI':
51
+ # Model selection
52
+ model_options = self.config.get_openai_model_options()
53
+ self.user_controls["selected_openai_model"] = st.selectbox("Select Model", model_options)
54
+ # API key input
55
+ self.user_controls["OPENAI_API_KEY"] = st.session_state["OPENAI_API_KEY"] = st.text_input("API Key",
56
+ type="password")
57
+ # Validate API key
58
+ if not self.user_controls["OPENAI_API_KEY"]:
59
+ st.warning("⚠️ Please enter your OpenAI API key to proceed. Don't have? refer : https://platform.openai.com/api-keys ")
60
+
61
+ # Use case selection
62
+ self.user_controls["selected_usecase"] = st.selectbox("Select Usecases", usecase_options)
63
+
64
+ if "state" not in st.session_state:
65
+ st.session_state.state = self.initialize_session()
66
+
67
+
68
+
69
+ return self.user_controls
src/agnoai/ui/uiconfigfile.ini ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ [DEFAULT]
2
+ PAGE_TITLE = AGNO : Quickly Build AI Agents
3
+ LLM_OPTIONS = Groq, OpenAI
4
+ USECASE_OPTIONS = Stock Analyser
5
+ GROQ_MODEL_OPTIONS = llama-3.3-70b-versatile, llama-3.1-8b-instant, mixtral-8x7b-32768, gemma2-9b-it, qwen-2.5-32b, deepseek-r1-distill-qwen-32b, deepseek-r1-distill-llama-70b-specdec, deepseek-r1-distill-llama-70b
6
+ OPENAI_MODEL_OPTIONS = gpt-4o, gpt-4o-mini
src/agnoai/ui/uiconfigfile.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from configparser import ConfigParser
2
+
3
+ class Config:
4
+ def __init__(self, config_file = "./src/agnoai/ui/uiconfigfile.ini"):
5
+ self.config = ConfigParser()
6
+ self.config.read(config_file)
7
+
8
+ def get_llm_options(self):
9
+ return self.config["DEFAULT"].get("LLM_OPTIONS").split(", ")
10
+
11
+ def get_usecase_options(self):
12
+ return self.config["DEFAULT"].get("USECASE_OPTIONS").split(", ")
13
+
14
+ def get_groq_model_options(self):
15
+ return self.config["DEFAULT"].get("GROQ_MODEL_OPTIONS").split(", ")
16
+
17
+ def get_openai_model_options(self):
18
+ return self.config["DEFAULT"].get("OPENAI_MODEL_OPTIONS")
19
+
20
+ def get_page_title(self):
21
+ return self.config["DEFAULT"].get("PAGE_TITLE")