|
5 | 5 | from pathlib import Path |
6 | 6 |
|
7 | 7 | import tiktoken |
8 | | -from langchain import LLMChain, OpenAI, PromptTemplate |
| 8 | +from langchain import LLMChain, PromptTemplate |
9 | 9 | from langchain.callbacks import get_openai_callback |
10 | 10 | from langchain.chat_models import ChatOpenAI |
11 | 11 | from langchain.output_parsers import PydanticOutputParser |
@@ -117,14 +117,14 @@ def redact_tale_information( |
117 | 117 | content_type, |
118 | 118 | docs, |
119 | 119 | verbose=False, |
120 | | - model_name="text-davinci-003", |
| 120 | + model_name="gpt-3.5-turbo", |
121 | 121 | cost_estimation=False, |
122 | 122 | ): |
123 | 123 | prompt = PromptTemplate( |
124 | 124 | template=TYPE_INFORMATION[content_type], input_variables=["information"] |
125 | 125 | ) |
126 | 126 | 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 |
128 | 128 | ) |
129 | 129 | if content_type not in ["no-code-file", "folder-description"]: |
130 | 130 | information = str(docs[0].page_content) |
@@ -250,12 +250,7 @@ def fuse_documentation(code, tale, file_ext, save_path): |
250 | 250 |
|
251 | 251 |
|
252 | 252 | 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) |
259 | 254 | return (len(tokens) / 1000) * GPT_PRICE[model] |
260 | 255 |
|
261 | 256 |
|
|
0 commit comments