diff --git a/.gitignore b/.gitignore index ed8ebf5..ba0430d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -__pycache__ \ No newline at end of file +__pycache__/ \ No newline at end of file diff --git a/__pycache__/CUSTOM_STRING.cpython-311.pyc b/__pycache__/CUSTOM_STRING.cpython-311.pyc deleted file mode 100644 index 2893bde..0000000 Binary files a/__pycache__/CUSTOM_STRING.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/__init__.cpython-311.pyc b/__pycache__/__init__.cpython-311.pyc deleted file mode 100644 index 5adefea..0000000 Binary files a/__pycache__/__init__.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 8485826..0000000 Binary files a/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/combine_texts.cpython-311.pyc b/__pycache__/combine_texts.cpython-311.pyc deleted file mode 100644 index d057813..0000000 Binary files a/__pycache__/combine_texts.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/combine_texts.cpython-312.pyc b/__pycache__/combine_texts.cpython-312.pyc deleted file mode 100644 index 96d59e3..0000000 Binary files a/__pycache__/combine_texts.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/convert_16to4_channels.cpython-311.pyc b/__pycache__/convert_16to4_channels.cpython-311.pyc deleted file mode 100644 index 3d18a14..0000000 Binary files a/__pycache__/convert_16to4_channels.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/convert_16to8_channels.cpython-311.pyc b/__pycache__/convert_16to8_channels.cpython-311.pyc deleted file mode 100644 index dc7016b..0000000 Binary files a/__pycache__/convert_16to8_channels.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/create_video.cpython-311.pyc b/__pycache__/create_video.cpython-311.pyc deleted file mode 100644 index 21cd95b..0000000 Binary files a/__pycache__/create_video.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/create_video.cpython-312.pyc b/__pycache__/create_video.cpython-312.pyc deleted file mode 100644 index 50f9ab0..0000000 Binary files a/__pycache__/create_video.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/loop_basic_batch.cpython-311.pyc b/__pycache__/loop_basic_batch.cpython-311.pyc deleted file mode 100644 index c4cf0aa..0000000 Binary files a/__pycache__/loop_basic_batch.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/loop_basic_batch.cpython-312.pyc b/__pycache__/loop_basic_batch.cpython-312.pyc deleted file mode 100644 index 77d4794..0000000 Binary files a/__pycache__/loop_basic_batch.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/loop_float.cpython-311.pyc b/__pycache__/loop_float.cpython-311.pyc deleted file mode 100644 index f42329f..0000000 Binary files a/__pycache__/loop_float.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/loop_float.cpython-312.pyc b/__pycache__/loop_float.cpython-312.pyc deleted file mode 100644 index aa6b851..0000000 Binary files a/__pycache__/loop_float.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/loop_integer.cpython-311.pyc b/__pycache__/loop_integer.cpython-311.pyc deleted file mode 100644 index 46e4bae..0000000 Binary files a/__pycache__/loop_integer.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/loop_integer.cpython-312.pyc b/__pycache__/loop_integer.cpython-312.pyc deleted file mode 100644 index f9243e9..0000000 Binary files a/__pycache__/loop_integer.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/loop_my_combos_samplers_schedulers.cpython-311.pyc b/__pycache__/loop_my_combos_samplers_schedulers.cpython-311.pyc deleted file mode 100644 index 88cc6f7..0000000 Binary files a/__pycache__/loop_my_combos_samplers_schedulers.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/loop_my_combos_samplers_schedulers.cpython-312.pyc b/__pycache__/loop_my_combos_samplers_schedulers.cpython-312.pyc deleted file mode 100644 index d29a9aa..0000000 Binary files a/__pycache__/loop_my_combos_samplers_schedulers.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/loop_samplers.cpython-311.pyc b/__pycache__/loop_samplers.cpython-311.pyc deleted file mode 100644 index 46eb606..0000000 Binary files a/__pycache__/loop_samplers.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/loop_samplers.cpython-312.pyc b/__pycache__/loop_samplers.cpython-312.pyc deleted file mode 100644 index 1089412..0000000 Binary files a/__pycache__/loop_samplers.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/loop_schedulers.cpython-311.pyc b/__pycache__/loop_schedulers.cpython-311.pyc deleted file mode 100644 index a63a758..0000000 Binary files a/__pycache__/loop_schedulers.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/loop_schedulers.cpython-312.pyc b/__pycache__/loop_schedulers.cpython-312.pyc deleted file mode 100644 index d88b832..0000000 Binary files a/__pycache__/loop_schedulers.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/loop_texts.cpython-311.pyc b/__pycache__/loop_texts.cpython-311.pyc deleted file mode 100644 index eb131ae..0000000 Binary files a/__pycache__/loop_texts.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/loop_texts.cpython-312.pyc b/__pycache__/loop_texts.cpython-312.pyc deleted file mode 100644 index 80b8520..0000000 Binary files a/__pycache__/loop_texts.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/ollama.cpython-311.pyc b/__pycache__/ollama.cpython-311.pyc deleted file mode 100644 index 048de21..0000000 Binary files a/__pycache__/ollama.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/ollama.cpython-312.pyc b/__pycache__/ollama.cpython-312.pyc deleted file mode 100644 index 34ab897..0000000 Binary files a/__pycache__/ollama.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/random_model_clip_vae.cpython-311.pyc b/__pycache__/random_model_clip_vae.cpython-311.pyc deleted file mode 100644 index d0319a1..0000000 Binary files a/__pycache__/random_model_clip_vae.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/random_model_clip_vae.cpython-312.pyc b/__pycache__/random_model_clip_vae.cpython-312.pyc deleted file mode 100644 index 3e01784..0000000 Binary files a/__pycache__/random_model_clip_vae.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/random_texts.cpython-311.pyc b/__pycache__/random_texts.cpython-311.pyc deleted file mode 100644 index 48ac842..0000000 Binary files a/__pycache__/random_texts.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/random_texts.cpython-312.pyc b/__pycache__/random_texts.cpython-312.pyc deleted file mode 100644 index fbe1da4..0000000 Binary files a/__pycache__/random_texts.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/resize_image.cpython-312.pyc b/__pycache__/resize_image.cpython-312.pyc deleted file mode 100644 index 7f019da..0000000 Binary files a/__pycache__/resize_image.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/save_api_image.cpython-311.pyc b/__pycache__/save_api_image.cpython-311.pyc deleted file mode 100644 index 8092ad8..0000000 Binary files a/__pycache__/save_api_image.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/save_api_image.cpython-312.pyc b/__pycache__/save_api_image.cpython-312.pyc deleted file mode 100644 index 5aa1507..0000000 Binary files a/__pycache__/save_api_image.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/save_image.cpython-311.pyc b/__pycache__/save_image.cpython-311.pyc deleted file mode 100644 index e27676b..0000000 Binary files a/__pycache__/save_image.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/save_image_path.cpython-312.pyc b/__pycache__/save_image_path.cpython-312.pyc deleted file mode 100644 index eb18810..0000000 Binary files a/__pycache__/save_image_path.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/save_text.cpython-311.pyc b/__pycache__/save_text.cpython-311.pyc deleted file mode 100644 index 3e8e58f..0000000 Binary files a/__pycache__/save_text.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/save_text.cpython-312.pyc b/__pycache__/save_text.cpython-312.pyc deleted file mode 100644 index 8b91d96..0000000 Binary files a/__pycache__/save_text.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/save_tmp_image.cpython-311.pyc b/__pycache__/save_tmp_image.cpython-311.pyc deleted file mode 100644 index c3ef804..0000000 Binary files a/__pycache__/save_tmp_image.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/save_tmp_image.cpython-312.pyc b/__pycache__/save_tmp_image.cpython-312.pyc deleted file mode 100644 index 4908623..0000000 Binary files a/__pycache__/save_tmp_image.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/show_float.cpython-311.pyc b/__pycache__/show_float.cpython-311.pyc deleted file mode 100644 index aeb7dbe..0000000 Binary files a/__pycache__/show_float.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/show_float.cpython-312.pyc b/__pycache__/show_float.cpython-312.pyc deleted file mode 100644 index 1316901..0000000 Binary files a/__pycache__/show_float.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/show_int.cpython-311.pyc b/__pycache__/show_int.cpython-311.pyc deleted file mode 100644 index f328154..0000000 Binary files a/__pycache__/show_int.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/show_int.cpython-312.pyc b/__pycache__/show_int.cpython-312.pyc deleted file mode 100644 index b0875d9..0000000 Binary files a/__pycache__/show_int.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/show_text.cpython-311.pyc b/__pycache__/show_text.cpython-311.pyc deleted file mode 100644 index 2b632c3..0000000 Binary files a/__pycache__/show_text.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/show_text.cpython-312.pyc b/__pycache__/show_text.cpython-312.pyc deleted file mode 100644 index 4b3ce47..0000000 Binary files a/__pycache__/show_text.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/video_pingpong.cpython-311.pyc b/__pycache__/video_pingpong.cpython-311.pyc deleted file mode 100644 index 75661b1..0000000 Binary files a/__pycache__/video_pingpong.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/video_pingpong.cpython-312.pyc b/__pycache__/video_pingpong.cpython-312.pyc deleted file mode 100644 index 37d6f69..0000000 Binary files a/__pycache__/video_pingpong.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/write_image_allinone.cpython-311.pyc b/__pycache__/write_image_allinone.cpython-311.pyc deleted file mode 100644 index 0e09b40..0000000 Binary files a/__pycache__/write_image_allinone.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/write_image_allinone.cpython-312.pyc b/__pycache__/write_image_allinone.cpython-312.pyc deleted file mode 100644 index 39159a0..0000000 Binary files a/__pycache__/write_image_allinone.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/write_image_character.cpython-311.pyc b/__pycache__/write_image_character.cpython-311.pyc deleted file mode 100644 index 445707c..0000000 Binary files a/__pycache__/write_image_character.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/write_image_character.cpython-312.pyc b/__pycache__/write_image_character.cpython-312.pyc deleted file mode 100644 index d9ca4f2..0000000 Binary files a/__pycache__/write_image_character.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/write_image_characters.cpython-311.pyc b/__pycache__/write_image_characters.cpython-311.pyc deleted file mode 100644 index 4960fb4..0000000 Binary files a/__pycache__/write_image_characters.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/write_image_characters.cpython-312.pyc b/__pycache__/write_image_characters.cpython-312.pyc deleted file mode 100644 index 0c934d9..0000000 Binary files a/__pycache__/write_image_characters.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/write_image_environment.cpython-311.pyc b/__pycache__/write_image_environment.cpython-311.pyc deleted file mode 100644 index 3b09cf8..0000000 Binary files a/__pycache__/write_image_environment.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/write_image_environment.cpython-312.pyc b/__pycache__/write_image_environment.cpython-312.pyc deleted file mode 100644 index f9d18f8..0000000 Binary files a/__pycache__/write_image_environment.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/write_text.cpython-311.pyc b/__pycache__/write_text.cpython-311.pyc deleted file mode 100644 index 79a0cde..0000000 Binary files a/__pycache__/write_text.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/write_text.cpython-312.pyc b/__pycache__/write_text.cpython-312.pyc deleted file mode 100644 index 239937b..0000000 Binary files a/__pycache__/write_text.cpython-312.pyc and /dev/null differ diff --git a/__pycache__/write_texts.cpython-311.pyc b/__pycache__/write_texts.cpython-311.pyc deleted file mode 100644 index 458349b..0000000 Binary files a/__pycache__/write_texts.cpython-311.pyc and /dev/null differ diff --git a/ollama.py b/ollama.py index 22901e1..c88a932 100644 --- a/ollama.py +++ b/ollama.py @@ -2,27 +2,42 @@ import ollama from ollama import Client # pip install ollama class ollamaLoader: + @classmethod + def get_available_models(cls): + try: + list_models = ollama.list() + return [model['name'] for model in list_models['models']] + except Exception as e: + print(f"Error fetching models: {e}") + return ["dolphin-llama3"] # Return a default model if fetching fails + @classmethod def INPUT_TYPES(cls): + default_system_prompt = "Describe a specific example of an object, animal, person, or landscape based on a given general idea. Start with a clear and concise overall description in the first sentence. Then, provide a detailed depiction of its physical features, focusing on colors, size, clothing, eyes, and other distinguishing characteristics. Use commas to separate each detail and avoid listing them. Ensure each description is vivid, precise, and specific to one unique instance of the subject. Refrain from using poetic language and giving it a name.\nExample input: man\n Example output: \nAn overweight old man sitting on a bench, wearing a blue hat, yellow pants, orange jacket and black shirt, sunglasses, very long beard, very pale skin, long white hair, very large nose." return { "required": { "user_prompt": ("STRING", {"multiline": True}), - # "selected_model": ((), {}), + "selected_model": (cls.get_available_models(),), + "system_prompt": ("STRING", { + "multiline": True, + "default": default_system_prompt + }), } } RETURN_TYPES = ("STRING",) RETURN_NAMES = ("ollama_response",) FUNCTION = "connect_2_ollama" - # INPUT_NODE = True # Changed from OUTPUT_NODE to INPUT_NODE CATEGORY = "Bjornulf" - # @classmethod - def connect_2_ollama(self, user_prompt): + def connect_2_ollama(self, user_prompt, selected_model, system_prompt): keep_alive = 0 - list_models=ollama.list() #{'models': [{'name': 'dolphin-llama3:latest', 'model': 'dolphin-llama3:latest', 'modified_at': '2024-04-24T06:56:57.498527412+02:00', 'size': 4661235994, 'digest': '613f068e29f863bb900e568f920401b42678efca873d7a7c87b0d6ef4945fadd', 'details': {'parent_model': '', 'format': 'gguf', 'family': 'llama', 'families': ['llama'], 'parameter_size': '8B', 'quantization_level': 'Q4_0'}}]} - print(list_models) client = Client(host="http://127.0.0.1:11434") - response = client.generate(model="dolphin-llama3", system="I will give you an object, animal, person or landscape, just create details about it : colors, size, clothes, eyes and other physical details or features in 1 sentence.", prompt=user_prompt, keep_alive=str(keep_alive) + "m") + response = client.generate( + model=selected_model, + system=system_prompt, + prompt=user_prompt, + keep_alive=str(keep_alive) + "m" + ) print("Ollama response : ", response['response']) - return (response['response'],) + return (response['response'],) \ No newline at end of file