genaitiwari commited on
Commit
3524557
·
1 Parent(s): 6040b2c

multi agent coder corrected

Browse files
README.md CHANGED
@@ -86,8 +86,9 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
86
  - Special thanks to all contributors and the open-source community.
87
  - Inspiration and support from our user base.
88
 
89
- ## Screeshot
90
  ### MultiAgent Coder and planner
 
91
  ![crewaidemo](image.png)
92
  ![alt text](image-1.png)
93
 
 
86
  - Special thanks to all contributors and the open-source community.
87
  - Inspiration and support from our user base.
88
 
89
+ ## Usecases
90
  ### MultiAgent Coder and planner
91
+ ![alt text](coder.png)
92
  ![crewaidemo](image.png)
93
  ![alt text](image-1.png)
94
 
coder.png ADDED
configfile.ini CHANGED
@@ -2,5 +2,6 @@
2
  PAGE_TITLE = CrewAI Studio
3
  LLM_OPTIONS = Groq, Huggingface
4
  USECASE_OPTIONS = MultiAgent Coder, MultiAgent SearchTool, MultiAgent Image
5
- GROQ_MODEL_OPTIONS = mixtral-8x7b-32768, llama3-8b-8192, llama3-70b-8192, gemma-7b-i
 
6
 
 
2
  PAGE_TITLE = CrewAI Studio
3
  LLM_OPTIONS = Groq, Huggingface
4
  USECASE_OPTIONS = MultiAgent Coder, MultiAgent SearchTool, MultiAgent Image
5
+ GROQ_MODEL_OPTIONS = gemma2-9b-it, mixtral-8x7b-32768, llama3-8b-8192, llama3-70b-8192,
6
+
7
 
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  streamlit
2
  langchain-core
3
- langchain-groq
4
  crewai
5
  crewai_tools
6
  duckduckgo-search
7
- langchain-community
 
 
1
  streamlit
2
  langchain-core
 
3
  crewai
4
  crewai_tools
5
  duckduckgo-search
6
+ langchain-community
7
+ groq
src/Handler/customhandler.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_core.callbacks import BaseCallbackHandler
2
+
3
+ class CustomHandler(BaseCallbackHandler):
4
+ """A custom handler for logging interactions within the process chain."""
5
+
6
+ def __init__(self, agent_name: str) -> None:
7
+ super().__init__()
8
+ self.agent_name = agent_name
9
+
10
+ def on_chain_start(self, serialized, outputs, **kwargs) -> None:
11
+ """Log the start of a chain with user input."""
12
+ from streamlit import session_state, chat_message
13
+ session_state.messages.append({"role": "assistant", "content": outputs['input']})
14
+ chat_message("assistant").write(outputs['input'])
15
+
16
+ def on_agent_action(self, serialized, inputs, **kwargs) -> None:
17
+ """Log the action taken by an agent during a chain run."""
18
+ from streamlit import session_state, chat_message
19
+ session_state.messages.append({"role": "assistant", "content": inputs['input']})
20
+ chat_message("assistant").write(inputs['input'])
21
+
22
+ def on_chain_end(self, outputs, **kwargs) -> None:
23
+ """Log the end of a chain with the output generated by an agent."""
24
+ import streamlit as st
25
+ from streamlit import session_state, chat_message
26
+ session_state.messages.append({"role": self.agent_name, "content": outputs['output']})
27
+ output = outputs['output']
28
+ st.write("**********")
29
+ st.write(self.agent_name)
30
+ st.write("**********")
31
+ if self.agent_name == 'Visual Content Creator':
32
+ chat_message(self.agent_name).image(f"{self.agent_name } : {output}")
33
+ else :
34
+ chat_message(self.agent_name).markdown(f"{self.agent_name } : {output}")
35
+
src/agents/agents.py CHANGED
@@ -1,47 +1,14 @@
1
- from langchain_core.callbacks import BaseCallbackHandler
2
  from crewai import Agent
3
- #from llm import groq
4
 
5
- class CustomHandler(BaseCallbackHandler):
6
- """A custom handler for logging interactions within the process chain."""
7
-
8
- def __init__(self, agent_name: str) -> None:
9
- super().__init__()
10
- self.agent_name = agent_name
11
-
12
- def on_chain_start(self, serialized, outputs, **kwargs) -> None:
13
- """Log the start of a chain with user input."""
14
- from streamlit import session_state, chat_message
15
- session_state.messages.append({"role": "assistant", "content": outputs['input']})
16
- chat_message("assistant").write(outputs['input'])
17
-
18
- def on_agent_action(self, serialized, inputs, **kwargs) -> None:
19
- """Log the action taken by an agent during a chain run."""
20
- from streamlit import session_state, chat_message
21
- session_state.messages.append({"role": "assistant", "content": inputs['input']})
22
- chat_message("assistant").write(inputs['input'])
23
-
24
- def on_chain_end(self, outputs, **kwargs) -> None:
25
- """Log the end of a chain with the output generated by an agent."""
26
- import streamlit as st
27
- from streamlit import session_state, chat_message
28
- session_state.messages.append({"role": self.agent_name, "content": outputs['output']})
29
- output = outputs['output']
30
- st.write("**********")
31
- st.write(self.agent_name)
32
- st.write("**********")
33
- if self.agent_name == 'Visual Content Creator':
34
- chat_message(self.agent_name).image(f"{self.agent_name } : {output}")
35
- else :
36
- chat_message(self.agent_name).markdown(f"{self.agent_name } : {output}")
37
-
38
  class CrewAIAgents:
