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

ChatSambaNovaCloud with_structured_output json_mode is always failing since kwargs are always not None if they are not used #28776

Open
5 tasks done
orlandokaramani opened this issue Dec 17, 2024 · 1 comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@orlandokaramani
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

The following:

from langchain_community.chat_models.sambanova import ChatSambaNovaCloud
from pydantic import BaseModel

llm = ChatSambaNovaCloud(
    sambanova_api_key="37d19d6b-2c13-4658-a157-bb9bb0362096",
    model="Qwen2.5-72B-Instruct",
    temperature=0,
)

structured_llm = llm.with_structured_output(method="json_mode")

Raises exception:
raise ValueError(f"Received unsupported arguments {kwargs}")

Error Message and Stack Trace (if applicable)


ValueError                               
 Traceback (most recent call last) Cell In[15], line 10
      2 from pydantic import BaseModel
      4 llm = ChatSambaNovaCloud(
      5     sambanova_api_key="37d19d6b-2c13-4658-a157-bb9bb0362096",
      6     model="Qwen2.5-72B-Instruct",
      7     temperature=0,
      8 )
---> 10 structured_llm = llm.with_structured_output(method="json_mode")
     12 structured_llm.invoke(
     13                     "Answer the following question. "
     14                     "Make sure to return a JSON blob with keys 'answer' and 'justification'.\n\n"
     15                     "What's heavier a pound of bricks or a pound of feathers?"
     16                 )

File ~/.pyenv/versions/3.10.0/lib/python3.10/site-packages/langchain_community/chat_models/sambanova.py:620, in ChatSambaNovaCloud.with_structured_output(self, schema, method, include_raw, **kwargs)
    382 """Model wrapper that returns outputs formatted to match the given schema.
    383 
    384 Args:
   (...)
    617         # }
    618 """  # noqa: E501
    619 if kwargs is not None:
--> 620     raise ValueError(f"Received unsupported arguments {kwargs}")
    621 is_pydantic_schema = _is_pydantic_class(schema)
    622 if method == "function_calling":

ValueError: Received unsupported arguments {}

Description

  • I'm trying to use json_mode of ChatSambaNovaCloud using method with_structured_output
  • I think the patch should be as below, since {} is interpreted as not None
 if kwargs:
    raise ValueError(f"Received unsupported arguments {kwargs}")

System Info

System Information
------------------
> OS:  Darwin
> OS Version:  Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:36 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6020
> Python Version:  3.12.6 (main, Sep  6 2024, 19:03:47) [Clang 15.0.0 (clang-1500.3.9.4)]

Package Information
-------------------
> langchain_core: 0.3.25
> langchain: 0.3.12
> langchain_community: 0.3.12
> langsmith: 0.2.3
> langchain_chroma: 0.1.2
> langchain_google_vertexai: 2.0.9
> langchain_groq: 0.2.1
> langchain_openai: 0.2.12
> langchain_text_splitters: 0.3.3

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.11.10
> anthropic[vertexai]: Installed. No version info available.
> async-timeout: Installed. No version info available.
> chromadb: 0.5.23
> dataclasses-json: 0.6.7
> fastapi: 0.115.6
> google-cloud-aiplatform: 1.74.0
> google-cloud-storage: 2.19.0
> groq: 0.13.1
> httpx: 0.27.2
> httpx-sse: 0.4.0
> jsonpatch: 1.33
> langchain-mistralai: Installed. No version info available.
> langsmith-pyo3: Installed. No version info available.
> numpy: 2.2.0
> openai: 1.58.1
> orjson: 3.10.12
> packaging: 24.2
> pydantic: 2.9.2
> pydantic-settings: 2.7.0
> PyYAML: 6.0.2
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> SQLAlchemy: 2.0.36
> tenacity: 9.0.0
> tiktoken: 0.8.0
> typing-extensions: 4.12.2
@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Dec 17, 2024
@keenborder786
Copy link
Contributor

@orlandokaramani fixed

ccurme pushed a commit that referenced this issue Dec 18, 2024
)

- **Description:** The `kwargs` was being checked as None object which
was causing the rest of code in `with_structured_output` not getting
executed. The checking part has been fixed in this PR.
- **Issue:** #28776
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants