Azure AI

A pipeline for interacting with Azure AI services, enabling seamless communication with various AI models via configurable headers and robust error handling. This includes support for Azure OpenAI models as well as other Azure AI models by dynamically managing headers and request configurations. Azure AI Search (RAG) integration is only supported with Azure OpenAI endpoints.

v3.0.1
azure_ai.py
Python · 4,167 lines
336    class Valves(BaseModel):337        # Custom prefix for pipeline display name338        AZURE_AI_PIPELINE_PREFIX: str = Field(339            default=os.getenv("AZURE_AI_PIPELINE_PREFIX", "Azure AI"),340            description="Custom prefix for the pipeline display name (e.g., 'Azure AI', 'My Azure', 'Company AI'). The final display will be: '<prefix>: <model_name>'",341        )342 343        # API key for Azure AI344        AZURE_AI_API_KEY: EncryptedStr = Field(345            default=os.getenv("AZURE_AI_API_KEY", "API_KEY"),346            description="API key for Azure AI",347            json_schema_extra={"input": {"type": "password"}},

Azure AI

A pipeline for interacting with Azure AI services, enabling seamless communication with various AI models via configurable headers and robust error handling. This includes support for Azure OpenAI models as well as other Azure AI models by dynamically managing headers and request configurations. Support API Key encryption.


Features

  • Supports dynamic model specification via headers.
    • Filters valid parameters to ensure clean requests.
    • Handles streaming and non-streaming responses.
    • Provides flexible timeout and error handling mechanisms.
    • Compatible with Azure OpenAI and other Azure AI models.
    • Predefined models for easy access.
    • Encrypted storage of sensitive API keys
    • Azure AI Search / RAG with native OpenWebUI citations for any chat endpoint and model - the pipeline queries Azure AI Search itself (simple, semantic, vector and hybrid queries, filter, fields_mapping, strictness, top_n_documents, in_scope, role_information from AZURE_AI_DATA_SOURCES) and adds the documents to the prompt
    • Search queries for follow-up turns written by the model from the conversation (AZURE_AI_SEARCH_QUERY_GENERATION, falls back to the user message)
    • Tools, function calling and token usage keep working in chats with Azure AI Search
    • Encrypted Azure AI Search key valve (AZURE_AI_SEARCH_KEY); API key, access token or the managed identity of the Open WebUI host
    • Automatic [docX] to markdown link conversion for clickable citations (also when streamed in pieces)
    • Relevance scores from Azure AI Search displayed in citation cards
    • Answers with [docX] references show only the referenced documents; answers without any show all retrieved documents (default) or none (AZURE_AI_SHOW_ALL_CITATIONS_WITHOUT_REFERENCES=false)
    • Background tasks (titles, tags, follow-ups) skip Azure AI Search and add no citations
    • A failed search ends the request with "Error: Azure AI Search: ..." instead of an answer without the documents
    • A request with data_sources (Azure OpenAI On Your Data) ends with an error that names its removal instead of being forwarded
    • Streamed events of up to 4 MiB are read; a stream that fails ends with an "Error: ..." message instead of an empty or cut off answer

GitHub

Open-WebUI-Functions

Note

For questions, problems, and feature requests, an issue must be created on GitHub.


License

Apache License 2.0

0
0