설치 및 실행 방법 #
(1) miniconda 설치, https://docs.conda.io/projects/miniconda/en/latest/index.html
(2) powser shell 로 실행,
- 명령어 메뉴에서 Anaconda Powershell Prompt (miniconda3) 선택
(3) conda create -n crewai python=3.11
(4) conda activate crewai
(5) pip install crewai duckduckgo-search langchain_google_genai
- 한 번 실행하면, 다음 부터는 안해도 됩니다.
(6) $ENV:GOOGLE_API_KEY=’Your Key’
- https://makersuite.google.com/app/ 사이트에서 계정을 생성한 후 Get API key 메뉴를 클릭하여 GOOGLE_API_KEY 를 받을 수 있음
- 새로 termial을 열 때마다 위 명령어 실행해야 함
(7) 실행: python 파일명.py
(8) Visual Studio Code 를 이용하면, python code 를 편리하게 수정할 수 있습니다.
실행 결과 예시 #
Title: Synthetic Biology: A Revolutionary Force Shaping Our Future
Introduction:
In the realm of scientific advancements, synthetic biology stands as a beacon of hope, promising to revolutionize industries and tackle global challenges. This emerging field has witnessed remarkable progress in recent years, unlocking new possibilities and transforming the way we approach medicine, energy, and sustainability. In this blog post, we’ll delve into the most significant advancements in synthetic biology, exploring how they’re shaping our future and paving the way for a better tomorrow.
1. AI-Driven Drug Discovery: Accelerating the Path to New Therapies:
Imagine a world where AI and big data analytics join forces to accelerate the discovery of life-saving drugs. Synthetic biology has made this a reality. By harnessing the power of AI, researchers can now sift through vast amounts of data, identifying potential therapies with unprecedented speed and accuracy. This breakthrough has the potential to revolutionize drug development, bringing new treatments to patients faster than ever before.
2. CRISPR Advancements: Editing Genes for Health and Beyond:
CRISPR-based gene editing techniques have taken the world by storm, offering a precise and powerful tool for manipulating DNA. Synthetic biology has played a pivotal role in advancing CRISPR technology, leading to targeted therapies for genetic diseases and cancer. With CRISPR, scientists can now make precise changes to DNA, correcting genetic defects and potentially curing previously untreatable conditions.
3. Biomaterials and Tissue Engineering: Regenerating and Repairing:
Synthetic biology has opened up new avenues for regenerative medicine and organ transplantation. By engineering biomaterials and developing tissue engineering techniques, scientists can now create artificial tissues and organs that can repair damaged ones or replace those lost to disease or injury. This holds immense promise for improving the lives of millions of people worldwide.
4. Green Chemistry and Decarbonization: A Sustainable Future:
In the fight against climate change, synthetic biology is emerging as a powerful ally. Researchers are harnessing the power of synthetic biology to develop sustainable and eco-friendly processes, reducing carbon emissions and promoting green chemistry. From bio-based plastics to renewable energy sources, synthetic biology is helping us transition to a greener, more sustainable future.
5. Biofuels and Renewable Energy: Powering the Future:
Synthetic biology is also playing a crucial role in the development of biofuels and renewable energy sources. By engineering microorganisms, scientists can produce biofuels that are cleaner and more efficient than traditional fossil fuels. These advancements have the potential to reduce our reliance on fossil fuels and pave the way for a more sustainable energy future.
Conclusion:
Synthetic biology is a rapidly evolving field that is transforming industries and addressing global challenges. From AI-driven drug discovery to CRISPR-based gene editing, biomaterials and tissue engineering to green chemistry and renewable energy, synthetic biology is shaping our future in remarkable ways. As this field continues to advance, we can expect even more groundbreaking discoveries and innovations that will improve human health, promote sustainable development, and create a better world for generations to come.
Python Code #
import os
# from langchain.llms import Ollama
#from langchain_community.llms import Ollama
from crewai import Agent, Task, Crew, Process
from langchain_google_genai import ChatGoogleGenerativeAI
#os.environ["OPENAI_API_KEY"] = "YOUR KEY"
# You can choose to use a local model through Ollama for example.
#
# from langchain.llms import Ollama
#ollama_openhermes = Ollama(model="openhermes")
#ollama_llm = Ollama(model="openhermes")
# To load gemini (this api is for free: https://makersuite.google.com/app/apikey)
api_gemini = os.environ.get("GOOGLE_API_KEY")
llm = ChatGoogleGenerativeAI(
model="gemini-pro", verbose=True, temperature=0.1, google_api_key=api_gemini
)
# Install duckduckgo-search for this example:
# !pip install -U duckduckgo-search
from langchain_community.tools import DuckDuckGoSearchRun
search_tool = DuckDuckGoSearchRun()
# Define your agents with roles and goals
researcher = Agent(
role='Senior Research Analyst',
goal='Uncover cutting-edge developments in Synthetic Biology',
backstory="""You work at a leading tech think tank.
Your expertise lies in identifying emerging trends.
You have a knack for dissecting complex data and presenting
actionable insights.""",
verbose=True,
allow_delegation=False,
tools=[search_tool],
# You can pass an optional llm attribute specifying what mode you wanna use.
# It can be a local model through Ollama / LM Studio or a remote
# model like OpenAI, Mistral, Antrophic of others (https://python.langchain.com/docs/integrations/llms/)
#
# Examples:
# llm=ollama_llm # was defined above in the file
# llm=ChatOpenAI(model_name="gpt-3.5", temperature=0.7)
llm=llm
)
writer = Agent(
role='Tech Content Strategist',
goal='Craft compelling content on tech advancements',
backstory="""You are a renowned Content Strategist, known for
your insightful and engaging articles.
You transform complex concepts into compelling narratives.""",
verbose=True,
allow_delegation=True,
llm=llm
)
# Create tasks for your agents
task1 = Task(
description="""Conduct a comprehensive analysis of the latest advancements in Synthetic Biology in 2024.
Identify key trends, breakthrough technologies, and potential industry impacts.
Your final answer MUST be a full analysis report""",
agent=researcher
)
task2 = Task(
description="""Using the insights provided, develop an engaging blog
post that highlights the most significant advancements in the area of Synthetic Biology.
Your post should be informative yet accessible, catering to a tech-savvy audience.
Make it sound cool, avoid complex words so it doesn't sound like Synthetic Biology.
Your final answer MUST be the full blog post of at least 4 paragraphs.""",
agent=writer
)
# Instantiate your crew with a sequential process
crew = Crew(
agents=[researcher, writer],
tasks=[task1, task2],
verbose=2, # You can set it to 1 or 2 to different logging levels
)
# Get your crew to work!
result = crew.kickoff()
print("######################")
print(result)
위 코드에서 주황색으로 된 부분 위주로 수정하여 다른 기술들에 대한 분석들을 진행할 수 있습니다.
Agent와 Task들을 추가적으로 구성하여 원하는 답을 보다 구체적으로 도출할 수 있습니다.
semantic scholar 사이트 데이터를 이용한 분석 #
위의 환경에서 추가 두개의 모듈을 더 설치합니다.
pip install langchainhub semanticscholar
이후에 다음 코드를 실행하면 아래와 같은 결과를 얻을 수 있습니다.
파일명: semantic_scholar_synthetic_bio.py
import os
from langchain import hub
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain_openai import ChatOpenAI
instructions = """You are an expert researcher."""
base_prompt = hub.pull("langchain-ai/openai-functions-template")
prompt = base_prompt.partial(instructions=instructions)
from langchain_google_genai import ChatGoogleGenerativeAI
api_gemini = os.environ.get("GOOGLE_API_KEY")
llm = ChatGoogleGenerativeAI(
model="gemini-pro", verbose=True, convert_system_message_to_human=True, temperature=0.1, google_api_key=api_gemini
)
from langchain_community.tools.semanticscholar.tool import SemanticScholarQueryRun
tools = [SemanticScholarQueryRun()]
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(
agent=agent,
tools=tools,
verbose=True,
)
agent_executor.invoke(
{
"input": "What are popular articles on synthetic biology? what are the main research questions"
"show me a list of papers and techniques. Based on your findings write new research questions "
"to work on. Break down the task into subtasks for search. Use the search tool"
}
)
실행결과 #
실행명령어
python .\semantic_scholar_synthetic_bio.py
Entering new AgentExecutor chain…
Popular articles on Synthetic biology:
- “Synthetic biology: Engineering biology to solve global challenges” by the World Economic Form.
- “Synthetic biology: A new era of biology based on engineering principles” by the National Institute of Health.
- “Synthetic biology: The power to design and build new living things” by the American Society for Microbiology.
- “Synthetic biology: The future of medicine, energy, and food” by the Synthetic biology Project.
- “Synthetic biology: A new frontier in biology with far-reaching applications” by the European Commission.
Main research questions in Synthetic biology:
- How can we design and build new living things with desired properties?
- How can we use Synthetic biology to solve global challenges such as climate change, food security, and disease?
- How can we ensure that Synthetic biology is used responsibly and ethically?
- What are the potential benefits and drawbacks of Synthetic biology?
- How can we integrate Synthetic biology with other fields of science and engineering?
List of papers and techniques in Synthetic biology:
- “A semi-synthetic organism that stores and retrieves data from DNA” by the J.Craig Venter Institute.
- “Engineering a bacterial cell to synthesize artemisinin, a malaria-fighting drug” by the University of California, Berkley.
- “Design and construction of a minimal bacterial genome” by the J.Craig Venter Institute.
- “CRISPER-Cas9: A powerful new tool for genome engineering” by the University of California, Berkley.
- “Synthetic biology: A toolkit for engineering biology” by the Wyss Institute for Biologically Inspired Engineering.
New research questions in Synthetic biology:
- How can we use Synthetic biology to develop new therapies for cancer and other disease?
- How can we use Synthetic biology to develop new bio fuels and other renewable energy sources?
- How can we use Synthetic biology to develop new materials with desired properties?
- How can we use Synthetic biology to develop new ways to clean up the environment?
- How can we use Synthetic biology to develop new ways to study and understand biology?
Subtask for search:
- Search for papers on the use of Synthetic biology to develop new therapies for cancer.
- Search for papers on the use of Synthetic biology to develop new bio fuels and other renewable energy sources.
- Search for papers on the use of Synthetic biology to develop new materials with desired properties.
- Search for papers on the use of Synthetic biology to develop new ways to clean up the environment.
- Search for papers on the use of Synthetic biology to develop new ways to study and understand biology.