Hi, community.
I’m trying to create a cached content in Vertex AI. I want to provide a custom ID to the endpoint. Is it possible?
My goal:
async def achat(
self, messages: Sequence[ChatMessage], **kwargs: Any
) -> ChatResponse:
if self.cache_config["enabled"]:
try:
cached_content: caching.CachedContent = caching.CachedContent(
cached_content_name=self.cache_config["cache_id"],
)
except Exception:
cached_content = caching.CachedContent.create(
model_name=self.model,
system_instruction=next(
filter(lambda x: x.role == MessageRole.SYSTEM, messages)
),
display_name=self.cache_config["cache_id"],
)
model: GenerativeModel = GenerativeModel.from_cached_content(
cached_content=cached_content
)
raise RuntimeError("Testing cached content. Model almost instantiated")
else:
model = GenerativeModel(model_name=self.model)
Users will provide custom IDs to the cached content, I’d like to be able to let the user control that