39
  def __init__(self,llm):
40
  self.llm = llm
41
  # self.image_generate_tool = image_generate_tool
42
  # self.search_tool = search_tool
43
 
44
-
45
  def crewai_agents(self):
46
  project_manager = Agent(
47
  role='Project Manager',
@@ -50,7 +17,7 @@ class CrewAIAgents:
50
  You do not write code.''',
51
  goal='Generate actionable steps for task completion in brief.',
52
  llm=self.llm,
53
- callbacks=[CustomHandler("Project Manager")],
54
  max_iter = 3
55
  )
56
  coder = Agent(
@@ -61,11 +28,11 @@ class CrewAIAgents:
61
  You produce functional, feature complete code.''',
62
  goal='Develop high-quality, well-structured code.',
63
  llm=self.llm,
64
- callbacks=[CustomHandler("Coder")],
65
  max_iter = 3
66
  )
67
 
68
- return [project_manager,coder]
69
 
70
  def gen_with_crewai_agents(self,search_tool):
71
  from crewai import Agent
@@ -185,9 +152,6 @@ class CrewAIAgents:
185
 
186
  except Exception as e:
187
  raise ValueError(e, sys)
188
-
189
-
190
-
191
 
192
  def gen_with_image_crewai_agents(self,image_generate):
193
  from crewai import Agent
 
 
1
  from crewai import Agent
 
2
 
3
+ from src.Handler.customhandler import CustomHandler
4
+ #from llm import groq
5
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  class CrewAIAgents:
7
  def __init__(self,llm):
8
  self.llm = llm
9
  # self.image_generate_tool = image_generate_tool
10
  # self.search_tool = search_tool
11
 
 
12
  def crewai_agents(self):
13
  project_manager = Agent(
14
  role='Project Manager',
 
17
  You do not write code.''',
18
  goal='Generate actionable steps for task completion in brief.',
19
  llm=self.llm,
20
+ # callbacks=[CustomHandler("Project Manager")],
21
  max_iter = 3
22
  )
23
  coder = Agent(
 
28
  You produce functional, feature complete code.''',
29
  goal='Develop high-quality, well-structured code.',
30
  llm=self.llm,
31
+ # callbacks=[CustomHandler("Coder")],
32
  max_iter = 3
33
  )
34
 
35
+ return [project_manager, coder]
36
 
37
  def gen_with_crewai_agents(self,search_tool):
38
  from crewai import Agent
 
152
 
153
  except Exception as e:
154
  raise ValueError(e, sys)
 
 
 
155
 
156
  def gen_with_image_crewai_agents(self,image_generate):
157
  from crewai import Agent
src/llmconfig/groqllm.py CHANGED
@@ -3,19 +3,22 @@ import streamlit as st
3
  # Initialize the Groq model for use with agents
4
  from langchain_core.prompts import ChatPromptTemplate
5
  from langchain_groq import ChatGroq
 
6
 
7
 
8
 
9
  class GroqLLM:
10
  def __init__(self, user_controls_input):
11
  self.user_controls_input = user_controls_input
 
12
 
13
  def groq_llm_config(self):
14
- groq = ChatGroq(
15
- max_tokens=4000,
16
  max_retries=3,
17
  temperature=0.7,
18
- model= self.user_controls_input["selected_model"],
19
- api_key="" # Optional if not set as an environment variable
20
  )
21
- return groq
 
 
 
3
  # Initialize the Groq model for use with agents
4
  from langchain_core.prompts import ChatPromptTemplate
5
  from langchain_groq import ChatGroq
6
+ from crewai import LLM
7
 
8
 
9
 
10
  class GroqLLM:
11
  def __init__(self, user_controls_input):
12
  self.user_controls_input = user_controls_input
13
+ self.model = 'groq/'+self.user_controls_input["selected_model"]
14
 
15
  def groq_llm_config(self):
16
+ llm = LLM(
 
17
  max_retries=3,
18
  temperature=0.7,
19
+ model= self.model,
20
+ api_key=st.session_state["GROQ_API_KEY"]
21
  )
22
+ # llm = LLM(model="groq/gemma2-9b-it",api_key=st.session_state["GROQ_API_KEY"])
23
+
24
+ return llm
src/supportingtools/tools.py CHANGED
@@ -2,7 +2,7 @@ from PIL import Image
2
  import io
3
  import os
4
  import requests
5
- from crewai_tools import tool
6
  from langchain_community.tools import DuckDuckGoSearchRun
7
 
8
  class SupportingTools:
 
2
  import io
3
  import os
4
  import requests
5
+ from crewai.tools import tool
6
  from langchain_community.tools import DuckDuckGoSearchRun
7
 
8
  class SupportingTools: