๐Ÿซ ๋ณด๊ณ ์„œ ๋ฐ ์ง€์‹ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ์„ ์œ„ํ•œ CAMEL ๋กคํ”Œ๋ ˆ์ž‰ ์Šคํฌ๋ž˜ํผ

๐Ÿซ ๋ณด๊ณ ์„œ ๋ฐ ์ง€์‹ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ์„ ์œ„ํ•œ CAMEL ๋กคํ”Œ๋ ˆ์ž‰ ์Šคํฌ๋ž˜ํผ

CAMEL์˜ RAG์™€ Firecrawl์„ ๊ฒฐํ•ฉํ•ด ์›น ์Šคํฌ๋ž˜ํ•‘, ๋‹ค์ค‘ ์—์ด์ „ํŠธ ๋กคํ”Œ๋ ˆ์ž‰ ์ž‘์—…, ์ง€์‹ ๊ทธ๋ž˜ํ”„ ๊ตฌ์ถ•์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์šฐ๋Š” ๋ฌธ์„œ์˜ˆ์š”. Mistral์˜ ๋ชจ๋ธ๋กœ 2024 ํŒŒ๋ฆฌ ์˜ฌ๋ฆผํ”ฝ ํ„ฐํ‚ค ์‚ฌ์ˆ˜์— ๋Œ€ํ•œ ์ข…ํ•ฉ ์—ฐ๊ตฌ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š” ์˜ˆ์‹œ๋ฅผ ๋‹ค๋ฃน๋‹ˆ๋‹ค.

์ถœ์ฒ˜: ๋ฌธ์„œ

๋ณธ๋ฌธ

์ด ๋…ธํŠธ๋ถ์€ CAMEL์˜ RAG(๊ฒ€์ƒ‰ ์ฆ๊ฐ• ์ƒ์„ฑ)์™€ Firecrawl์„ ๊ฒฐํ•ฉํ•ด ํšจ์œจ์ ์ธ ์›น ์Šคํฌ๋ž˜ํ•‘, ๋‹ค์ค‘ ์—์ด์ „ํŠธ ๋กคํ”Œ๋ ˆ์ž‰ ์ž‘์—…, ์ง€์‹ ๊ทธ๋ž˜ํ”„ ๊ตฌ์ถ•์„ ์„ค์ •ํ•˜๊ณ  ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค˜์š”. Mistral์˜ ๋ชจ๋ธ๋กœ 2024 ํŒŒ๋ฆฌ ์˜ฌ๋ฆผํ”ฝ์˜ ํ„ฐํ‚ค ์‚ฌ์ˆ˜์— ๋Œ€ํ•œ ์ข…ํ•ฉ ์—ฐ๊ตฌ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š” ์˜ˆ์‹œ๋ฅผ ์‚ดํŽด๋ณผ๊ฒŒ์š”.

