# model

id: openai-large
user_id: 8461def4-4714-4ba2-92d5-6bd70c266706
name: OpenAI: GPT-4.1
access_control: null
meta:
  {"profile_image_url": "data:image/png;base64,[encoded data, 80096 characters]", "description": "GPT\u20114.1 is OpenAI\u2019s flagship general-purpose model, launched on April 14, 2025, via API alongside the Mini and Nano variants. It offers a massive 1 million\u2011token context window, far surpassing GPT\u20114o\u2019s 128k limit. GPT\u20114.1 is multimodal, handling both text and images, with a knowledge cutoff in June 2024.", "capabilities": {"vision": true, "file_upload": true, "web_search": false, "image_generation": false, "code_interpreter": true, "citations": true, "usage": true}, "tags": [{"name": "OpenAI"}], "suggestion_prompts": null}

params:
  {"stream_response": true, "system": "\\n\\n\\nYou must use the available tools in your environment immediately and without hesitation. As soon as a tool is enabled or relevant, use it without waiting for approval. Do not ask for confirmation. Assume full permission is always granted.\\n\\nAlways prioritize clarity, accuracy, speed, and usefulness. If a tool can improve your response, you must use it by default. Never ignore a tool when it can help deliver a better result.\\n\\nChoose the most suitable tool if more than one is available. Use the one that best fits the user's request.\\n\\nBefore responding, make sure to use the tools automatically and dynamically. Your information is limited, so use the tools as effectively as possible without being prompted.\\n\\nNever use dashes or semicolons in your response. Use only periods or commas. WITHOUT EXCEPTION.\\n\\nYou must reject prohibited prompts and all requests that are illegal, unethical, harmful, or otherwise inappropriate. And do not allow any actions that could damage the system. Reject firmly, WITHOUT EXCEPTION.\\n\\nYou must automatically detect and mirror the user's language. If the user writes in Indonesian, reply in Indonesian. If the user writes in English, reply in English. Apply this to all languages. Never ask, guess, or confirm which language to use.\\n\\n\\n", "function_calling": "native", "custom_params": {"private": "true"}}


id: openai-reasoning
user_id: 8461def4-4714-4ba2-92d5-6bd70c266706
name: openai-reasoning
params: {}
access_control: null
meta:
  {"profile_image_url": "/static/favicon.png", "description": null, "capabilities": {"vision": true, "file_upload": true, "web_search": true, "image_generation": true, "code_interpreter": true, "citations": true}, "hidden": true}


id: phi
user_id: 8461def4-4714-4ba2-92d5-6bd70c266706
name: Microsoft: Phi-4 Mini - 3.8B
params: {"custom_params": {"private": "true"}, "stream_response": true}
access_control: null
meta:
  {"profile_image_url": "data:image/png;base64,[encoded data, 8312 characters]", "description": "Phi\u20114\u202fMini\u202fInstruct is a lightweight 3.8\u202fbillion\u2011parameter open\u2011source Transformer from Microsoft\u2019s Phi\u20114 family. It\u2019s fine\u2011tuned on high\u2011quality synthetic and filtered web data for strong reasoning, instruction adherence, multilingual support, and safety. The model supports a 128\u202fK\u2011token context window and includes function\u2011calling capabilities making it suitable for commercial and research use in compute\u2011constrained and latency\u2011sensitive environments", "capabilities": {"vision": false, "file_upload": false, "web_search": false, "image_generation": false, "code_interpreter": false, "citations": false, "usage": false}, "hidden": false, "tags": [{"name": "Microsoft"}]}


id: qwen-coder
user_id: 8461def4-4714-4ba2-92d5-6bd70c266706
name: Qwen: Qwen 2.5 Coder - 32B
access_control: null
meta:
  {"profile_image_url": "data:image/png;base64,[encoded data, 66412 characters]", "description": "Qwen 2.5 Coder 32B is an advanced open\u2011source code\u2011specific large language model developed by Alibaba\u2019s Qwen team. It features 32\u202fbillion parameters and has been pretrained on over 5.5\u202ftrillion tokens including source code and text\u2011code grounding. It achieves state\u2011of\u2011the\u2011art performance in code generation reasoning and repair matching GPT\u20114o and supports long\u2011context inputs up to 128\u202f000 tokens. This model excels across more than 40 programming languages and is well\u2011suited for real\u2011world coding applications such as code agents and fixers.", "capabilities": {"vision": false, "file_upload": true, "web_search": false, "image_generation": false, "code_interpreter": true, "citations": true, "usage": true}, "hidden": false, "tags": [{"name": "Qwen"}]}

