diff --git a/.gitignore b/.gitignore index 39e81dd..03de8a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ node.zip +venv \ No newline at end of file diff --git a/__init__.py b/__init__.py index 4204623..0902879 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,4 @@ +from .nodes.llm_ollama_node import LlmOllama from .nodes.llm_chatGpt_node import LlmChatGpt from .nodes.llm_huggingface_node import LlmHuggingFace from .nodes.llm_openai_node import LlmOpenai @@ -16,6 +17,7 @@ NODE_CLASS_MAPPINGS = { "📎CrewAI LLM OpenAI": LlmOpenai, "📎CrewAI LLM Hugging Face": LlmHuggingFace, "📎CrewAI LLM Chat GPT": LlmChatGpt, + "📎CrewAI LLM Ollama": LlmOllama, } WEB_DIRECTORY = "./js" diff --git a/docs/image_ollama.png b/docs/image_ollama.png new file mode 100644 index 0000000..10c9f40 Binary files /dev/null and b/docs/image_ollama.png differ diff --git a/nodes/llm_chatGpt_node.py b/nodes/llm_chatGpt_node.py index 0671751..c47b592 100644 --- a/nodes/llm_chatGpt_node.py +++ b/nodes/llm_chatGpt_node.py @@ -1,5 +1,5 @@ from .base_node import BaseNode -from langchain_openai import ChatOpenAI +from crewai import LLM import os @@ -26,5 +26,5 @@ class LlmChatGpt(BaseNode): FUNCTION = "create_task" def create_task(self, model, api_key): - llm = ChatOpenAI(model=model, api_key=api_key) + llm = LLM(model=model, api_key=api_key) return (llm,) diff --git a/nodes/llm_huggingface_node.py b/nodes/llm_huggingface_node.py index 67d314a..686249b 100644 --- a/nodes/llm_huggingface_node.py +++ b/nodes/llm_huggingface_node.py @@ -1,5 +1,6 @@ from .base_node import BaseNode -from langchain_community.llms.huggingface_endpoint import HuggingFaceEndpoint +from crewai import LLM + import os @@ -31,7 +32,7 @@ class LlmHuggingFace(BaseNode): FUNCTION = "create_task" def create_task(self, base_url, api_key, task, max_new_tokens): - llm = HuggingFaceEndpoint( + llm = LLM( endpoint_url=base_url, huggingfacehub_api_token=api_key, task=task, diff --git a/nodes/llm_ollama_node.py b/nodes/llm_ollama_node.py new file mode 100644 index 0000000..6dd1e34 --- /dev/null +++ b/nodes/llm_ollama_node.py @@ -0,0 +1,29 @@ +from .base_node import BaseNode +from crewai import LLM + + +class LlmOllama(BaseNode): + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "model": ("STRING", { + "default": "ollama/llama3:70b" + }), + "base_url": ("STRING", { + "default": "http://localhost:11434" + }), + }, + } + + RETURN_TYPES = ("CREWAI_LLM",) + RETURN_NAMES = ("llm",) + + FUNCTION = "create_task" + + def create_task(self, model, base_url): + llm = LLM(model=model, base_url=base_url) + return (llm,) diff --git a/nodes/llm_openai_node.py b/nodes/llm_openai_node.py index dc55dc3..6e31643 100644 --- a/nodes/llm_openai_node.py +++ b/nodes/llm_openai_node.py @@ -1,5 +1,5 @@ from .base_node import BaseNode -from langchain_openai import ChatOpenAI +from crewai import LLM import os @@ -31,5 +31,5 @@ class LlmOpenai(BaseNode): FUNCTION = "create_task" def create_task(self, model, base_url, api_key): - llm = ChatOpenAI(model=model, base_url=base_url, api_key=api_key) + llm = LLM(model=model, base_url=base_url, api_key=api_key) return (llm,) diff --git a/pyproject.toml b/pyproject.toml index f2179ed..00c1705 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,11 @@ [project] name = "comfyui-crewai" description = "ComfyUI-CrewAI aims to integrate Crew AI's multi-agent collaboration framework into the ComfyUI environment. By combining the strengths of Crew AI's role-based, collaborative AI agent system with ComfyUI's intuitive interface, we will create a robust platform for managing and executing complex AI tasks seamlessly" -version = "1.0.3" +version = "1.1.0" license = { file = "LICENSE" } -dependencies = ["crewai>=0.5.0", "langchain-community>=0.0.20", "langchain-openai>=0.0.2.post1", "tokenizers>=0.19"] +dependencies = [ + "crewai[tools]>=0.95.0,<1.0.0" +] [project.urls] Repository = "https://github.com/luandev/ComfyUI-CrewAI" diff --git a/requirements.txt b/requirements.txt index 105e853..b587d58 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1 @@ -crewai>=0.5.0 -langchain-community>=0.0.20 -langchain-openai>=0.0.2.post1 -tokenizers>=0.19 \ No newline at end of file +crewai>=0.95.0