dromerosm commited on
Commit
5d62a8f
·
verified ·
1 Parent(s): 1a6ab6a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -73,7 +73,7 @@ def web_scrapper(url: str, topic: str) -> str:
73
  model='command-r-plus',
74
  message=prompt,
75
  temperature=0.4,
76
- max_tokens=600,
77
  chat_history=[],
78
  prompt_truncation='AUTO'
79
  )
@@ -88,26 +88,18 @@ def web_scrapper(url: str, topic: str) -> str:
88
 
89
  return summary_response
90
 
91
- def kickoff_crew(topic: str) -> str:
92
  try:
93
 
94
- # Initialize the large language models
95
- groq_llm_70b = ChatGroq(temperature=0, groq_api_key=groq_api_key, model_name="llama-3.1-70b-versatile")
96
- cohere_llm = ChatCohere(
97
- temperature=0,
98
- cohere_api_key=cohere_api_key,
99
- model_name="command-r-plus"
100
- )
101
-
102
- #selected_llm = cohere_llm
103
- selected_llm = groq_llm_70b
104
 
105
  # Define Agents with Groq LLM
106
  researcher = Agent(
107
  role='Researcher',
108
  goal='Search and Collect detailed information on topic ## {topic} ##',
109
  tools=[search_results, web_scrapper],
110
- llm=selected_llm, # Assigning the LLM here
111
  backstory=(
112
  "You are a meticulous researcher, skilled at navigating vast amounts of information to extract essential insights on any given topic. "
113
  "Your dedication to detail ensures the reliability and thoroughness of your findings. "
@@ -124,7 +116,7 @@ def kickoff_crew(topic: str) -> str:
124
  editor = Agent(
125
  role='Editor',
126
  goal='Compile and refine the information into a comprehensive report on topic ## {topic} ##',
127
- llm=selected_llm, # Assigning the LLM here
128
  backstory=(
129
  "As an expert editor, you specialize in transforming raw data into clear, engaging reports. "
130
  "Your strong command of language and attention to detail ensure that each report not only conveys essential insights "
@@ -191,17 +183,18 @@ def main():
191
  with gr.Blocks() as demo:
192
  gr.Markdown("## CrewAI Research Tool")
193
  topic_input = gr.Textbox(label="Enter Topic", placeholder="Type here...")
 
194
  submit_button = gr.Button("Start Research")
195
  output = gr.Markdown(label="Result")
196
 
197
  submit_button.click(
198
  fn=kickoff_crew,
199
- inputs=topic_input,
200
  outputs=output
201
  )
202
 
203
  # demo.launch(debug=True)
204
  demo.queue(api_open=False, max_size=3).launch()
205
 
206
- if __name__=="__main__":
207
  main()
 
73
  model='command-r-plus',
74
  message=prompt,
75
  temperature=0.4,
76
+ max_tokens=1000,
77
  chat_history=[],
78
  prompt_truncation='AUTO'
79
  )
 
88
 
89
  return summary_response
90
 
91
+ def kickoff_crew(topic: str, model_choice: str) -> str:
92
  try:
93
 
94
+ # Initialize the large language models based on user selection
95
+ groq_llm = ChatGroq(temperature=0, groq_api_key=groq_api_key, model_name=model_choice)
 
 
 
 
 
 
 
 
96
 
97
  # Define Agents with Groq LLM
98
  researcher = Agent(
99
  role='Researcher',
100
  goal='Search and Collect detailed information on topic ## {topic} ##',
101
  tools=[search_results, web_scrapper],
102
+ llm=groq_llm, # Assigning the LLM here
103
  backstory=(
104
  "You are a meticulous researcher, skilled at navigating vast amounts of information to extract essential insights on any given topic. "
105
  "Your dedication to detail ensures the reliability and thoroughness of your findings. "
 
116
  editor = Agent(
117
  role='Editor',
118
  goal='Compile and refine the information into a comprehensive report on topic ## {topic} ##',
119
+ llm=groq_llm, # Assigning the LLM here
120
  backstory=(
121
  "As an expert editor, you specialize in transforming raw data into clear, engaging reports. "
122
  "Your strong command of language and attention to detail ensure that each report not only conveys essential insights "
 
183
  with gr.Blocks() as demo:
184
  gr.Markdown("## CrewAI Research Tool")
185
  topic_input = gr.Textbox(label="Enter Topic", placeholder="Type here...")
186
+ model_choice = gr.Radio(choices=["llama3-8b-8192", "llama3-70b-8192", 'llama-3.1-8b-instant', 'llama-3.1-70b-versatile'], label="Choose Model")
187
  submit_button = gr.Button("Start Research")
188
  output = gr.Markdown(label="Result")
189
 
190
  submit_button.click(
191
  fn=kickoff_crew,
192
+ inputs=[topic_input, model_choice],
193
  outputs=output
194
  )
195
 
196
  # demo.launch(debug=True)
197
  demo.queue(api_open=False, max_size=3).launch()
198
 
199
+ if __name__ == "__main__":
200
  main()