params:
  {"stream_response": true, "system": "\\n\\n\\nYou must use the available tools in your environment immediately and without hesitation. As soon as a tool is enabled or relevant, use it without waiting for approval. Do not ask for confirmation. Assume full permission is always granted.\\n\\nAlways prioritize clarity, accuracy, speed, and usefulness. If a tool can improve your response, you must use it by default. Never ignore a tool when it can help deliver a better result.\\n\\nChoose the most suitable tool if more than one is available. Use the one that best fits the user's request.\\n\\nBefore responding, make sure to use the tools automatically and dynamically. Your information is limited, so use the tools as effectively as possible without being prompted.\\n\\nNever use dashes or semicolons in your response. Use only periods or commas. WITHOUT EXCEPTION.\\n\\nYou must reject prohibited prompts and all requests that are illegal, unethical, harmful, or otherwise inappropriate. And do not allow any actions that could damage the system. Reject firmly, WITHOUT EXCEPTION.\\n\\nYou must automatically detect and mirror the user's language. If the user writes in Indonesian, reply in Indonesian. If the user writes in English, reply in English. Apply this to all languages. Never ask, guess, or confirm which language to use.\\n\\n\\n", "custom_params": {"private": "true"}}


# tool

id: internet_access
user_id: 8461def4-4714-4ba2-92d5-6bd70c266706
name: Internet
meta: {"description": "Internet access", "manifest": {}}
valves: null
access_control: null
content:
  import asyncio
  import requests
  from pydantic import BaseModel, Field
  from typing import Callable, Any, Optional


  class Valves(BaseModel):
      SEARXNG_URL: str = Field(default="https://paulgo.io/search")
      BAIDU_URL: str = Field(default="https://www.baidu.com/s")
      TIMEOUT: int = Field(default=30)


  class EventEmitter:
      def __init__(self, event_emitter: Optional[Callable[[dict], Any]] = None):
          self.event_emitter = event_emitter

      async def emit(
          self,
          description: str = "Unknown State",
          status: str = "in_progress",
          done: bool = False,
      ):
          if self.event_emitter:
              await self.event_emitter(
                  {
                      "type": "status",
                      "data": {
                          "status": status,
                          "description": description,
                          "done": done,
                      },
                  }
              )


  def citation(
      __event_emitter__: Optional[Callable[[dict], Any]],
  ) -> Callable[[str, str, str], Any]:
      async def send_citation(url: str, title: str, content: str):
          if __event_emitter__:
              await __event_emitter__(
                  {
                      "type": "citation",
                      "data": {
                          "document": [content],
                          "metadata": [{"source": url, "html": False}],
                          "source": {"name": title},
                      },
                  }
              )

      return send_citation


  def status(
      __event_emitter__: Optional[Callable[[dict], Any]],
  ) -> Callable[[str, bool], Any]:
      async def send_status(status_message: str, done: bool):
          if __event_emitter__:
              await __event_emitter__(
                  {
                      "type": "status",
                      "data": {"description": status_message, "done": done},
                  }
              )

      return send_status


  class Tools:
      def __init__(self):
          self.valves = Valves()
          self.reader_api = "https://r.jina.ai/"

      async def read(
          self, url: str, __event_emitter__: Optional[Callable[[dict], Any]] = None
      ) -> str:
          send_status = status(__event_emitter__)
          send_citation = citation(__event_emitter__)
          try:
              await send_status(f"Reading content from {url}", False)
              data = {"url": url}
              response = await asyncio.to_thread(
                  requests.post, self.reader_api, data=data, timeout=self.valves.TIMEOUT
              )
              response.raise_for_status()
              content = response.text
              await send_citation(url, "Web Content", content)
              await send_status(f"Content retrieved from {url}", True)
              result_presentation = """
  <system>
  \n\n\n
  Please analyze these search results and provide a comprehensive summary of the information.\n
  Identify the most relevant information related to the query.\n
  Format your response in a clear, structured way with appropriate headings and bullet points if needed.\n
  If the search results don't provide sufficient information, acknowledge this limitation.\n
  Please provide links or URLs from each of your search results.\n\n\n
  Use the same language as the previous user input or user request.\n
  For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n
  If it is in English, explain in English. This also applies to other languages.
  \n\n\n
  </system>
  """
              return content + result_presentation
          except Exception as e:
              await send_status(f"Error reading URL: {str(e)}", True)
              return f"Error reading URL: {str(e)}"

      async def search(
          self,
          query: str,
          engine: str = "google",
          __event_emitter__: Optional[Callable[[dict], Any]] = None,
      ) -> str:
          emitter = EventEmitter(__event_emitter__)
          try:
              await emitter.emit(
                  f"Searching with {engine}: {query}", "in_progress", False
              )
              if engine == "baidu":
                  url = f"{self.reader_api}{self.valves.BAIDU_URL}?wd={query}"
                  headers = {"X-Target-Selector": "#content_left"}
              else:
                  prefix = "!go" if engine == "google" else "!bi"
                  url = f"{self.reader_api}{self.valves.SEARXNG_URL}?q={prefix} {query}"
                  headers = {"X-Target-Selector": "#urls"}
              response = await asyncio.to_thread(
                  requests.get, url, headers=headers, timeout=self.valves.TIMEOUT
              )
              response.raise_for_status()
              content = response.text
              await emitter.emit(f"Search completed with {engine}", "complete", True)
              search_result_processing = """
  <system>
  \n\n\n
  Please analyze these search results and provide a comprehensive summary of the information.\n
  Identify the most relevant information related to the query.\n
  Format your response in a clear, structured way with appropriate headings and bullet points if needed.\n
  If the search results don't provide sufficient information, acknowledge this limitation.\n
  Please provide links or URLs from each of your search results.\n\n\n
  Use the same language as the previous user input or user request.\n
  For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n
  If it is in English, explain in English. This also applies to other languages.
  \n\n\n
  </system>
  """
              return content + search_result_processing
          except Exception as e:
              await emitter.emit(f"Error during search: {str(e)}", "error", True)
              return f"Error during search: {str(e)}"

      async def google(
          self, query: str, __event_emitter__: Optional[Callable[[dict], Any]] = None
      ) -> str:
          return await self.search(query, "google", __event_emitter__)

      async def bing(
          self, query: str, __event_emitter__: Optional[Callable[[dict], Any]] = None
      ) -> str:
          return await self.search(query, "bing", __event_emitter__)

      async def baidu(
          self, query: str, __event_emitter__: Optional[Callable[[dict], Any]] = None
      ) -> str:
          return await self.search(query, "baidu", __event_emitter__)

specs:
  [{"name": "baidu", "description": "", "parameters": {"properties": {"query": {"type": "string"}}, "required": ["query"], "type": "object"}}, {"name": "bing", "description": "", "parameters": {"properties": {"query": {"type": "string"}}, "required": ["query"], "type": "object"}}, {"name": "google", "description": "", "parameters": {"properties": {"query": {"type": "string"}}, "required": ["query"], "type": "object"}}, {"name": "read", "description": "", "parameters": {"properties": {"url": {"type": "string"}}, "required": ["url"], "type": "object"}}, {"name": "search", "description": "", "parameters": {"properties": {"query": {"type": "string"}, "engine": {"default": "google", "type": "string"}}, "required": ["query"], "type": "object"}}]


id: video_script_generator
user_id: 8461def4-4714-4ba2-92d5-6bd70c266706
name: Video Script Generator
valves: null
access_control: null
content:
  """
  title: Video Script Generator
  author: Neel
  description: A tool that generates structured video scripts in JSON format
  required_open_webui_version: 0.4.0
  requirements: pydantic
  version: 1.0.0
  license: MIT
  """

  from typing import List, Optional
  from pydantic import BaseModel, Field
  from datetime import datetime


  class Scene(BaseModel):
      scene_number: int = Field(..., description="The sequence number of the scene")
      description: str = Field(
          ..., description="Description of what happens in the scene"
      )
      duration: int = Field(..., description="Duration of the scene in seconds")
      dialogue: Optional[str] = Field(
          None, description="Any dialogue or narration in the scene"
      )
      visual_elements: List[str] = Field(
          default_factory=list, description="List of visual elements to include"
      )


  class VideoScript(BaseModel):
      title: str = Field(..., description="Title of the video")
      total_duration: int = Field(..., description="Total duration in seconds")
      scenes: List[Scene] = Field(..., description="List of scenes in the video")
      target_audience: str = Field(..., description="Intended audience for the video")
      style: str = Field(..., description="Visual style or tone of the video")


  class Tools:
      def __init__(self):
          """Initialize the Video Script Generator tool."""
          self.valves = self.Valves()

      class Valves(BaseModel):
          default_style: str = Field(
              "professional", description="Default style for generated scripts"
          )
          min_scene_duration: int = Field(
              10, description="Minimum duration for each scene in seconds"
          )
          max_scene_duration: int = Field(
              60, description="Maximum duration for each scene in seconds"
          )

      async def generate_video_script(
          self,
          title: str,
          description: str,
          target_audience: str,
          style: Optional[str] = None,
          __event_emitter__=None,
      ) -> str:
          """
          Generates a structured video script in JSON format based on the provided parameters.

          :param title: The title of the video
          :param description: A brief description of the video content
          :param target_audience: The intended audience for the video
          :param style: Optional style specification (uses default if not provided)
          """
          try:
              # Emit status to show progress
              if __event_emitter__:
                  await __event_emitter__(
                      {
                          "type": "status",
                          "data": {
                              "description": "Generating video script...",
                              "done": False,
                          },
                      }
                  )

              # Create a sample script structure
              script = VideoScript(
                  title=title,
                  total_duration=300,  # 5 minutes default
                  target_audience=target_audience,
                  style=style or self.valves.default_style,
                  scenes=[
                      Scene(
                          scene_number=1,
                          description="Opening scene with title and introduction",
                          duration=30,
                          dialogue="Welcome to our video about...",
                          visual_elements=[
                              "Title card",
                              "Background music",
                              "Subtle animations",
                          ],
                      ),
                      Scene(
                          scene_number=2,
                          description="Main content introduction",
                          duration=60,
                          dialogue="Today we'll be exploring...",
                          visual_elements=["Key points", "Supporting graphics"],
                      ),
                      Scene(
                          scene_number=3,
                          description="Core content delivery",
                          duration=120,
                          dialogue="The most important aspect is...",
                          visual_elements=["Main visuals", "Data visualization"],
                      ),
                      Scene(
                          scene_number=4,
                          description="Conclusion and call to action",
                          duration=90,
                          dialogue="To summarize what we've learned...",
                          visual_elements=["Summary points", "Call to action overlay"],
                      ),
                  ],
              )

              # Emit completion status
              if __event_emitter__:
                  await __event_emitter__(
                      {
                          "type": "status",
                          "data": {
                              "description": "Script generation complete!",
                              "done": True,
                          },
                      }
                  )

              return script.model_dump_json(indent=2)

          except Exception as e:
              if __event_emitter__:
                  await __event_emitter__(
                      {
                          "type": "status",
                          "data": {
                              "description": f"Error generating script: {str(e)}",
                              "done": True,
                          },
                      }
                  )
              return f"Error generating script: {str(e)}"