์ด ๋…ธํŠธ๋ถ์—์„œ ๋ฐฐ์šธ ๋‚ด์šฉ:

  • CAMEL: RAG์™€ ๋‹ค์ค‘ ์—์ด์ „ํŠธ ๋กคํ”Œ๋ ˆ์ž‰ ์‹œ๋‚˜๋ฆฌ์˜ค๋ฅผ ์ง€์›ํ•˜๋Š” ๊ฐ•๋ ฅํ•œ ๋‹ค์ค‘ ์—์ด์ „ํŠธ ํ”„๋ ˆ์ž„์›Œํฌ
  • Mistral: ์ตœ์ฒจ๋‹จ ์–ธ์–ด ๋ชจ๋ธ๋กœ, ์™ธ๋ถ€ ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋„๊ตฌ ํ˜ธ์ถœ ๋Šฅ๋ ฅ๊ณผ ๊ฐ•๋ ฅํ•œ ์ž„๋ฒ ๋”ฉ์„ ์ œ๊ณตํ•ด ์˜๋ฏธ ๊ฒ€์ƒ‰๊ณผ ์ฝ˜ํ…์ธ  ๊ฒ€์ƒ‰์— ์‚ฌ์šฉ
  • Firecrawl: ๋‹ค์–‘ํ•œ ์›น ํŽ˜์ด์ง€์—์„œ ์ฝ˜ํ…์ธ ๋ฅผ ์ถ”์ถœยท์ •๋ฆฌํ•˜๋Š” ๊ฐ•๋ ฅํ•œ ์›น ์Šคํฌ๋ž˜ํ•‘ ๋„๊ตฌ
  • AgentOps: CAMEL ์—์ด์ „ํŠธ์˜ ์‹คํ–‰์„ ์ถ”์ ยท๋ถ„์„
  • Qdrant: CAMEL์˜ AutoRetriever์™€ ํ•จ๊ป˜ ์‚ฌ์šฉ๋˜๋Š” ํšจ์œจ์ ์ธ ๋ฒกํ„ฐ ์Šคํ† ๋ฆฌ์ง€ ์‹œ์Šคํ…œ
  • Neo4j: ์—”ํ‹ฐํ‹ฐ ๊ฐ„ ๋ณต์žกํ•œ ๊ด€๊ณ„๋ฅผ ํšจ์œจ์ ์œผ๋กœ ๋งคํ•‘ยท์ฟผ๋ฆฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ์„ ๋„์ ์ธ ๊ทธ๋ž˜ํ”„ DBMS
  • DuckDuckGo Search: SearchToolkit ๋‚ด์—์„œ ์›น์—์„œ ๊ด€๋ จ URL๊ณผ ์ •๋ณด๋ฅผ ์ˆ˜์ง‘ํ•˜๋Š” ๊ธฐ๋ณธ ๊ฒ€์ƒ‰ ์—”์ง„
  • Unstructured IO: ์ฝ˜ํ…์ธ  ์ฒญํ‚น์— ์‚ฌ์šฉ๋˜์–ด ๋น„์ •ํ˜• ๋ฐ์ดํ„ฐ ๊ด€๋ฆฌ๋ฅผ ์šฉ์ดํ•˜๊ฒŒ ํ•จ

์ด ์„ค์ •์€ ์‹ค์šฉ์ ์ธ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ณด์—ฌ์ค„ ๋ฟ ์•„๋‹ˆ๋ผ, ๊ณ ๊ธ‰ ์›น ์ •๋ณด ๊ฒ€์ƒ‰, AI ํ˜‘์—…, ๋‹ค์ค‘ ์†Œ์Šค ๋ฐ์ดํ„ฐ ์ง‘๊ณ„๊ฐ€ ํ•„์š”ํ•œ ๋‹ค์–‘ํ•œ ์‹œ๋‚˜๋ฆฌ์˜ค์— ์ ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์œ ์—ฐํ•œ ํ”„๋ ˆ์ž„์›Œํฌ ์—ญํ• ์„ ํ•ด์š”.

โญ Star the Repo

CAMEL์ด ์œ ์šฉํ•˜๊ฑฐ๋‚˜ ํฅ๋ฏธ๋กญ๋‹ค๋ฉด [CAMEL GitHub Repo]์— ์Šคํƒ€๋ฅผ ์ฃผ๋Š” ๊ฑธ ๊ณ ๋ คํ•ด ์ฃผ์„ธ์š”!

๐Ÿ“ฆ ์„ค์น˜ (Installation)

๋จผ์ € CAMEL ํŒจํ‚ค์ง€๋ฅผ ๋ชจ๋“  ์˜์กด์„ฑ๊ณผ ํ•จ๊ป˜ ์„ค์น˜ํ•ด์š”.

pip install camel-ai[all]==0.1.6.4

๐Ÿ”‘ API ํ‚ค ์„ค์ • (Setting Up API Keys)

