ask-tokens-rails 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f36ea3ade0e11cbb7a52d00ae56f1168574ce7a559ce8995cc6ca43d6716de8
|
|
4
|
+
data.tar.gz: c5b9d81ebc12fe4a51080cd773d8728dad5eb75ffbd50f15329623083ba8dcf9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48e3aaefc5ac428854b2c998fe9f4c66f9bd0b78483184ef17ac43494ddd52c77f0dc2939c4bdab114f14222bc208a5174536212c027b90417d3d77f8373e3a4
|
|
7
|
+
data.tar.gz: 29dff0d60146f50f546f20be6643e8c8bd938c671a9d74f238c84f030af048ca07558fd5154e63d44641111352496382f7db00ea379554d29ecf5e1baafb8bb5
|
|
@@ -42,7 +42,8 @@ module Ask
|
|
|
42
42
|
metadata: meta,
|
|
43
43
|
expires_at: entry.expires_at,
|
|
44
44
|
balance: entry.balance,
|
|
45
|
-
created_at: entry.created_at
|
|
45
|
+
created_at: entry.created_at,
|
|
46
|
+
**extract_columns_from_metadata(meta)
|
|
46
47
|
)
|
|
47
48
|
entry.with(id: txn.id)
|
|
48
49
|
end
|
|
@@ -89,6 +90,18 @@ module Ask
|
|
|
89
90
|
created_at: txn.created_at
|
|
90
91
|
)
|
|
91
92
|
end
|
|
93
|
+
|
|
94
|
+
# Extract well-known metadata keys into their matching model columns.
|
|
95
|
+
# Only writes keys that exist in metadata, so grants/debits without
|
|
96
|
+
# LLM context are unaffected. Symbol and string keys are both handled.
|
|
97
|
+
COLUMN_KEYS = %i[model_id provider input_tokens output_tokens cached_tokens llm_cost_usd multiplier].freeze
|
|
98
|
+
|
|
99
|
+
def extract_columns_from_metadata(meta)
|
|
100
|
+
COLUMN_KEYS.each_with_object({}) do |key, hash|
|
|
101
|
+
value = meta[key] || meta[key.to_s]
|
|
102
|
+
hash[key] = value if value
|
|
103
|
+
end
|
|
104
|
+
end
|
|
92
105
|
end
|
|
93
106
|
end
|
|
94
107
|
end
|