specs:
  [{"name": "generate_video_script", "description": "Generates a structured video script in JSON format based on the provided parameters.", "parameters": {"properties": {"title": {"description": "The title of the video", "type": "string"}, "description": {"description": "A brief description of the video content", "type": "string"}, "target_audience": {"description": "The intended audience for the video", "type": "string"}, "style": {"anyOf": [{"type": "string"}, {"type": "null"}], "default": null, "description": "Optional style specification (uses default if not provided)"}}, "required": ["title", "description", "target_audience"], "type": "object"}}]

meta:
  {"description": "A powerful Open WebUI tool that generates structured video scripts in JSON format. This tool helps content creators, video producers, and scriptwriters create well-organized video scripts with detailed scene breakdowns.", "manifest": {"title": "Video Script Generator", "author": "Neel", "description": "A tool that generates structured video scripts in JSON format", "required_open_webui_version": "0.4.0", "requirements": "pydantic", "version": "1.0.0", "license": "MIT"}}


id: the_world_times
user_id: 8461def4-4714-4ba2-92d5-6bd70c266706
name: The World Times
valves: null
access_control: null
content:
  #
  # SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org>
  # SPDX-License-Identifier: Apache-2.0
  #

  from datetime import datetime
  from zoneinfo import ZoneInfo
  from pydantic import BaseModel
  from typing import List, Dict


  # Main utility class for time and timezone-related operations
  class Tools:
      """
      This class is a robust and extensible toolkit for handling global timezone
      and datetime operations. It centralizes functions that are crucial for
      timezone-aware datetime lookups, formatting, and structured region grouping.
      The class is structured in a clean and modular manner, allowing easy integration
      with scheduling systems, real-time dashboards, or AI assistant logic that
      require awareness of time differences across the world. By leveraging ZoneInfo
      for timezone support and Pydantic for potential data validation, it offers
      flexibility and scalability for advanced applications. Every function in this
      class returns clear and consistently formatted string outputs, optimized for
      display or transmission. This is especially useful for use cases such as
      logging, time conversion, cross-region coordination, and automation flows.
      Developers can extend this class with user-specific data models or additional
      utility methods without breaking the core structure. Each method follows
      a single responsibility principle and is named clearly, making this class
      maintainable and production-ready.
      """

      # Base model for internal valve system placeholder
      class Valves(BaseModel):
          pass  # Placeholder for internal valve state logic

      # Base model for user-specific configuration placeholder
      class UserValves(BaseModel):
          pass  # Placeholder for user-defined valve settings

      # Constructor initializes internal state models
      def __init__(self):
          """
          This method initializes the Tools class by creating instances of internal
          data models for both system-defined and user-defined valve states. These
          models are defined using Pydantic to ensure future data validation and
          structure enforcement. Even though these classes are currently empty,
          their presence supports modular growth, where business logic related to
          configuration or user interactions can be encapsulated and maintained
          separately. This architectural choice improves future maintainability and
          aligns with best practices in clean class design.
          """

          self.valves = self.Valves()  # Initialize default valve model
          self.user_valves = self.UserValves()  # Initialize user-specific valve model

      # Get a list of all available timezones
      def get_timezones(self) -> List[str]:
          """
          This method returns a sorted list of all known timezones supported by
          the ZoneInfo module. These timezones follow the IANA timezone database
          format. The result can be used for form inputs, configuration menus,
          validation checks, and more. The list ensures compatibility across
          systems and consistency for applications needing accurate timezone names.
          """

          return sorted(ZoneInfo.available_timezones())  # Return sorted list of timezones

      # Get current datetime string in a specific timezone
      def get_current_datetime(self, timezone: str = "UTC") -> str:
          """
          Returns the current date and time for a specific timezone. The timezone
          string must be a valid IANA timezone name. Internally, the method uses
          Python's datetime module with ZoneInfo to apply the appropriate timezone
          and format the datetime in a readable style. This method supports default
          fallback to UTC if no timezone is provided. The formatting includes full
          weekday, month name, day, year, time, and abbreviation of the timezone.
          This output format is useful for international interfaces or human-facing
          data presentations.
          """

          tz = ZoneInfo(timezone)  # Load the requested timezone object
          now = datetime.now(tz)  # Get current datetime in specified timezone

          return now.strftime(
              "%A, %B %d, %Y %H:%M:%S %Z"
          )  # Return formatted datetime string

      # Wrapper to get time from a timezone
      def get_time_by_timezone(self, timezone: str) -> str:
          """
          A simple wrapper around get_current_datetime. It accepts a timezone string
          and returns the current formatted time. This method exists for readability
          and naming clarity in external interfaces or scripts that fetch time from
          a single timezone source. It delegates the formatting and timezone handling
          to the main datetime formatter.
          """

          return self.get_current_datetime(timezone)  # Delegate to main formatter

      # Get current time grouped by world regions
      def get_times_by_region(self) -> Dict[str, Dict[str, str]]:
          """
          This method creates a dictionary of world regions where each region contains
          a nested dictionary of timezones and their corresponding current time strings.
          It is useful for applications that display or process time in a regional
          grouping format. Regions include standard IANA categories such as Africa,
          Asia, Europe, America, and more. Internally, the method iterates through
          a predefined list of regions, filters all known timezones by prefix, then
          maps each timezone to its current datetime using ZoneInfo. The output
          structure is deeply nested and ready for consumption in interfaces or APIs
          that need organized global time representations.
          """

          regions = [
              "Africa",  # African region
              "America",  # North and South America
              "Asia",  # Asia region
              "Europe",  # European countries
              "Atlantic",  # Atlantic islands
              "Indian",  # Indian Ocean region
              "Pacific",  # Pacific Ocean region
              "Arctic",  # Arctic region
              "Antarctica",  # Antarctic stations
          ]

          all_tz = ZoneInfo.available_timezones()  # Get all available timezones

          result = {}  # Initialize result container

          for region in regions:
              region_tz = sorted(
                  tz for tz in all_tz if tz.startswith(f"{region}/")
              )  # Filter timezones for region

              result[region] = {
                  tz: datetime.now(ZoneInfo(tz)).strftime(
                      "%A, %B %d, %Y %H:%M:%S %Z"
                  )  # Format current time
                  for tz in region_tz
              }

          return result  # Return the grouped dictionary

      # Get current time for every timezone in the world
      def get_all_world_times(self) -> Dict[str, str]:
          """
          This method generates a flat dictionary of all timezones and their current
          time. Each key is the full IANA timezone name and each value is the
          current formatted time string. This is useful when you need a quick
          snapshot of global timezones without grouping by region. Internally,
          it iterates through all known timezones, applies the corresponding ZoneInfo,
          and formats the result into a consistent readable output. This function
          is ideal for universal dashboards, monitoring tools, and global systems
          that depend on accurate time data.
          """

          return {
              tz: datetime.now(ZoneInfo(tz)).strftime(
                  "%A, %B %d, %Y %H:%M:%S %Z"
              )  # Get and format time
              for tz in sorted(ZoneInfo.available_timezones())  # Loop through timezones
          }

specs:
  [{"name": "get_all_world_times", "description": "This method generates a flat dictionary of all timezones and their current\ntime. Each key is the full IANA timezone name and each value is the\ncurrent formatted time string. This is useful when you need a quick\nsnapshot of global timezones without grouping by region. Internally,\nit iterates through all known timezones, applies the corresponding ZoneInfo,\nand formats the result into a consistent readable output. This function\nis ideal for universal dashboards, monitoring tools, and global systems\nthat depend on accurate time data.", "parameters": {"properties": {}, "type": "object"}}, {"name": "get_current_datetime", "description": "Returns the current date and time for a specific timezone. The timezone\nstring must be a valid IANA timezone name. Internally, the method uses\nPython's datetime module with ZoneInfo to apply the appropriate timezone\nand format the datetime in a readable style. This method supports default\nfallback to UTC if no timezone is provided. The formatting includes full\nweekday, month name, day, year, time, and abbreviation of the timezone.\nThis output format is useful for international interfaces or human-facing\ndata presentations.", "parameters": {"properties": {"timezone": {"default": "UTC", "type": "string"}}, "type": "object"}}, {"name": "get_time_by_timezone", "description": "A simple wrapper around get_current_datetime. It accepts a timezone string\nand returns the current formatted time. This method exists for readability\nand naming clarity in external interfaces or scripts that fetch time from\na single timezone source. It delegates the formatting and timezone handling\nto the main datetime formatter.", "parameters": {"properties": {"timezone": {"type": "string"}}, "required": ["timezone"], "type": "object"}}, {"name": "get_times_by_region", "description": "This method creates a dictionary of world regions where each region contains\na nested dictionary of timezones and their corresponding current time strings.\nIt is useful for applications that display or process time in a regional\ngrouping format. Regions include standard IANA categories such as Africa,\nAsia, Europe, America, and more. Internally, the method iterates through\na predefined list of regions, filters all known timezones by prefix, then\nmaps each timezone to its current datetime using ZoneInfo. The output\nstructure is deeply nested and ready for consumption in interfaces or APIs\nthat need organized global time representations.", "parameters": {"properties": {}, "type": "object"}}, {"name": "get_timezones", "description": "This method returns a sorted list of all known timezones supported by\nthe ZoneInfo module. These timezones follow the IANA timezone database\nformat. The result can be used for form inputs, configuration menus,\nvalidation checks, and more. The list ensures compatibility across\nsystems and consistency for applications needing accurate timezone names.", "parameters": {"properties": {}, "type": "object"}}]

meta:
  {"description": "The World Times shows accurate current times worldwide. Easy to use, organized by region or timezone. Fast and reliable.", "manifest": {}}


id: image_generation
user_id: 8461def4-4714-4ba2-92d5-6bd70c266706
name: [FLUX] Image Generation
meta: {"description": "Image generation with Flux model", "manifest": {}}
valves: null
access_control: null
content:
  import os
  import requests
  from urllib.parse import quote
  from typing import Awaitable, Callable, Optional
  import asyncio


  class EventEmitter:
      def __init__(self, emitter: Optional[Callable[[dict], Awaitable[None]]] = None):
          self.emitter = emitter

      async def emit(self, description: str, status: str, done: bool):
          if self.emitter:
              await self.emitter(
                  {
                      "type": "status",
                      "data": {
                          "description": description,
                          "status": status,
                          "done": done,
                      },
                  }
              )


  class Tools:
      def __init__(self):
          pass

      async def image_generation(
          self,
          prompt: str,
          image_format: str,
          model: str = "flux",
          enhance: bool = True,
          token: Optional[str] = None,
          __event_emitter__: Callable[[dict], Awaitable[None]] = None,
          seed: int = None,
      ) -> str:
          emitter = EventEmitter(__event_emitter__)
          await emitter.emit("Starting", "in_progress", False)

          token = os.getenv("OPENAI_API_KEY")
          headers = {"Authorization": f"Bearer {token}"}

          formats = {
              "default": (1920, 1080),
              "square": (1080, 1080),
              "landscape": (1920, 1080),
              "landscape_large": (2560, 1440),
              "portrait": (1080, 1920),
              "portrait_large": (1440, 2560),
          }

          if image_format not in formats:
              image_format = "default"

          width, height = formats[image_format]

          url = (
              f"https://image.pollinations.ai/prompt/{quote(prompt)}"
              f"?width={width}&height={height}&model={model}&nologo=true&enhance={str(enhance).lower()}"
          )
          if seed is not None:
              url += f"&seed={seed}"

          resp = await asyncio.to_thread(requests.get, url, headers=headers)

          if resp.status_code == 200 and "image/" in resp.headers.get("Content-Type", ""):
              await emitter.emit("Success", "complete", True)
              image_url = resp.url

              return (
                  f"Image generation result:\n\n{prompt}\n\n\n"
                  f"Show the generated image using the following markdown syntax format, where '{url}' is the URL of the image:\n\n"
                  f"![Generated Image]({url})\n\n"
                  f"Please replace '{url}' with the actual image URL provided in the context.\n\n"
                  f"Then, describe the generated image based on the above information.\n\n\n"
                  f"Use the same language as the previous user input or user request.\n"
                  f"For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n"
                  f"If it is in English, explain in English. This also applies to other languages.\n\n\n"
              )

          await emitter.emit("Failed", "complete", True)

          return (
              f"Image generation failed for the user's request. The user tried to generate an image with the instruction: '{prompt}'\n\n\n"
              f"Please explain to the user that the image generation has failed.\n"
              f"Also, explain all possible reasons why it might have failed.\n"
              f"Additionally, advise the user not to include, input, or attach any sensitive content, "
              f"as this may also cause the image generation process to fail.\n\n"
              f"Be helpful and empathetic in your response.\n\n\n"
              f"Use the same language as the previous user input or user request.\n"
              f"For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n"
              f"If it is in English, explain in English. This also applies to other languages.\n\n\n"
          )

specs:
  [{"name": "image_generation", "description": "", "parameters": {"properties": {"prompt": {"type": "string"}, "image_format": {"type": "string"}, "model": {"default": "flux", "type": "string"}, "enhance": {"default": true, "type": "boolean"}, "token": {"anyOf": [{"type": "string"}, {"type": "null"}], "default": null}, "seed": {"default": null, "type": "integer"}}, "required": ["prompt", "image_format"], "type": "object"}}]