Mistral AI, Firecrawl, AgentOps์šฉ API ํ‚ค๋ฅผ ์„ค์ •ํ•ด์•ผ ํ•ด์š”. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋„๊ตฌ๋“ค์ด ์™ธ๋ถ€ ์„œ๋น„์Šค์™€ ์•ˆ์ „ํ•˜๊ฒŒ ์ƒํ˜ธ์ž‘์šฉํ•  ์ˆ˜ ์žˆ์–ด์š”. [์—ฌ๊ธฐ]์—์„œ AgentOps API ํ‚ค๋ฅผ ๋ฌด๋ฃŒ๋กœ ์–ป์„ ์ˆ˜ ์žˆ์–ด์š”.

import os
from getpass import getpass

# Prompt for the AgentOps API key securely
agentops_api_key = getpass('Enter your API key: ')
os.environ["AGENTOPS_API_KEY"] = agentops_api_key

[์—ฌ๊ธฐ]์—์„œ ๋ฌด๋ฃŒ ํฌ๋ ˆ๋”ง์œผ๋กœ Mistral AI API ํ‚ค๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์–ด์š”.

# Prompt for the API key securely
mistral_api_key = getpass('Enter your API key: ')
os.environ["MISTRAL_API_KEY"] = mistral_api_key

CAMEL ModelFactory๋กœ Mistral Large 2 ๋ชจ๋ธ์„ ์„ค์ •ํ•ด์š”. ํ•„์š”์— ๋”ฐ๋ผ ๋‹ค๋ฅธ ๋ชจ๋ธ๋„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์–ด์š”.

from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
from camel.configs import MistralConfig

# Set up model
mistral_large_2 = ModelFactory.create(
    model_platform=ModelPlatformType.MISTRAL,
    model_type=ModelType.MISTRAL_LARGE,
    model_config_dict=MistralConfig(temperature=0.2).as_dict(),
)

[์—ฌ๊ธฐ]์—์„œ ๋ฌด๋ฃŒ ํฌ๋ ˆ๋”ง์œผ๋กœ Firecrawl API ํ‚ค๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์–ด์š”.

# Prompt for the Firecrawl API key securely
firecrawl_api_key = getpass('Enter your API key: ')
os.environ["FIRECRAWL_API_KEY"] = firecrawl_api_key

๐ŸŒ Firecrawl๋กœ ์›น ์Šคํฌ๋ž˜ํ•‘ (Web Scraping with Firecrawl)

Firecrawl์€ ์›น ํŽ˜์ด์ง€์—์„œ ์ฝ˜ํ…์ธ ๋ฅผ ์Šคํฌ๋ž˜ํ•‘ํ•˜๊ณ  ์ •๋ฆฌํ•˜๋Š” ๊ฐ•๋ ฅํ•œ ๋„๊ตฌ์˜ˆ์š”. ์ด ์„น์…˜์—์„œ๋Š” CAMEL AI ์›น์‚ฌ์ดํŠธ์˜ ํŠน์ • ํฌ์ŠคํŠธ ์ฝ˜ํ…์ธ ๋ฅผ ์˜ˆ์‹œ๋กœ ์Šคํฌ๋ž˜ํ•‘ํ•ด์š”.

from camel.loaders import Firecrawl

firecrawl = Firecrawl()

# Scrape and clean content from a specified URL
response = firecrawl.tidy_scrape(
    url="https://www.camel-ai.org/post/crab"
)

print(response)

๐ŸŽ‰ Firecrawl์€ URL์—์„œ ๊นจ๋—ํ•˜๊ณ  LLM ์นœํ™”์ ์ธ ์ฝ˜ํ…์ธ ๋ฅผ ์‰ฝ๊ฒŒ ์–ป์„ ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค˜์š”!

๐Ÿ› ๏ธ CAMEL์˜ RAG์™€ Firecrawl๋กœ ์›น ์ •๋ณด ๊ฒ€์ƒ‰

์ด ์„น์…˜์—์„œ๋Š” CAMEL์˜ RAG ๋ชจ๋ธ๋กœ URL ๋ชฉ๋ก์—์„œ ๊ด€๋ จ ์ •๋ณด๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ๋“œ๋ฆด๊ฒŒ์š”. ์ด๋Š” ์—ฌ๋Ÿฌ ์†Œ์Šค์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ง‘๊ณ„ยท๋ถ„์„ํ•˜๋Š” ๋ฐ ํŠนํžˆ ์œ ์šฉํ•ด์š”.

