Skip to content

Commit de85ef7

Browse files
committed
ref
1 parent 9ad3eef commit de85ef7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

examples/ollama/chat-llama-with-cache.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545

4646
assert($secondResult->getMetadata()->get('cached'));
4747
assert('chat' === $secondResult->getMetadata()->get('prompt_cache_key'));
48-
assert(0 !== $secondResult->getMetadata()->get('cached_prompt_count'));
49-
assert(0 !== $secondResult->getMetadata()->get('cached_completion_count'));
48+
assert($result->getMetadata()->get('cached_prompt_count') === $secondResult->getMetadata()->get('cached_prompt_count'));
49+
assert($result->getMetadata()->get('cached_completion_count') === $secondResult->getMetadata()->get('cached_completion_count'));
50+
assert($result->getMetadata()->get('cached_time') === $secondResult->getMetadata()->get('cached_time'));

src/platform/src/Bridge/Ollama/OllamaResultConverter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function doConvertCompletion(array $data, array $options): ResultInterfac
8383
$metadata->add('prompt_cache_key', $options['prompt_cache_key']);
8484
$metadata->add('cached_prompt_count', $data['prompt_eval_count']);
8585
$metadata->add('cached_completion_count', $data['eval_count']);
86+
$metadata->add('cached_time', (new \DateTimeImmutable())->getTimestamp());
8687
}
8788

8889
return $result;

0 commit comments

Comments
 (0)