Spaces:
Sleeping
Sleeping
Update dynamic_cheatsheet/language_model.py
Browse files
dynamic_cheatsheet/language_model.py
CHANGED
@@ -113,6 +113,14 @@ class LanguageModel:
|
|
113 |
raise ValueError("History must contain at least one message.")
|
114 |
|
115 |
print('history\n', history)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
# The self.client is already a partial function with model, api_key, base_url, etc., pre-filled for SambaNova
|
117 |
response = self.client(
|
118 |
messages=history,
|
|
|
113 |
raise ValueError("History must contain at least one message.")
|
114 |
|
115 |
print('history\n', history)
|
116 |
+
from litellm import num_tokens_from_messages
|
117 |
+
|
118 |
+
tokens_num = num_tokens_from_messages(
|
119 |
+
messages=history,
|
120 |
+
model=self.model_name
|
121 |
+
)
|
122 |
+
print("prompt tokens:", tokens_num)
|
123 |
+
|
124 |
# The self.client is already a partial function with model, api_key, base_url, etc., pre-filled for SambaNova
|
125 |
response = self.client(
|
126 |
messages=history,
|