Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
Refactor/epic 4 tweak in doc (#299)
Thomas Hebrard1bd66ac74d07
diff --git a/docs/pages/configuration/config-technical/inference-backend-config.md b/docs/pages/configuration/config-technical/inference-backend-config.mdindex 83eb572ea..8bb35043e 100644--- a/docs/pages/configuration/config-technical/inference-backend-config.md+++ b/docs/pages/configuration/config-technical/inference-backend-config.md@@ -72,6 +72,16 @@ llm = { llm_handle = "claude-4-sonnet", temperature = 0.7 }# Model automatically routed through Pipelex Inference```+### Model Availability Note++While Pipelex Inference provides access to most AI models through a unified API, certain specialized models require their native backend to be enabled directly:++- **FAL image generation models** (e.g., Flux models) - Enable the FAL backend+- **OpenAI image generation** (`gpt-image-1`) - Enable the OpenAI backend (should also work via Azure OpenAI, but we haven't been able to test this - if you've successfully used it on Azure, please let us know on [Discord](https://go.pipelex.com/discord) so we can validate this configuration)+- **Mistral OCR models** - Enable the Mistral backend++These models are not proxied through Pipelex Inference and require direct configuration of their respective backends with appropriate API keys.+## Inference BackendsBackends represent AI service providers that can offer LLMs, OCR models, or image generation models. Each backend is configured with its endpoint and authentication details.@@ -102,6 +112,8 @@ enabled = true# No API key needed for internal/local processing```+Set `enabled` to `true` to activate a backend, or `false` to disable it. When a backend is enabled, you must set its corresponding API key as an environment variable.+### Model SpecificationsEach backend has its own model specification file in `.pipelex/inference/backends/`:diff --git a/docs/pages/quick-start/index.md b/docs/pages/quick-start/index.mdindex cd2f05ac6..5a1ef7b01 100644--- a/docs/pages/quick-start/index.md+++ b/docs/pages/quick-start/index.md@@ -32,19 +32,37 @@ If you already have API keys from LLM providers, you can use them directly:```bash# Add to your .env file+# To directly use models on OpenAI, you will need to set the following variableOPENAI_API_KEY=your-openai-key+# To directly use models on Anthropic, you will need to set the following variableANTHROPIC_API_KEY=your-anthropic-key+# To directly use models on Google, you will need to set the following variableGOOGLE_API_KEY=your-google-key-# Or for Azure OpenAI+# To directly use models on Mistral, you will need to set the following variable+MISTRAL_API_KEY=your-mistral-key+# To directly use models on FAL, you will need to set the following variable+FAL_API_KEY=your-fal-key+# To directly use models on XAI, you will need to set the following variable+XAI_API_KEY=your-xai-key++# To use models via Ollama, you will need to set the following variables+OLLAMA_API_KEY=your-ollama-key+# To use models via BlackboxAI, you will need to set the following variables+BLACKBOX_API_KEY=your-blackboxai-key+# To use models via Azure OpenAI, you will need to set the following variablesAZURE_API_KEY=your-azure-keyAZURE_API_BASE=your-azure-endpoint-# Or for AWS Bedrock+AZURE_API_VERSION=your-azure-version+# To use models via AWS Bedrock, you will need to set the following variablesAWS_ACCESS_KEY_ID=your-aws-keyAWS_SECRET_ACCESS_KEY=your-aws-secret+AWS_REGION=your-aws-region```-For complete configuration details, see the [Inference Backend Configuration](../configuration/config-technical/inference-backend-config.md) documentation.+Adding those env variables is not enough. You also need to configure the inference backend to choose where to route the AI calls.+See the [Inference Backend Configuration](../configuration/config-technical/inference-backend-config.md#inference-backends) documentation.+For example, if you want to use a gemini model via GOOGLE, enable the google backend in `.pipelex/inference/backends.toml` and set the API key in your env.---## Your first LLM call with Pipelexdiff --git a/pipelex/pipe_operators/func/pipe_func.py b/pipelex/pipe_operators/func/pipe_func.pyindex 932925e3e..fff8a204d 100644--- a/pipelex/pipe_operators/func/pipe_func.py+++ b/pipelex/pipe_operators/func/pipe_func.py@@ -1,3 +1,4 @@+import asynciofrom typing import Literal, cast, get_type_hintsfrom typing_extensions import override@@ -48,11 +49,12 @@ class PipeFunc(PipeOperator[PipeFuncOutput]):log.debug(f"Applying function '{self.function_name}'")function = func_registry.get_required_function(self.function_name)- if not callable(function):- msg = f"Function '{self.function_name}' is not callable"- raise TypeError(msg)- func_output_object = await function(working_memory=working_memory)+ if asyncio.iscoroutinefunction(function):+ func_output_object = await function(working_memory=working_memory)+ else:+ func_output_object = await asyncio.to_thread(function, working_memory=working_memory)+the_content: StuffContentif isinstance(func_output_object, StuffContent):the_content = func_output_object@@ -92,9 +94,6 @@ class PipeFunc(PipeOperator[PipeFuncOutput]):log.debug(f"Dry run for PipeFunc '{self.function_name}'")function = func_registry.get_required_function(self.function_name)- if not callable(function):- msg = f"Function '{self.function_name}' is not callable"- raise TypeError(msg)# Check that all needed inputs are present in working memoryneeded_inputs = self.needed_inputs()diff --git a/pipelex/tools/func_registry.py b/pipelex/tools/func_registry.pyindex 34b58e97e..7b7532417 100644--- a/pipelex/tools/func_registry.py+++ b/pipelex/tools/func_registry.py@@ -1,7 +1,7 @@import inspectimport loggingfrom collections.abc import Callable-from typing import Any, TypeVar, get_type_hints+from typing import Any, TypeVar, cast, get_type_hintsfrom pydantic import Field, PrivateAttr, RootModel@@ -113,18 +113,25 @@ class FuncRegistry(RootModel[FuncRegistryDict]):"""Checks if a function is in the registry by its name."""return name in self.root- def is_eligible_function(self, func: Callable[..., Any]) -> bool:+ def is_eligible_function(self, func: Any) -> bool:"""Checks if a function matches the criteria for PipeFunc registration:+ - Must be callable- Exactly 1 parameter named "working_memory" with type WorkingMemory- Return type that is a subclass of StuffContent"""+ if not callable(func):+ return False++ the_function = cast("Callable[..., Any]", func)+try:# Import here to avoid circular imports+ # TODO: code-smellfrom pipelex.core.memory.working_memory import WorkingMemory # noqa: PLC0415from pipelex.core.stuffs.stuff_content import StuffContent # noqa: PLC0415# Get function signature- sig = inspect.signature(func)+ sig = inspect.signature(the_function)params = list(sig.parameters.values())# Check parameter count and name@@ -136,7 +143,7 @@ class FuncRegistry(RootModel[FuncRegistryDict]):return False# Get type hints- type_hints = get_type_hints(func)+ type_hints = get_type_hints(the_function)# Check parameter typeif "working_memory" not in type_hints: