Skip to content

Commit

Permalink
start deprecating old tags
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Oct 12, 2024
1 parent 4b8d3a0 commit 010e520
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies = [
"jinja2",
"litellm",
"pydantic",
"deprecated",
]

[project.urls]
Expand Down
5 changes: 5 additions & 0 deletions src/banks/extensions/docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# This module exists for documentation purpose only
from deprecated import deprecated


def chat(role: str): # pylint: disable=W0613
Expand Down Expand Up @@ -39,10 +40,14 @@ def completion(model_name: str): # pylint: disable=W0613
"""


@deprecated(version="1.3.0", reason="This extension is deprecated, use {% completion %} instead.")
def generate(model_name: str): # pylint: disable=W0613
"""
`generate` can be used to call the LiteLLM API passing the tag text as a prompt and get back some content.
Deprecated:
This extension is deprecated, use `{% completion %}` instead.
Example:
```jinja
{% generate "write a tweet with positive sentiment" "gpt-3.5-turbo" %}
Expand Down
2 changes: 2 additions & 0 deletions src/banks/extensions/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from jinja2.ext import Extension
from litellm import acompletion, completion
from litellm.types.utils import ModelResponse
from deprecated import deprecated

from banks.errors import CanaryWordError
from banks.prompt import Prompt
Expand All @@ -15,6 +16,7 @@
SYSTEM_PROMPT = Prompt("{{canary_word}} You are a helpful assistant.")


@deprecated(version="1.3.0", reason="This extension is deprecated, use {% completion %} instead.")
class GenerateExtension(Extension):
# a set of names that trigger the extension.
tags = {"generate"} # noqa
Expand Down
5 changes: 5 additions & 0 deletions src/banks/extensions/inference_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
import os

import requests
from deprecated import deprecated
from jinja2 import nodes
from jinja2.ext import Extension


@deprecated(version="1.3.0", reason="This extension is deprecated, use {% completion %} instead.")
class HFInferenceEndpointsExtension(Extension):
"""
`inference_endpoint` can be used to call the Hugging Face Inference Endpoint API
passing a prompt to get back some content.
Deprecated:
This extension is deprecated, use `{% completion %}` instead.
Example:
```jinja
{% inference_endpoint "write a tweet with positive sentiment", "https://foo.aws.endpoints.huggingface.cloud" %}
Expand Down

0 comments on commit 010e520

Please sign in to comment.