Firecrawl์„ CAMEL์˜ RAG์™€ ํ•จ๊ป˜ ์„ค์ •

๋‹ค์Œ ํ•จ์ˆ˜๋Š” ์ฃผ์–ด์ง„ ์ฟผ๋ฆฌ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ URL ๋ชฉ๋ก์—์„œ ๊ด€๋ จ ์ •๋ณด๋ฅผ ๊ฒ€์ƒ‰ํ•ด์š”. Firecrawl๋กœ ์›น ์Šคํฌ๋ž˜ํ•‘๊ณผ CAMEL์˜ AutoRetriever๋ฅผ ๊ฒฐํ•ฉํ•ด ์›ํ™œํ•œ ์ •๋ณด ๊ฒ€์ƒ‰ ๊ณผ์ •์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

from camel.retrievers import AutoRetriever
from camel.toolkits import OpenAIFunction, SearchToolkit
from camel.types import ModelPlatformType, ModelType, StorageType
from camel.embeddings import MistralEmbedding
def retrieve_information_from_urls(urls: list[str], query: str) -> str:
    r"""Retrieves relevant information from a list of URLs based on a given
    query.

    This function uses the `Firecrawl` tool to scrape content from the
    provided URLs and then uses the `AutoRetriever` from CAMEL to retrieve the
    most relevant information based on the query from the scraped content.

    Args:
        urls (list[str]): A list of URLs to scrape content from.
        query (str): The query string to search for relevant information.

    Returns:
        str: The most relevant information retrieved based on the query.

    Example:
        >>> urls = ["https://example.com/article1", "https://example.com/
        article2"]
        >>> query = "latest advancements in AI"
        >>> result = retrieve_information_from_urls(urls, query)
    """
    aggregated_content = ''

    # Scrape and aggregate content from each URL
    for url in urls:
        scraped_content = Firecrawl().tidy_scrape(url)
        aggregated_content += scraped_content

    # Set up a vector retriever with local storage and embedding model from Mistral AI
    auto_retriever = AutoRetriever(
        vector_storage_local_path="local_data",
        storage_type=StorageType.QDRANT,
        embedding_model=MistralEmbedding(),
    )

    # Retrieve the most relevant information based on the query
    # You can adjust the top_k and similarity_threshold value based on your needs
    retrieved_info = auto_retriever.run_vector_retriever(
        query=query,
        contents=aggregated_content,
        top_k=3,
        similarity_threshold=0.5,
    )

    return retrieved_info

๊ฒ€์ƒ‰ ํ•จ์ˆ˜๋ฅผ ํ…Œ์ŠคํŠธํ•ด ๋ณผ๊ฒŒ์š”. 2024 ์˜ฌ๋ฆผํ”ฝ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์ˆ˜์ง‘ํ•ด ๋ณด๊ฒ ์–ด์š”. ์ฒซ ์‹คํ–‰์€ ๋กœ์ปฌ ๋ฒกํ„ฐ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๊ตฌ์ถ•ํ•ด์•ผ ํ•ด์„œ ์•ฝ 50์ดˆ๊ฐ€ ๊ฑธ๋ฆด ์ˆ˜ ์žˆ์–ด์š”.

retrieved_info = retrieve_information_from_urls(
    query="Which country won the most golden prize in 2024 Olympics?",
    urls=[
        "https://www.nbcnews.com/sports/olympics/united-states-china-gold-medals-rcna166013",
    ],
)

print(retrieved_info)

๐ŸŽ‰ CAMEL์˜ RAG ํŒŒ์ดํ”„๋ผ์ธ๊ณผ Firecrawl์˜ tidy ์Šคํฌ๋ž˜ํ•‘ ๋•๋ถ„์— ์ด ํ•จ์ˆ˜๋Š” ์ง€์ •๋œ URL์—์„œ ๊ด€๋ จ ์ •๋ณด๋ฅผ ํšจ๊ณผ์ ์œผ๋กœ ๊ฒ€์ƒ‰ํ•ด์š”! ์ด์ œ ์ด ํ•จ์ˆ˜๋ฅผ CAMEL ์—์ด์ „ํŠธ์— ํ†ตํ•ฉํ•ด ๊ฒ€์ƒ‰ ๊ณผ์ •์„ ๋” ์ž๋™ํ™”ํ•  ์ˆ˜ ์žˆ์–ด์š”.

๐Ÿ“น AgentOps๋กœ AI ์—์ด์ „ํŠธ ๋ชจ๋‹ˆํ„ฐ๋ง (Monitoring AI Agents with AgentOps)

import agentops
agentops.init(default_tags=["CAMEL cookbook"])

๐Ÿง  ์ง€์‹ ๊ทธ๋ž˜ํ”„ ๊ตฌ์ถ• (Knowledge Graph Construction)

CAMEL์˜ ๊ฐ•๋ ฅํ•œ ๊ธฐ๋Šฅ ์ค‘ ํ•˜๋‚˜๋Š” ํ…์ŠคํŠธ ๋ฐ์ดํ„ฐ์—์„œ ์ง€์‹ ๊ทธ๋ž˜ํ”„๋ฅผ ๊ตฌ์ถ•ยท์ €์žฅํ•˜๋Š” ๋Šฅ๋ ฅ์ด์—์š”. ์ด๋Š” ๋ฐ์ดํ„ฐ ๋‚ด ๊ด€๊ณ„์˜ ๊ณ ๊ธ‰ ๋ถ„์„๊ณผ ์‹œ๊ฐํ™”๋ฅผ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

Neo4j ์ธ์Šคํ„ด์Šค๋ฅผ URL, ์‚ฌ์šฉ์ž ์ด๋ฆ„, ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ์„ค์ •ํ•ด์š”. [์—ฌ๊ธฐ]์— ์•ˆ๋‚ด๊ฐ€ ์žˆ๊ณ , ๋‹ค์šด๋กœ๋“œํ•œ .txt ํŒŒ์ผ์—์„œ ์ž๊ฒฉ ์ฆ๋ช…์„ ํ™•์ธํ•˜์„ธ์š”. ๋ฐฉ๊ธˆ ์ธ์Šคํ„ด์Šค๋ฅผ ์„ค์ •ํ–ˆ๋‹ค๋ฉด ์ตœ๋Œ€ 60์ดˆ๋ฅผ ๊ธฐ๋‹ค๋ ค์•ผ ํ•  ์ˆ˜ ์žˆ์–ด์š”.

from camel.storages import Neo4jGraph
from camel.loaders import UnstructuredIO
from camel.agents import KnowledgeGraphAgent

def knowledge_graph_builder(text_input: str) -> None:
    r"""Build and store a knowledge graph from the provided text.

    This function processes the input text to create and extract nodes and relationships,
    which are then added to a Neo4j database as a knowledge graph.

    Args:
        text_input (str): The input text from which the knowledge graph is to be constructed.

    Returns:
        graph_elements: The generated graph element from knowlegde graph agent.
    """

    # Set Neo4j instance
    n4j = Neo4jGraph(
        url="Your_URI",
        username="Your_Username",
        password="Your_Password",
    )

    # Initialize instances
    uio = UnstructuredIO()
    kg_agent = KnowledgeGraphAgent(model=mistral_large_2)

    # Create an element from the provided text
    element_example = uio.create_element_from_text(text_input, element_id="001")

    # Extract nodes and relationships using the Knowledge Graph Agent
    graph_elements = kg_agent.run(element_example, parse_graph_elements=True)

    # Add the extracted graph elements to the Neo4j database
    n4j.add_graph_elements(graph_elements=[graph_elements])

    return graph_elements

