Skip to content

Commit 3939a71

Browse files
authored
dev: update the deprecated davinci OpenAI's model to the GPT-3.5 model version. (#77)
1 parent 64553f5 commit 3939a71

3 files changed

Lines changed: 8 additions & 13 deletions

File tree

devtale/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def process_file(
390390
file_docstring, call_cost = redact_tale_information(
391391
content_type="no-code-file",
392392
docs=no_code_file_data,
393-
model_name="text-davinci-003",
393+
model_name="gpt-3.5-turbo",
394394
cost_estimation=cost_estimation,
395395
)
396396
cost += call_cost
@@ -467,7 +467,7 @@ def process_file(
467467
file_docstring, call_cost = redact_tale_information(
468468
content_type="top-level",
469469
docs=summaries,
470-
model_name="text-davinci-003",
470+
model_name="gpt-3.5-turbo",
471471
cost_estimation=cost_estimation,
472472
)
473473
cost += call_cost

devtale/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
DOCSTRING_LABEL = "@DEVTALE-GENERATED:"
1818

19-
# Extracted from https://openai.com/pricing on September 26th, 2023.
20-
GPT_PRICE = {"gpt-4": 0.03, "gpt-3.5-turbo-16k": 0.03, "text-davinci-003": 0.0015}
19+
# Extracted from https://openai.com/pricing on January 15th, 2024.
20+
GPT_PRICE = {"gpt-4": 0.03, "gpt-3.5-turbo-16k": 0.0010, "gpt-3.5-turbo": 0.0015}

devtale/utils.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pathlib import Path
66

77
import tiktoken
8-
from langchain import LLMChain, OpenAI, PromptTemplate
8+
from langchain import LLMChain, PromptTemplate
99
from langchain.callbacks import get_openai_callback
1010
from langchain.chat_models import ChatOpenAI
1111
from langchain.output_parsers import PydanticOutputParser
@@ -117,14 +117,14 @@ def redact_tale_information(
117117
content_type,
118118
docs,
119119
verbose=False,
120-
model_name="text-davinci-003",
120+
model_name="gpt-3.5-turbo",
121121
cost_estimation=False,
122122
):
123123
prompt = PromptTemplate(
124124
template=TYPE_INFORMATION[content_type], input_variables=["information"]
125125
)
126126
teller_of_tales = LLMChain(
127-
llm=OpenAI(model_name=model_name), prompt=prompt, verbose=verbose
127+
llm=ChatOpenAI(model_name=model_name), prompt=prompt, verbose=verbose
128128
)
129129
if content_type not in ["no-code-file", "folder-description"]:
130130
information = str(docs[0].page_content)
@@ -250,12 +250,7 @@ def fuse_documentation(code, tale, file_ext, save_path):
250250

251251

252252
def _calculate_cost(input: str, model: str):
253-
if model == "text-davinci-003":
254-
encoding = "p50k_base"
255-
else:
256-
encoding = "cl100k_base"
257-
258-
tokens = tiktoken.get_encoding(encoding).encode(input)
253+
tokens = tiktoken.get_encoding("cl100k_base").encode(input)
259254
return (len(tokens) / 1000) * GPT_PRICE[model]
260255

261256

0 commit comments

Comments
 (0)