Spaces:
Runtime error
Runtime error
File size: 906 Bytes
35b22df |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
"""Token predictor utils."""
from typing import Optional
from gpt_index.indices.keyword_table.utils import simple_extract_keywords
def mock_extract_keywords_response(
text_chunk: str, max_keywords: Optional[int] = None, filter_stopwords: bool = True
) -> str:
"""Extract keywords mock response.
Same as simple_extract_keywords but without filtering stopwords.
"""
return ",".join(
simple_extract_keywords(
text_chunk, max_keywords=max_keywords, filter_stopwords=False
)
)
def mock_extract_kg_triplets_response(
text_chunk: str, max_triplets: Optional[int] = None
) -> str:
"""Generate 1 or more fake triplets."""
response = ""
if max_triplets is not None:
for i in range(max_triplets):
response += "(This is, a mock, triplet)\n"
else:
response += "(This is, a mock, triplet)\n"
return response
|