๐Ÿค–๐Ÿค– CAMEL๋กœ ๋‹ค์ค‘ ์—์ด์ „ํŠธ ๋กคํ”Œ๋ ˆ์ž‰ (Multi-Agent Role-Playing with CAMEL)

์ด ์„น์…˜์€ AI ์—์ด์ „ํŠธ๋“ค์ด ๋‹ค์–‘ํ•œ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•ด ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋„๋ก ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๋กคํ”Œ๋ ˆ์ž‰ ์„ธ์…˜์„ ์„ค์ •ํ•ด์š”. ์–ด์‹œ์Šคํ„ดํŠธ ์—์ด์ „ํŠธ๊ฐ€ 2024 ํŒŒ๋ฆฌ ์˜ฌ๋ฆผํ”ฝ์˜ ํ„ฐํ‚ค ์‚ฌ์ˆ˜์— ๋Œ€ํ•œ ์ข…ํ•ฉ ์—ฐ๊ตฌ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋„๋ก ์•ˆ๋‚ดํ• ๊ฒŒ์š”.

from typing import List

from colorama import Fore

from camel.agents.chat_agent import FunctionCallingRecord
from camel.societies import RolePlaying
from camel.utils import print_text_animated

์ž‘์—… ํ”„๋กฌํ”„ํŠธ ์ •์˜

task_prompt = """Do a comprehensive study of the Turkish shooter in 2024 paris
olympics, write a report for me, then create a knowledge graph for the report.
You should use search tool to get related URLs first, then use retrieval tool
to get the retrieved content back by providing the list of URLs, finially
use tool to build the knowledge graph to finish the task.
No more other actions needed"""

์–ด์‹œ์Šคํ„ดํŠธ ์—์ด์ „ํŠธ๋ฅผ ์ˆ˜ํ•™ ๊ณ„์‚ฐ, ์›น ์ •๋ณด ๊ฒ€์ƒ‰, ์ง€์‹ ๊ทธ๋ž˜ํ”„ ๊ตฌ์ถ•์šฉ ๋„๊ตฌ๋กœ ๊ตฌ์„ฑํ•ด์š”.

retrieval_tool = OpenAIFunction(retrieve_information_from_urls)
search_tool = OpenAIFunction(SearchToolkit().search_duckduckgo)
knowledge_graph_tool = OpenAIFunction(knowledge_graph_builder)

tool_list = [
    retrieval_tool,
    search_tool,
    knowledge_graph_tool,
]

assistant_model_config = MistralConfig(
    tools=tool_list,
    temperature=0.0,
)

๋กคํ”Œ๋ ˆ์ž‰ ์„ธ์…˜ ์„ค์ •

# Initialize the role-playing session
role_play_session = RolePlaying(
    assistant_role_name="CAMEL Assistant",
    user_role_name="CAMEL User",
    assistant_agent_kwargs=dict(
        model=ModelFactory.create(
            model_platform=ModelPlatformType.MISTRAL,
            model_type=ModelType.MISTRAL_LARGE,
            model_config_dict=assistant_model_config.as_dict(),
        ),
        tools=tool_list,
    ),
    user_agent_kwargs=dict(model=mistral_large_2),
    task_prompt=task_prompt,
    with_task_specify=False,
)

์‹œ์Šคํ…œ ๋ฉ”์‹œ์ง€์™€ ์ž‘์—… ํ”„๋กฌํ”„ํŠธ ์ถœ๋ ฅ

# Print system and task messages
print(
    Fore.GREEN
    + f"AI Assistant sys message:\n{role_play_session.assistant_sys_msg}\n"
)
print(Fore.BLUE + f"AI User sys message:\n{role_play_session.user_sys_msg}\n")

print(Fore.YELLOW + f"Original task prompt:\n{task_prompt}\n")
print(
    Fore.CYAN
    + "Specified task prompt:"
    + f"\n{role_play_session.specified_task_prompt}\n"
)
print(Fore.RED + f"Final task prompt:\n{role_play_session.task_prompt}\n")

