diff --git a/Core_Nodes/__pycache__/isulion_OllamaGenerate.cpython-312.pyc b/Core_Nodes/__pycache__/isulion_OllamaGenerate.cpython-312.pyc new file mode 100644 index 0000000..308cff4 Binary files /dev/null and b/Core_Nodes/__pycache__/isulion_OllamaGenerate.cpython-312.pyc differ diff --git a/Core_Nodes/__pycache__/isulion_prompt_generator.cpython-312.pyc b/Core_Nodes/__pycache__/isulion_prompt_generator.cpython-312.pyc new file mode 100644 index 0000000..6aaf378 Binary files /dev/null and b/Core_Nodes/__pycache__/isulion_prompt_generator.cpython-312.pyc differ diff --git a/Core_Nodes/__pycache__/mega_prompt_generator.cpython-312.pyc b/Core_Nodes/__pycache__/mega_prompt_generator.cpython-312.pyc new file mode 100644 index 0000000..5572316 Binary files /dev/null and b/Core_Nodes/__pycache__/mega_prompt_generator.cpython-312.pyc differ diff --git a/Core_Nodes/isulion_OllamaGenerate.py b/Core_Nodes/isulion_OllamaGenerate.py index 7c824af..d9e3f92 100644 --- a/Core_Nodes/isulion_OllamaGenerate.py +++ b/Core_Nodes/isulion_OllamaGenerate.py @@ -1,11 +1,40 @@ from ollama import Client +import json class OllamaGenerate: + """Node for generating text using Ollama models""" + def __init__(self): - pass - + self.client = None + self.current_host = None + self.available_models = [] + self._update_model_list() + + def _update_model_list(self): + """Fetch available models from Ollama server""" + try: + self.client = Client(host="http://127.0.0.1:11434") + self.current_host = "http://127.0.0.1:11434" + models = self.client.list() + self.available_models = [model['name'] for model in models['models']] + if not self.available_models: + # Fallback to default models if none found + self.available_models = ["llama2", "mistral", "mixtral", "phi", "neural-chat", "codellama"] + except Exception as e: + print(f"Failed to fetch models: {str(e)}") + # Fallback to default models + self.available_models = ["llama2", "mistral", "mixtral", "phi", "neural-chat", "codellama"] + @classmethod def INPUT_TYPES(cls): + try: + # Create temporary instance to get models + temp = cls() + models = temp.available_models + except: + # Fallback models if fetching fails + models = ["llama2", "mistral", "mixtral", "phi", "neural-chat", "codellama"] + return { "required": { "prompt": ("STRING", { @@ -16,7 +45,9 @@ class OllamaGenerate: "multiline": False, "default": "http://127.0.0.1:11434" }), - "model": ((), {}), + "model": (models, { + "default": models[0] if models else "llama2" + }), }, } @@ -26,21 +57,54 @@ class OllamaGenerate: CATEGORY = "Ollama" def ollama_generate(self, prompt, url, model): - # Keep_alive is now hardcoded to 0 (not visible to user) - keep_alive = 0 + """Generate text using Ollama model + + Args: + prompt (str): Input prompt for generation + url (str): Ollama API endpoint URL + model (str): Name of the model to use + + Returns: + tuple: Generated response text + """ + try: + # Initialize client if needed + if not self.client or self.current_host != url: + self.client = Client(host=url) + self.current_host = url + # Update model list when URL changes + self._update_model_list() - client = Client(host=url) + # Validate inputs + if not prompt.strip(): + raise ValueError("Prompt cannot be empty") + + if not url.startswith(("http://", "https://")): + raise ValueError("Invalid URL format") - # Generate the response from the model - response = client.generate( - model=model, - prompt=prompt, - keep_alive=f"{keep_alive}m" # keep_alive is always 0 - ) + # Check if model exists + if model not in self.available_models: + raise ValueError(f"Model '{model}' not found. Available models: {', '.join(self.available_models)}") - return (response['response'],) + # Generate response + response = self.client.generate( + model=model, + prompt=prompt, + keep_alive="0m" # Keep alive disabled + ) -# Register the node with your node mapping system + # Extract and validate response + if not response or 'response' not in response: + raise RuntimeError("Invalid response from Ollama") + + return (response['response'],) + + except Exception as e: + error_msg = f"Ollama generation failed: {str(e)}" + print(error_msg) + return (error_msg,) + +# Register the node NODE_CLASS_MAPPINGS = { "OllamaGenerate": OllamaGenerate, } diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..1052dd0 Binary files /dev/null and b/__pycache__/__init__.cpython-312.pyc differ diff --git a/animals_nodes/__pycache__/isulion_animal_behavior_generator.cpython-312.pyc b/animals_nodes/__pycache__/isulion_animal_behavior_generator.cpython-312.pyc new file mode 100644 index 0000000..e6a7500 Binary files /dev/null and b/animals_nodes/__pycache__/isulion_animal_behavior_generator.cpython-312.pyc differ diff --git a/animals_nodes/__pycache__/isulion_animal_generator.cpython-312.pyc b/animals_nodes/__pycache__/isulion_animal_generator.cpython-312.pyc new file mode 100644 index 0000000..4d24521 Binary files /dev/null and b/animals_nodes/__pycache__/isulion_animal_generator.cpython-312.pyc differ diff --git a/animals_nodes/__pycache__/isulion_cute_animal_generator.cpython-312.pyc b/animals_nodes/__pycache__/isulion_cute_animal_generator.cpython-312.pyc new file mode 100644 index 0000000..fc4c20e Binary files /dev/null and b/animals_nodes/__pycache__/isulion_cute_animal_generator.cpython-312.pyc differ diff --git a/character_nodes/__pycache__/isulion_clothing_generator.cpython-312.pyc b/character_nodes/__pycache__/isulion_clothing_generator.cpython-312.pyc new file mode 100644 index 0000000..ca3439e Binary files /dev/null and b/character_nodes/__pycache__/isulion_clothing_generator.cpython-312.pyc differ diff --git a/character_nodes/__pycache__/isulion_fantasy_race_generator.cpython-312.pyc b/character_nodes/__pycache__/isulion_fantasy_race_generator.cpython-312.pyc new file mode 100644 index 0000000..b3cfa33 Binary files /dev/null and b/character_nodes/__pycache__/isulion_fantasy_race_generator.cpython-312.pyc differ diff --git a/character_nodes/__pycache__/isulion_profession_generator.cpython-312.pyc b/character_nodes/__pycache__/isulion_profession_generator.cpython-312.pyc new file mode 100644 index 0000000..38f6500 Binary files /dev/null and b/character_nodes/__pycache__/isulion_profession_generator.cpython-312.pyc differ diff --git a/enhancement_nodes/__pycache__/isulion_emotion_generator.cpython-312.pyc b/enhancement_nodes/__pycache__/isulion_emotion_generator.cpython-312.pyc new file mode 100644 index 0000000..05f2776 Binary files /dev/null and b/enhancement_nodes/__pycache__/isulion_emotion_generator.cpython-312.pyc differ diff --git a/enhancement_nodes/__pycache__/isulion_negative_prompt_generator.cpython-312.pyc b/enhancement_nodes/__pycache__/isulion_negative_prompt_generator.cpython-312.pyc new file mode 100644 index 0000000..ade2896 Binary files /dev/null and b/enhancement_nodes/__pycache__/isulion_negative_prompt_generator.cpython-312.pyc differ diff --git a/enhancement_nodes/__pycache__/isulion_prompt_enhancer.cpython-312.pyc b/enhancement_nodes/__pycache__/isulion_prompt_enhancer.cpython-312.pyc new file mode 100644 index 0000000..0b69a3d Binary files /dev/null and b/enhancement_nodes/__pycache__/isulion_prompt_enhancer.cpython-312.pyc differ diff --git a/enhancement_nodes/__pycache__/isulion_style_mixer.cpython-312.pyc b/enhancement_nodes/__pycache__/isulion_style_mixer.cpython-312.pyc new file mode 100644 index 0000000..5d67c4f Binary files /dev/null and b/enhancement_nodes/__pycache__/isulion_style_mixer.cpython-312.pyc differ diff --git a/fantasy_nodes/__pycache__/isulion_artifact_generator.cpython-312.pyc b/fantasy_nodes/__pycache__/isulion_artifact_generator.cpython-312.pyc new file mode 100644 index 0000000..78b134f Binary files /dev/null and b/fantasy_nodes/__pycache__/isulion_artifact_generator.cpython-312.pyc differ diff --git a/fantasy_nodes/__pycache__/isulion_magical_effect_generator.cpython-312.pyc b/fantasy_nodes/__pycache__/isulion_magical_effect_generator.cpython-312.pyc new file mode 100644 index 0000000..3932907 Binary files /dev/null and b/fantasy_nodes/__pycache__/isulion_magical_effect_generator.cpython-312.pyc differ diff --git a/fantasy_nodes/__pycache__/isulion_mythical_location_generator.cpython-312.pyc b/fantasy_nodes/__pycache__/isulion_mythical_location_generator.cpython-312.pyc new file mode 100644 index 0000000..c9b2423 Binary files /dev/null and b/fantasy_nodes/__pycache__/isulion_mythical_location_generator.cpython-312.pyc differ diff --git a/scene_nodes/__pycache__/isulion_action_generator.cpython-312.pyc b/scene_nodes/__pycache__/isulion_action_generator.cpython-312.pyc new file mode 100644 index 0000000..a143108 Binary files /dev/null and b/scene_nodes/__pycache__/isulion_action_generator.cpython-312.pyc differ diff --git a/scene_nodes/__pycache__/isulion_art_style_generator.cpython-312.pyc b/scene_nodes/__pycache__/isulion_art_style_generator.cpython-312.pyc new file mode 100644 index 0000000..e5b3056 Binary files /dev/null and b/scene_nodes/__pycache__/isulion_art_style_generator.cpython-312.pyc differ diff --git a/scene_nodes/__pycache__/isulion_habitat_generator.cpython-312.pyc b/scene_nodes/__pycache__/isulion_habitat_generator.cpython-312.pyc new file mode 100644 index 0000000..f55de07 Binary files /dev/null and b/scene_nodes/__pycache__/isulion_habitat_generator.cpython-312.pyc differ diff --git a/scene_nodes/__pycache__/isulion_scene_composition.cpython-312.pyc b/scene_nodes/__pycache__/isulion_scene_composition.cpython-312.pyc new file mode 100644 index 0000000..615bfd9 Binary files /dev/null and b/scene_nodes/__pycache__/isulion_scene_composition.cpython-312.pyc differ diff --git a/scene_nodes/__pycache__/isulion_time_of_day_generator.cpython-312.pyc b/scene_nodes/__pycache__/isulion_time_of_day_generator.cpython-312.pyc new file mode 100644 index 0000000..020b284 Binary files /dev/null and b/scene_nodes/__pycache__/isulion_time_of_day_generator.cpython-312.pyc differ diff --git a/scene_nodes/__pycache__/isulion_weather_generator.cpython-312.pyc b/scene_nodes/__pycache__/isulion_weather_generator.cpython-312.pyc new file mode 100644 index 0000000..018e569 Binary files /dev/null and b/scene_nodes/__pycache__/isulion_weather_generator.cpython-312.pyc differ diff --git a/scifi_nodes/__pycache__/isulion_alien_world_generator.cpython-312.pyc b/scifi_nodes/__pycache__/isulion_alien_world_generator.cpython-312.pyc new file mode 100644 index 0000000..e0b5c2a Binary files /dev/null and b/scifi_nodes/__pycache__/isulion_alien_world_generator.cpython-312.pyc differ diff --git a/scifi_nodes/__pycache__/isulion_spacecraft_generator.cpython-312.pyc b/scifi_nodes/__pycache__/isulion_spacecraft_generator.cpython-312.pyc new file mode 100644 index 0000000..b887ef2 Binary files /dev/null and b/scifi_nodes/__pycache__/isulion_spacecraft_generator.cpython-312.pyc differ diff --git a/scifi_nodes/__pycache__/isulion_tech_generator.cpython-312.pyc b/scifi_nodes/__pycache__/isulion_tech_generator.cpython-312.pyc new file mode 100644 index 0000000..e37c1b2 Binary files /dev/null and b/scifi_nodes/__pycache__/isulion_tech_generator.cpython-312.pyc differ