Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O3 Cost and O3 Condition Is Not Updated In Openai Info.py(langchian-community) #29548

Open
5 tasks done
nikhil-weamai opened this issue Feb 3, 2025 · 0 comments
Open
5 tasks done

Comments

@nikhil-weamai
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

def standardize_model_name(
    model_name: str,
    is_completion: bool = False,
    *,
    token_type: TokenType = TokenType.PROMPT,
) -> str:
    """
    Standardize the model name to a format that can be used in the OpenAI API.

    Args:
        model_name: Model name to standardize.
        is_completion: Whether the model is used for completion or not.
            Defaults to False. Deprecated in favor of ``token_type``.
        token_type: Token type. Defaults to ``TokenType.PROMPT``.

    Returns:
        Standardized model name.

    """
    if is_completion:
        warn_deprecated(
            since="0.3.13",
            message=(
                "is_completion is deprecated. Use token_type instead. Example:\n\n"
                "from langchain_community.callbacks.openai_info import TokenType\n\n"
                "standardize_model_name('gpt-4o', token_type=TokenType.COMPLETION)\n"
            ),
            removal="1.0",
        )
        token_type = TokenType.COMPLETION
    model_name = model_name.lower()
    if ".ft-" in model_name:
        model_name = model_name.split(".ft-")[0] + "-azure-finetuned"
    if ":ft-" in model_name:
        model_name = model_name.split(":")[0] + "-finetuned-legacy"
    if "ft:" in model_name:
        model_name = model_name.split(":")[1] + "-finetuned"
    if token_type == TokenType.COMPLETION and (
        model_name.startswith("gpt-4")
        or model_name.startswith("gpt-3.5")
        or model_name.startswith("gpt-35")
        or model_name.startswith("o1-")
        or ("finetuned" in model_name and "legacy" not in model_name)
    ):
        return model_name + "-completion"
    if (
        token_type == TokenType.PROMPT_CACHED
        and (model_name.startswith("gpt-4o") or model_name.startswith("o1"))
        and not (model_name.startswith("gpt-4o-2024-05-13"))
    ):
        return model_name + "-cached"
    else:
        return model_name

Error Message and Stack Trace (if applicable)

No response

Description

  • langchain==0.3.17
  • langchain-community==0.3.16
  • langchain-openai==0.3.3
  • langchain-core==0.3.33
  • openai==1.61.0

System Info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:06:23 PDT 2024; root:xnu-11215.41.3~3/RELEASE_ARM64_T8132
Python Version: 3.9.6 (default, Oct 4 2024, 08:01:31)
[Clang 16.0.0 (clang-1600.0.26.4)]

Package Information

langchain_core: 0.3.33
langchain: 0.3.17
langchain_community: 0.3.16
langsmith: 0.1.147
langchain_anthropic: 0.3.0
langchain_google_genai: 2.0.6
langchain_huggingface: 0.1.0
langchain_openai: 0.3.3
langchain_text_splitters: 0.3.5

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.11.11
anthropic: 0.42.0
async-timeout: 4.0.3
dataclasses-json: 0.6.7
defusedxml: 0.7.1
filetype: 1.2.0
google-generativeai: 0.8.3
httpx: 0.27.0
httpx-sse: 0.4.0
huggingface-hub: 0.26.2
jsonpatch: 1.33
langsmith-pyo3: Installed. No version info available.
numpy: 1.26.4
openai: 1.61.0
orjson: 3.9.15
packaging: 24.2
pydantic: 2.9.2
pydantic-settings: 2.6.0
PyYAML: 6.0.1
requests: 2.31.0
requests-toolbelt: 1.0.0
sentence-transformers: 3.2.0
SQLAlchemy: 2.0.35
tenacity: 9.0.0
tiktoken: 0.8.0
tokenizers: 0.20.3
transformers: 4.45.2
typing-extensions: 4.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant