Token Clip Filter

function

A filter that truncates chat history to retain the 7000 tokens while preserving the system prompt for optimal context management.

houxin
@houxin
·
2 years ago
210
0
1.3K
Created Aug 26, 2024
token_clip_filter.py
Python · 54 lines
"""
title: Token Clip Filter
author: houxin
author_url: https://github.com/hx173149
funding_url: https://github.com/hx173149
version: 0.1
"""

from pydantic import BaseModel, Field
from typing import Optional

import tiktoken

A filter that truncates chat history to retain the 7000 tokens while preserving the system prompt for optimal context management.


0