เกตเวย์ AI ที่ตอบจากสิ่งที่เคยตอบไปแล้ว
ผู้
Feature ที่core/semantic-caching หน้า
พื้นที่
สิ่งที่ตัวอย่างนี้บิลด์
| อินสแตนซ์ | Component ของ | สิ่ง |
|---|---|---|
router | core/gateway/litellm | เกตเวย์ AI: alias สำหรับassistant และ alias เอมเบดดิง embedder โดยmodels ของ |
chat | core/ai-model/openai | โมเดลassistant คือ API ของ OpenAI เอง |
embeddings | core/ai-model/openai-embedding | โมเดลembedder เข้า |
cache | core/datastore/redis | ที่ |
เส้นuses สามmodels ของcredential เป็นcache_store ของcredential เป็นapi_key ซึ่งanswers ซึ่งpassword ซึ่งcache_password ตัวopenai_key ตัวanswers ระบุ alias เอมเบดดิง0.9 ในscope ไว้ จึงend_user
ร่างตัวอย่าง
คุณ
เขียน
aggrega draft --example ai-gateway-semantic-cacheจาก
cd ai-gateway-semantic-cacheบิลด์
aggrega build --release release.yaml --auto-pullRelease ต้อง
aggrega pull --release release.yaml # resolve once, then build with no flagaggrega build --release release.yaml --auto-pull # or resolve during the buildพื้นที่.aggrega-config.yaml ระบุ realization ของpipeline-step/litellm-gateway-config ซึ่งdefault_registry ระบุ คือ hub.aggrega.ai
บิลด์<workspace> แทน
[… omitted: a line reporting on the gateway configuration step's plugin, five warnings, one per credential attachment, that the declared-sensitive origin reaches the target with no per-key sensitivity marking, because the realization maps it through a valuesMapping, the resolution's summary and a total build time, which differ per run, and a notice that core/referenced-secret declares origin in both of its pillars]Build completed: 13 files written to <workspace>/distกับผู้ช่วย AI
ผู้
ใช้เฉพาะเครื่องมือของ Aggrega และอย่าสร้างโฟลเดอร์เอง หากโฟลเดอร์ Workspace ยังไม่มีโฟลเดอร์ `ai-gateway-semantic-cache` เรียกเครื่องมือ `draft` หนึ่งครั้งโดยตั้ง `example` เป็น `ai-gateway-semantic-cache` และไม่ใส่ `dir`: เครื่องมือจะเขียนตัวอย่างลงในโฟลเดอร์ `ai-gateway-semantic-cache` ใหม่ จากนั้นเรียกเครื่องมือ `build` โดยตั้ง `workspace_root` เป็น `ai-gateway-semantic-cache` ตั้ง `release` เป็น `release.yaml` ตั้ง `auto_pull` เป็น true และตั้ง `write` เป็น true แจ้งฉันว่าบิลด์เขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใต้ `ai-gateway-semantic-cache/dist/`ทรีที่เรนเดอร์
dist/helm/├── cache--password--cache-secret-cache-password.yaml├── cache-default-service.yaml├── cache-deployment.yaml├── chat-service.yaml├── embeddings-service.yaml├── router--api-zukey--router-secret-router-api-key.yaml├── router--assistant-zdcredential--router-secret-router-assistant-credential.yaml├── router--embedder-zdcredential--router-secret-router-embedder-credential.yaml├── router--replies-zdcredential--router-secret-router-replies-credential.yaml├── router-default-service.yaml├── router-deployment.yaml└── router/ ├── litellm-gateway-config/ │ └── configmap.yaml └── request-guard/ └── request-guard.yamlการ
โมเดลที่ให้บริการ
ตารางmodels เขียน
model_list: - model_name: "assistant" litellm_params: model: "openai/gpt-4o" api_base: "https://api.openai.com/v1" api_key: os.environ/LITELLM_MODEL_ASSISTANT_API_KEY - model_name: "embedder" litellm_params: model: "openai/text-embedding-3-small" api_base: "https://api.openai.com/v1" api_key: os.environ/LITELLM_MODEL_EMBEDDER_API_KEYแคชตามที่เกตเวย์อ่าน
นี่config.yaml ของ dist/helm/router/litellm-gateway-config/configmap.yaml ตั้งแต่ litellm_settings เป็นต้น
[… omitted: the routing table]litellm_settings: callbacks: - /etc/litellm-request-guard/request_field_filter.filter cache: true cache_params: host: os.environ/SEMANTIC_CACHE_STORE_HOST port: os.environ/SEMANTIC_CACHE_STORE_PORT redis_semantic_cache_embedding_model: embedder redis_semantic_cache_index_name: router-answers semantic_cache_scope: end_user similarity_threshold: 0.9 supported_call_types: - acompletion - completion - aresponses - responses - aanthropic_messages - anthropic_messages ttl: 3600 type: redis-semanticมี
ที่host และ port ระบุcache_store จาก dist/helm/router-deployment.yaml นี่env ของ
env: - name: LITELLM_MASTER_KEY valueFrom: secretKeyRef: name: router-api-key key: master-key - name: REDIS_PASSWORD valueFrom: secretKeyRef: name: router-replies.credential key: password - name: LITELLM_MODEL_ASSISTANT_API_KEY valueFrom: secretKeyRef: name: router-assistant.credential key: api-key - name: LITELLM_MODEL_EMBEDDER_API_KEY valueFrom: secretKeyRef: name: router-embedder.credential key: api-key - name: SEMANTIC_CACHE_STORE_HOST value: cache-default - name: SEMANTIC_CACHE_STORE_PORT value: "6379"cache-default คือ Service ที่ Recipe ของ6379 คือREDIS_PASSWORD ซึ่งcredential บนcache_store เรนเดอร์ คือ router-replies.credential และcache-password และ--requirepass ที่cache_store จะ
โมเดลembedder ผ่าน
อายุttl เป็น
มี
ดัชนีrouter-answers ดัง
ใครได้รับบริการจากรายการแคชรายการเดียว
เกตเวย์0.9:
- คีย์
ที่ คำขอ แสดง ตาม ที่ เกตเวย์ ยืนยัน พร้อม ทีม และ องค์กร ของ คีย์ นั้น - ใต้
end_userคือผู้ ใช้ ปลาย ทาง ที่ คำขอ ระบุ - โมเดล
ที่ คำขอ ขอ และ พารามิเตอร์ อื่น ของ คำขอ อุณหภูมิ ที่ ต่าง กัน คือ บัคเก็ต ที่ ต่าง กัน
เกตเวย์metadata ของmetadata ของmetadata.user_api_key ด้วย HTTP 400 ที่
metadata ของmodel_group เข้าcaching_groups ทำให้redis_namespace เก็บ
คีย์api_key และ
ภายend_user ซึ่งx-litellm-end-user-id หรือ x-litellm-customer-id หรือuser, metadata.user_id, litellm_metadata.user หรือ safety_identifier ในalice ให้alice และbob
มี
- เกตเวย์
ไม่ ผู้ยืนยัน ชื่อ ใด เลย ใน ชื่อ เหล่า นั้น ที่ ถือ คีย์ ระบุ ผู้ ใช้ ปลาย ทาง คน ใด ก็ได้ และ ได้ รับ สิ่ง ที่ เก็บ ไว้ สำหรับ ผู้ ใช้ ปลาย ทาง นั้น เก็บ คีย์ ไว้ กับ แอปพลิเคชัน ที่ รู้ ว่า ผู้ ใช้ ปลาย ทาง ของ ตน คือ ใคร และ ปล่อย ให้ แอปพลิเคชัน นั้น ระบุ ชื่อ อย่า ส่ง มอบ คีย์ ให้ ผู้ ใช้ ปลาย ทาง เอง - คำขอ
ที่ ทุกไม่ ระบุ ผู้ ใช้ ปลาย ทาง ใช้ แคช เดียวกัน คำขอ เช่น นั้น ที่ แสดง คีย์ เดียวกัน ได้ รับ บริการ จาก รายการ เดียวกัน ไม่ ว่า ใคร เป็น ผู้ ส่ง
ภายkey ผู้scope: key ในsemantic_cache_scope ในkey และalice ที่x-litellm-end-user-id จึงbob ที่user ใน
อะไรที่ทำให้บิลด์หยุด
แต่ละ
-
ไม่มี
คีย์ ลบผู้ ดูแล การ แนบ api_keyแล้วบิลด์ หยุด ก่อน เรนเดอร์ สิ่ง ใด: [… omitted: a line reporting on the gateway configuration step's plugin, what resolving the lockfile prints, the same halt among it, and a notice that core/referenced-secret declares origin in both of its pillars][CATALOG_ERROR E0033]Recipe/FeatureRecipe assertionscaused by: FeatureRecipe "semantic-caching-litellm" instance "router" assertion "gateway_checks_the_caller": [… omitted: the template position and the assertion's own source]: error calling fail: assertion failed: core/semantic-caching attachment "answers" on "router" needs core/gateway/litellm to check every caller's key before a cached reply is served, but its api_key credential slot is not attached, so the gateway checks no caller and a cache bucket would be made only of what each caller claims. Attach a credential to the api_key slot of "router" -
ไม่มี
ที่ ลบจัด เก็บ เส้น เชื่อม cache_storeแล้วบิลด์ หยุด โดย ระบุ ซ็อกเก็ต ที่ ต้อง เชื่อม โยง -
ที่
จัด เก็บ ที่ ไม่ เผย แพร่ vector_searchซ็อกเก็ตยอมรับ ที่ จัด เก็บ แบบ คีย์-ค่า และ Recipe ของ เกตเวย์ หยุด กับ ตัว ที่ ไม่ ระบุ ว่า ให้ บริการ การ ค้นหา เวกเตอร์ ของ เอนจิน คิวรี Redis ซึ่ง แคช ใช้ ค้นหา คำ ตอบ ของ ตน: Redis ก่อน รุ่น 8.0 หรือ Valkey จะ ไม่ แคช สิ่ง ใด ใน ขณะ ที่ ทุก คำขอ ยัง สำเร็จ -
การ
แนบ core/semantic-cachingตัวที่ ซึ่งสอง บน เกตเวย์ มี แคช เพียง ตัว เดียว -
core/data-maskingบนเกตเวย์ ทั้งเดียวกัน สอง ประกาศ ว่า ขัด แย้ง กัน เพราะ แคช ใช้ คีย์ ของ คำขอ หลัง การ ปิดบัง คำขอ สอง รายการ ที่ ต่าง กัน เฉพาะ ใน สิ่ง ที่ การ ปิดบัง แทนที่ จึง ใช้ คำ ตอบ ที่ เก็บ ไว้ ร่วม กัน
เมื่อใช้ที่จัดเก็บไม่ได้
เกตเวย์password ของcredential บนcache_store
ตำแหน่งที่คอมไพเลอร์ไม่ตีความ
คอมไพเลอร์cache-default:6379 หรือ
การปรับแต่งตัวอย่างนี้
- ใช้
แคช เพิ่มเดียว ต่อ คีย์ scope: keyในการ แนบ answersในที่ ที่ ผู้ เรียก ทุก คน ควร ได้ รับคำ ตอบ เดียวกัน - รัน
ที่ ลบจัด เก็บ โดย ไม่มี รหัส ผ่าน การ แนบ passwordของที่ จัด เก็บ และ credentialบนเส้น เชื่อม cache_storeพร้อมกัน พร้อม พารามิเตอร์ cache_passwordใน Aggregate และ ReleaseREDIS_PASSWORDของเกตเวย์ จะ เรนเดอร์ เป็น ค่า ว่าง ซึ่ง เชื่อม ต่อ ได้ โดย ไม่ ใช้ รหัส ผ่าน การ ลบ การ แนบ เพียง หนึ่ง ใน สอง ทำให้ แคช ใช้ ที่ จัด เก็บ ไม่ ได้ - จับ
คู่ เพิ่มพรอมต์ มาก ขึ้น หรือ น้อย ลง similarity_thresholdเพื่อให้ คำ ตอบ เฉพาะ รายการ ที่ ตรง กัน ใกล้ กว่า หรือ ลด เพื่อ ให้ คำ ตอบ มาก ขึ้น ค่า ใด เหมาะ ขึ้น อยู่ กับ โมเดล เอมเบดดิง