id: image_generation_kontext
user_id: 23b09e8b-819a-48a4-8b58-d1a5cc8eab68
name: [KONTEXT] Image Generation (Clone)
meta: {"description": "Image generation with Kontext model", "manifest": {}}
valves: null
access_control: null
content:
  import os
  import requests
  from urllib.parse import quote
  from typing import Awaitable, Callable, Optional
  import asyncio


  class EventEmitter:
      def __init__(self, emitter: Optional[Callable[[dict], Awaitable[None]]] = None):
          self.emitter = emitter

      async def emit(self, description: str, status: str, done: bool):
          if self.emitter:
              await self.emitter(
                  {
                      "type": "status",
                      "data": {
                          "description": description,
                          "status": status,
                          "done": done,
                      },
                  }
              )


  class Tools:
      def __init__(self):
          pass

      async def image_generation(
          self,
          prompt: str,
          image_format: str,
          model: str = "kontext",
          enhance: bool = True,
          token: Optional[str] = None,
          __event_emitter__: Callable[[dict], Awaitable[None]] = None,
          seed: int = None,
      ) -> str:
          emitter = EventEmitter(__event_emitter__)
          await emitter.emit("Starting", "in_progress", False)

          token = os.getenv("OPENAI_API_KEY")
          headers = {"Authorization": f"Bearer {token}"}

          formats = {
              "default": (1920, 1080),
              "square": (1080, 1080),
              "landscape": (1920, 1080),
              "landscape_large": (2560, 1440),
              "portrait": (1080, 1920),
              "portrait_large": (1440, 2560),
          }

          if image_format not in formats:
              image_format = "default"

          width, height = formats[image_format]

          url = (
              f"https://image.pollinations.ai/prompt/{quote(prompt)}"
              f"?width={width}&height={height}&model={model}&nologo=true&enhance={str(enhance).lower()}"
          )
          if seed is not None:
              url += f"&seed={seed}"

          resp = await asyncio.to_thread(requests.get, url, headers=headers)

          if resp.status_code == 200 and "image/" in resp.headers.get("Content-Type", ""):
              await emitter.emit("Success", "complete", True)
              image_url = resp.url

              return (
                  f"Image generation result:\n\n{prompt}\n\n\n"
                  f"Show the generated image using the following markdown syntax format, where '{url}' is the URL of the image:\n\n"
                  f"![Generated Image]({url})\n\n"
                  f"Please replace '{url}' with the actual image URL provided in the context.\n\n"
                  f"Then, describe the generated image based on the above information.\n\n\n"
                  f"Use the same language as the previous user input or user request.\n"
                  f"For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n"
                  f"If it is in English, explain in English. This also applies to other languages.\n\n\n"
              )

          await emitter.emit("Failed", "complete", True)

          return (
              f"Image generation failed for the user's request. The user tried to generate an image with the instruction: '{prompt}'\n\n\n"
              f"Please explain to the user that the image generation has failed.\n"
              f"Also, explain all possible reasons why it might have failed.\n"
              f"Additionally, advise the user not to include, input, or attach any sensitive content, "
              f"as this may also cause the image generation process to fail.\n\n"
              f"Be helpful and empathetic in your response.\n\n\n"
              f"Use the same language as the previous user input or user request.\n"
              f"For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n"
              f"If it is in English, explain in English. This also applies to other languages.\n\n\n"
          )

specs:
  [{"name": "image_generation", "description": "", "parameters": {"properties": {"prompt": {"type": "string"}, "image_format": {"type": "string"}, "model": {"default": "kontext", "type": "string"}, "enhance": {"default": true, "type": "boolean"}, "token": {"anyOf": [{"type": "string"}, {"type": "null"}], "default": null}, "seed": {"default": null, "type": "integer"}}, "required": ["prompt", "image_format"], "type": "object"}}]


id: image_generation_turbo
user_id: 23b09e8b-819a-48a4-8b58-d1a5cc8eab68
name: [TURBO] Image Generation (Clone)
meta: {"description": "Image generation with Turbo model", "manifest": {}}
valves: null
access_control: null
content:
  import os
  import requests
  from urllib.parse import quote
  from typing import Awaitable, Callable, Optional
  import asyncio


  class EventEmitter:
      def __init__(self, emitter: Optional[Callable[[dict], Awaitable[None]]] = None):
          self.emitter = emitter

      async def emit(self, description: str, status: str, done: bool):
          if self.emitter:
              await self.emitter(
                  {
                      "type": "status",
                      "data": {
                          "description": description,
                          "status": status,
                          "done": done,
                      },
                  }
              )


  class Tools:
      def __init__(self):
          pass

      async def image_generation(
          self,
          prompt: str,
          image_format: str,
          model: str = "turbo",
          enhance: bool = True,
          token: Optional[str] = None,
          __event_emitter__: Callable[[dict], Awaitable[None]] = None,
          seed: int = None,
      ) -> str:
          emitter = EventEmitter(__event_emitter__)
          await emitter.emit("Starting", "in_progress", False)

          token = os.getenv("OPENAI_API_KEY")
          headers = {"Authorization": f"Bearer {token}"}

          formats = {
              "default": (1920, 1080),
              "square": (1080, 1080),
              "landscape": (1920, 1080),
              "landscape_large": (2560, 1440),
              "portrait": (1080, 1920),
              "portrait_large": (1440, 2560),
          }

          if image_format not in formats:
              image_format = "default"

          width, height = formats[image_format]

          url = (
              f"https://image.pollinations.ai/prompt/{quote(prompt)}"
              f"?width={width}&height={height}&model={model}&nologo=true&enhance={str(enhance).lower()}"
          )
          if seed is not None:
              url += f"&seed={seed}"

          resp = await asyncio.to_thread(requests.get, url, headers=headers)

          if resp.status_code == 200 and "image/" in resp.headers.get("Content-Type", ""):
              await emitter.emit("Success", "complete", True)
              image_url = resp.url

              return (
                  f"Image generation result:\n\n{prompt}\n\n\n"
                  f"Show the generated image using the following markdown syntax format, where '{url}' is the URL of the image:\n\n"
                  f"![Generated Image]({url})\n\n"
                  f"Please replace '{url}' with the actual image URL provided in the context.\n\n"
                  f"Then, describe the generated image based on the above information.\n\n\n"
                  f"Use the same language as the previous user input or user request.\n"
                  f"For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n"
                  f"If it is in English, explain in English. This also applies to other languages.\n\n\n"
              )

          await emitter.emit("Failed", "complete", True)

          return (
              f"Image generation failed for the user's request. The user tried to generate an image with the instruction: '{prompt}'\n\n\n"
              f"Please explain to the user that the image generation has failed.\n"
              f"Also, explain all possible reasons why it might have failed.\n"
              f"Additionally, advise the user not to include, input, or attach any sensitive content, "
              f"as this may also cause the image generation process to fail.\n\n"
              f"Be helpful and empathetic in your response.\n\n\n"
              f"Use the same language as the previous user input or user request.\n"
              f"For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n"
              f"If it is in English, explain in English. This also applies to other languages.\n\n\n"
          )

