You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
async def set_citations(self) -> None:
for annotation in self.annotations:
citation = annotation.file_citation
try:
retrieved_file: FileObject = await self.client.files.retrieve(
annotation.file_citation.file_id
)
To cache the client retrieve call, you can use a dictionary to store the results of previous calls. Before making a call, you can check if the result is already in the cache. If it is, you can return the cached result instead of making a new call. Here's how you can modify the set_citations method to include caching:
In this code, self.file_cache is a dictionary that stores the results of previous calls to self.client.files.retrieve. Before making a call, we check if the result is already in self.file_cache. If it is, we use the cached result instead of making a new call. If it's not, we make the call and store the result in self.file_cache for future use.
The text was updated successfully, but these errors were encountered:
To cache the client retrieve call, you can use a dictionary to store the results of previous calls. Before making a call, you can check if the result is already in the cache. If it is, you can return the cached result instead of making a new call. Here's how you can modify the
set_citations
method to include caching:In this code,
self.file_cache
is a dictionary that stores the results of previous calls toself.client.files.retrieve
. Before making a call, we check if the result is already inself.file_cache
. If it is, we use the cached result instead of making a new call. If it's not, we make the call and store the result inself.file_cache
for future use.The text was updated successfully, but these errors were encountered: