mirror of
https://github.com/symfony/ai-generic-platform.git
synced 2026-03-23 23:42:22 +01:00
Decouple Platform Token Usage handling from Agent by introducing new interface
This commit is contained in:
@@ -27,6 +27,7 @@ use Symfony\AI\Platform\Result\TextResult;
|
||||
use Symfony\AI\Platform\Result\ToolCall;
|
||||
use Symfony\AI\Platform\Result\ToolCallResult;
|
||||
use Symfony\AI\Platform\ResultConverterInterface;
|
||||
use Symfony\AI\Platform\TokenUsage\TokenUsageExtractorInterface;
|
||||
|
||||
/**
|
||||
* This default implementation is based on the OpenAI GPT completion API.
|
||||
@@ -82,6 +83,11 @@ class ResultConverter implements ResultConverterInterface
|
||||
return 1 === \count($choices) ? $choices[0] : new ChoiceResult(...$choices);
|
||||
}
|
||||
|
||||
public function getTokenUsageExtractor(): ?TokenUsageExtractorInterface
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private function convertStream(RawResultInterface|RawHttpResult $result): \Generator
|
||||
{
|
||||
$toolCalls = [];
|
||||
|
||||
@@ -20,6 +20,7 @@ use Symfony\AI\Platform\Model;
|
||||
use Symfony\AI\Platform\Result\RawResultInterface;
|
||||
use Symfony\AI\Platform\Result\VectorResult;
|
||||
use Symfony\AI\Platform\ResultConverterInterface;
|
||||
use Symfony\AI\Platform\TokenUsage\TokenUsageExtractorInterface;
|
||||
use Symfony\AI\Platform\Vector\Vector;
|
||||
|
||||
/**
|
||||
@@ -66,4 +67,9 @@ class ResultConverter implements ResultConverterInterface
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function getTokenUsageExtractor(): ?TokenUsageExtractorInterface
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user