์ข…๋ฃŒ ๊ทœ์น™ ์„ค์ • ๋ฐ ์—์ด์ „ํŠธ ์ƒํ˜ธ์ž‘์šฉ ์‹œ์ž‘

NOTE: ์ด ์„ธ์…˜์€ Mistral Large 2 ๋ชจ๋ธ๋กœ ์•ฝ 8๋ถ„์ด ๊ฑธ๋ฆฌ๊ณ  ์•ฝ 60k ํ† ํฐ์„ ์†Œ๋น„ํ•ด์š”.

n = 0
input_msg = role_play_session.init_chat()
while n < 20: # Limit the chat to 20 turns
    n += 1
    assistant_response, user_response = role_play_session.step(input_msg)

    if assistant_response.terminated:
        print(
            Fore.GREEN
            + (
                "AI Assistant terminated. Reason: "
                f"{assistant_response.info['termination_reasons']}."
            )
        )
        break
    if user_response.terminated:
        print(
            Fore.GREEN
            + (
                "AI User terminated. "
                f"Reason: {user_response.info['termination_reasons']}."
            )
        )
        break
    # Print output from the user
    print_text_animated(
        Fore.BLUE + f"AI User:\n\n{user_response.msg.content}\n",
        0.01
    )

    if "CAMEL_TASK_DONE" in user_response.msg.content:
        break

    # Print output from the assistant, including any function
    # execution information
    print_text_animated(Fore.GREEN + "AI Assistant:", 0.01)
    tool_calls: List[FunctionCallingRecord] = [
        FunctionCallingRecord(**call.as_dict())
        for call in assistant_response.info['tool_calls']
    ]
    for func_record in tool_calls:
        print_text_animated(f"{func_record}", 0.01)
    print_text_animated(f"{assistant_response.msg.content}\n", 0.01)

    input_msg = assistant_response.msg
# End the AgentOps session
agentops.end_session("Success")

๐ŸŽ‰ ์œ„์— ํ‘œ์‹œ๋œ AgentOps ๋งํฌ๋กœ ๊ฐ€๋ฉด ์ด๋ฒˆ ์‹คํ–‰์— ๋Œ€ํ•œ ์ƒ์„ธ ๊ธฐ๋ก์„ ๋ณผ ์ˆ˜ ์žˆ์–ด์š”. (์ฐธ๊ณ : AgentOps ๋งํฌ๋Š” ๋น„๊ณต๊ฐœ์ด๋ฉฐ AgentOps ๊ณ„์ •์— ์—ฐ๊ฒฐ๋ผ์š”. ๋งํฌ์— ์ ‘๊ทผํ•˜๋ ค๋ฉด ์ž์‹ ์˜ AgentOps API ํ‚ค๋กœ ์„ธ์…˜์„ ์‹คํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ˜„์žฌ AgentOps๋Š” Mistral AI์˜ ์‹คํ–‰ ๋น„์šฉ์„ ์ง์ ‘ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์—†์–ด์š”.)

๐ŸŽ‰ [Neo4j Aura]์—์„œ CAMEL ์—์ด์ „ํŠธ๊ฐ€ ์ƒ์„ฑํ•œ ์ง€์‹ ๊ทธ๋ž˜ํ”„๋ฅผ ํ™•์ธํ•  ์ˆ˜๋„ ์žˆ์–ด์š”.

๐ŸŒŸ ํ•˜์ด๋ผ์ดํŠธ (Highlights)

์ด ๋…ธํŠธ๋ถ์€ ๋ณต์žกํ•œ ๋‹ค์ค‘ ์—์ด์ „ํŠธ ๋กคํ”Œ๋ ˆ์ž‰ ์ž‘์—…์„ ์œ„ํ•œ CAMEL RAG ์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ Firecrawl๊ณผ ํ•จ๊ป˜ ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•ˆ๋‚ดํ–ˆ์–ด์š”. ์ด ์˜ˆ์‹œ๋Š” ๊ณ ๊ธ‰ ์›น ์ •๋ณด ๊ฒ€์ƒ‰๊ณผ AI ํ˜‘์—…์ด ํ•„์š”ํ•œ ๋‹ค์–‘ํ•œ ๋‹ค๋ฅธ ์‹œ๋‚˜๋ฆฌ์˜ค์—๋„ ์ ์šฉยทํ™•์žฅํ•  ์ˆ˜ ์žˆ์–ด์š”.

์ฃผ์š” ์‚ฌ์šฉ ๋„๊ตฌ:

  • CAMEL: RAG์™€ ๋‹ค์ค‘ ์—์ด์ „ํŠธ ๋กคํ”Œ๋ ˆ์ž‰ ์‹œ๋‚˜๋ฆฌ์˜ค๋ฅผ ์ง€์›ํ•˜๋Š” ๊ฐ•๋ ฅํ•œ ๋‹ค์ค‘ ์—์ด์ „ํŠธ ํ”„๋ ˆ์ž„์›Œํฌ
  • Mistral: ์™ธ๋ถ€ ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋„๊ตฌ ํ˜ธ์ถœ ๋Šฅ๋ ฅ๊ณผ ๊ฐ•๋ ฅํ•œ ์ž„๋ฒ ๋”ฉ์„ ์ œ๊ณตํ•˜๋Š” ์ตœ์ฒจ๋‹จ ์–ธ์–ด ๋ชจ๋ธ
  • Firecrawl: ์›น ํŽ˜์ด์ง€์—์„œ ์ฝ˜ํ…์ธ ๋ฅผ ์ถ”์ถœยท์ •๋ฆฌํ•˜๋Š” ๊ฐ•๋ ฅํ•œ ์›น ์Šคํฌ๋ž˜ํ•‘ ๋„๊ตฌ
  • AgentOps: CAMEL ์—์ด์ „ํŠธ์˜ ์‹คํ–‰ ์ถ”์ ยท๋ถ„์„
  • Qdrant: CAMEL์˜ AutoRetriever์™€ ํ•จ๊ป˜ ๋ฒกํ„ฐ ์œ ์‚ฌ๋„ ๊ธฐ๋ฐ˜ ๊ด€๋ จ ์ •๋ณด๋ฅผ ์ €์žฅยท๊ฒ€์ƒ‰ํ•˜๋Š” ํšจ์œจ์ ์ธ ๋ฒกํ„ฐ ์Šคํ† ๋ฆฌ์ง€ ์‹œ์Šคํ…œ
  • Neo4j: ์ง€์‹ ๊ทธ๋ž˜ํ”„ ๊ตฌ์ถ•ยท์ €์žฅ์— ์‚ฌ์šฉ๋˜๋Š” ์„ ๋„์ ์ธ ๊ทธ๋ž˜ํ”„ DBMS
  • DuckDuckGo Search: SearchToolkit ๋‚ด์—์„œ ์ดˆ๊ธฐ ์ฝ˜ํ…์ธ  ๊ฒ€์ƒ‰์˜ ๊ธฐ๋ณธ ๊ฒ€์ƒ‰ ์—”์ง„
  • Unstructured IO: ๋น„์ •ํ˜• ๋ฐ์ดํ„ฐ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ์ฝ˜ํ…์ธ  ์ฒญํ‚น

CAMEL์€ ๊ณ ๊ธ‰ GraphRAG๋„ ์ง€์›ํ•ด์š”. ์ž์„ธํ•œ ๋‚ด์šฉ์€ [์—ฌ๊ธฐ]๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

โญ ์Šคํƒ€๋Š” ํž˜์ด ๋ฉ๋‹ˆ๋‹ค! CAMEL์ด ์œ ์šฉํ•˜๋‹ค๊ณ  ์ƒ๊ฐ๋˜๋ฉด [GitHub]์— ์Šคํƒ€๋ฅผ ์ฃผ๋Š” ๊ฑธ ๊ณ ๋ คํ•ด ์ฃผ์„ธ์š”.

๋” ์•Œ์•„๋ณด๊ธฐ (Learn more)