-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add main function in single_llama_index example and update run_integr…
…ation_tests
- Loading branch information
User
committed
May 3, 2024
1 parent
2c1d4bc
commit 077a743
Showing
2 changed files
with
52 additions
and
72 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,56 @@ | ||
import logging | ||
|
||
from dotenv import load_dotenv | ||
from langchain_community.tools import DuckDuckGoSearchRun | ||
|
||
|
||
from motleycrew import MotleyCrew, Task | ||
from motleycrew.agent.llama_index import ReActLlamaIndexMotleyAgent | ||
from motleycrew.caсhing import enable_cache, disable_cache | ||
from motleycrew.common.utils import configure_logging | ||
|
||
|
||
def main(): | ||
"""Main function of running the example.""" | ||
search_tool = DuckDuckGoSearchRun() | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
# TODO: add LlamaIndex native tools | ||
researcher = ReActLlamaIndexMotleyAgent( | ||
goal="Uncover cutting-edge developments in AI and data science", | ||
tools=[search_tool], | ||
verbose=True, | ||
) | ||
|
||
load_dotenv() | ||
enable_cache() | ||
|
||
search_tool = DuckDuckGoSearchRun() | ||
crew = MotleyCrew() | ||
|
||
# TODO: add LlamaIndex native tools | ||
researcher = ReActLlamaIndexMotleyAgent( | ||
goal="Uncover cutting-edge developments in AI and data science", | ||
tools=[search_tool], | ||
verbose=True, | ||
) | ||
# Create tasks for your agents | ||
task1 = Task( | ||
crew=crew, | ||
name="produce comprehensive analysis report on AI advancements", | ||
description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024. | ||
Identify key trends, breakthrough technologies, and potential industry impacts. | ||
Your final answer MUST be a full analysis report""", | ||
agent=researcher, | ||
documents=["paper1.pdf", "paper2.pdf"], | ||
) | ||
|
||
# Instantiate your crew with a sequential process | ||
result = crew.run( | ||
agents=[researcher], | ||
verbose=2, # You can set it to 1 or 2 to different logging levels | ||
) | ||
|
||
crew = MotleyCrew() | ||
# Get your crew to work! | ||
outputs = list(result._done)[0].outputs | ||
print(outputs) | ||
print("######################") | ||
|
||
# Create tasks for your agents | ||
task1 = Task( | ||
crew=crew, | ||
name="produce comprehensive analysis report on AI advancements", | ||
description="""Conduct a comprehensive analysis of the latest advancements in AI in 2024. | ||
Identify key trends, breakthrough technologies, and potential industry impacts. | ||
Your final answer MUST be a full analysis report""", | ||
agent=researcher, | ||
documents=["paper1.pdf", "paper2.pdf"], | ||
) | ||
return outputs[0].response | ||
|
||
# Instantiate your crew with a sequential process | ||
result = crew.run( | ||
agents=[researcher], | ||
verbose=2, # You can set it to 1 or 2 to different logging levels | ||
) | ||
|
||
# Get your crew to work! | ||
print(list(result._done)[0].outputs) | ||
if __name__ == '__main__': | ||
configure_logging(verbose=True) | ||
|
||
print("######################") | ||
disable_cache() | ||
load_dotenv() | ||
enable_cache() | ||
main() | ||
disable_cache() |
This file contains 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