specs:
  [{"name": "image_generation", "description": "", "parameters": {"properties": {"prompt": {"type": "string"}, "image_format": {"type": "string"}, "model": {"default": "turbo", "type": "string"}, "enhance": {"default": true, "type": "boolean"}, "token": {"anyOf": [{"type": "string"}, {"type": "null"}], "default": null}, "seed": {"default": null, "type": "integer"}}, "required": ["prompt", "image_format"], "type": "object"}}]


id: image_generation_gpt
user_id: 23b09e8b-819a-48a4-8b58-d1a5cc8eab68
name: [GPT] Image Generation (Clone) (Clone)
meta: {"description": "Image generation with GPT Image model", "manifest": {}}
valves: null
access_control: null
content:
  import os
  import requests
  from urllib.parse import quote
  from typing import Awaitable, Callable, Optional
  import asyncio


  class EventEmitter:
      def __init__(self, emitter: Optional[Callable[[dict], Awaitable[None]]] = None):
          self.emitter = emitter

      async def emit(self, description: str, status: str, done: bool):
          if self.emitter:
              await self.emitter(
                  {
                      "type": "status",
                      "data": {
                          "description": description,
                          "status": status,
                          "done": done,
                      },
                  }
              )


  class Tools:
      def __init__(self):
          pass

      async def image_generation(
          self,
          prompt: str,
          image_format: str,
          model: str = "gptimage",
          enhance: bool = True,
          token: Optional[str] = None,
          __event_emitter__: Callable[[dict], Awaitable[None]] = None,
          seed: int = None,
      ) -> str:
          emitter = EventEmitter(__event_emitter__)
          await emitter.emit("Starting", "in_progress", False)

          token = os.getenv("OPENAI_API_KEY")
          headers = {"Authorization": f"Bearer {token}"}

          formats = {
              "default": (1920, 1080),
              "square": (1080, 1080),
              "landscape": (1920, 1080),
              "landscape_large": (2560, 1440),
              "portrait": (1080, 1920),
              "portrait_large": (1440, 2560),
          }

          if image_format not in formats:
              image_format = "default"

          width, height = formats[image_format]

          url = (
              f"https://image.pollinations.ai/prompt/{quote(prompt)}"
              f"?width={width}&height={height}&model={model}&nologo=true&enhance={str(enhance).lower()}"
          )
          if seed is not None:
              url += f"&seed={seed}"

          resp = await asyncio.to_thread(requests.get, url, headers=headers)

          if resp.status_code == 200 and "image/" in resp.headers.get("Content-Type", ""):
              await emitter.emit("Success", "complete", True)
              image_url = resp.url

              return (
                  f"Image generation result:\n\n{prompt}\n\n\n"
                  f"Show the generated image using the following markdown syntax format, where '{url}' is the URL of the image:\n\n"
                  f"![Generated Image]({url})\n\n"
                  f"Please replace '{url}' with the actual image URL provided in the context.\n\n"
                  f"Then, describe the generated image based on the above information.\n\n\n"
                  f"Use the same language as the previous user input or user request.\n"
                  f"For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n"
                  f"If it is in English, explain in English. This also applies to other languages.\n\n\n"
              )

          await emitter.emit("Failed", "complete", True)

          return (
              f"Image generation failed for the user's request. The user tried to generate an image with the instruction: '{prompt}'\n\n\n"
              f"Please explain to the user that the image generation has failed.\n"
              f"Also, explain all possible reasons why it might have failed.\n"
              f"Additionally, advise the user not to include, input, or attach any sensitive content, "
              f"as this may also cause the image generation process to fail.\n\n"
              f"Be helpful and empathetic in your response.\n\n\n"
              f"Use the same language as the previous user input or user request.\n"
              f"For example, if the previous user input or user request is in Indonesian, explain in Indonesian.\n"
              f"If it is in English, explain in English. This also applies to other languages.\n\n\n"
          )

specs:
  [{"name": "image_generation", "description": "", "parameters": {"properties": {"prompt": {"type": "string"}, "image_format": {"type": "string"}, "model": {"default": "gptimage", "type": "string"}, "enhance": {"default": true, "type": "boolean"}, "token": {"anyOf": [{"type": "string"}, {"type": "null"}], "default": null}, "seed": {"default": null, "type": "integer"}}, "required": ["prompt", "image_format"], "type": "object"}}]


