code: def create_app(
      settings: Settings | None = None,
      server_settings: ServerSettings | None = None,
      model_settings: List[ModelSettings] | None = None,
  ):
      config_file = os.environ.get("CONFIG_FILE", None)
      if config_file is not None:
          if not os.path.exists(config_file):
              raise ValueError(f"Config file {config_file} not found!")
          with open(config_file, "rb") as f:
              config_file_settings = (
                  ConfigFileSettings.model_validate_json(f.read())
              )
              server_settings = ServerSettings.model_validate(
                  config_file_settings
              )
              model_settings = config_file_settings.models
  
      if server_settings is None and model_settings is None:
          if settings is None:
              settings = Settings()
          server_settings = ServerSettings.model_validate(settings)
          model_settings = [ModelSettings.model_validate(settings)]
  
      assert (
          server_settings is not None and model_settings is not None
      ), "server_settings and model_settings must be provided together"
  
      set_server_settings(server_settings)
      middleware = [
          Middleware(RawContextMiddleware, plugins=(RequestIdPlugin(),))
      ]
      app = FastAPI(
          middleware=middleware,
          title="🦙 llama.cpp Python API",
          version="0.0.1",
      )
      app.add_middleware(
          CORSMiddleware,
          allow_origins=["*"],
          allow_credentials=True,
          allow_methods=["*"],
          allow_headers=["*"],
      )
      app.include_router(router)
  
      assert model_settings is not None
      set_llama_proxy(model_settings=model_settings)
  
      return app
  
imports: from __future__ import annotations
  import os
  import json
  from threading import Lock
  from functools import partial
  from typing import Iterator, List, Optional, Union, Dict
  import llama_cpp
  import anyio
  from anyio.streams.memory import MemoryObjectSendStream
  from starlette.concurrency import run_in_threadpool, iterate_in_threadpool
  from fastapi import Depends, FastAPI, APIRouter, Request, HTTPException, status
  from fastapi.middleware import Middleware
  from fastapi.middleware.cors import CORSMiddleware
  from fastapi.security import HTTPBearer
  from sse_starlette.sse import EventSourceResponse
  from starlette_context.plugins import RequestIdPlugin
  from starlette_context.middleware import RawContextMiddleware
  from llama_cpp.server.model import LlamaProxy
  from llama_cpp.server.settings import ConfigFileSettings, Settings, ModelSettings, ServerSettings
  from llama_cpp.server.types import CreateCompletionRequest, CreateEmbeddingRequest, CreateChatCompletionRequest, ModelList
  from llama_cpp.server.errors import RouteErrorHandler
label_desc: Use image node_id 5 for calling a global function with example usage: create_app(settings, server_settings, model_settings) and returns: app