Skip to content

fix: proxy client init bug - #130

Open
yamaceay wants to merge 9 commits into
mainfrom
fix/proxy-client-init
Open

fix: proxy client init bug#130
yamaceay wants to merge 9 commits into
mainfrom
fix/proxy-client-init

Conversation

@yamaceay

@yamaceay yamaceay commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

References

What this PR does and why it is needed

v7.2.0 introduced a new bug. Intentionally, init_llm and init_embedding_model now require the model name / id to be passed (previously it was optional). Along with that, default proxy_client setting was also mistakenly removed from the code base.

If no proxy_client is passed through, proxy client is forwarded as None in the underlying subclass call, so that we run into the error "NoneType has no such XXX attribute / property".

So the correct fix to the docs is to add:

def _init_model(proxy_client: Optional[BaseProxyClient], ...):
    proxy_client = proxy_client or get_proxy_client()

Note: There is only one client available in the client registry, namely 'gen-ai-hub', so that the default setting will provide full coverage.

Definition of Done

  • Code is tested (Unit, Integration, E2E)
  • Error handling created / updated & covered by the tests above
  • Documentation updated
    • Only Public APIs are allowed to be used in documentation/tutorials/sample code
  • (Optional) Aligned changes with the JS/TS and Java SDK
  • (Optional) Release notes updated -->

@yamaceay
yamaceay requested a review from alpkom as a code owner September 8, 2026 13:05
@yamaceay yamaceay changed the title fix proxy client init bug fix: proxy client init bug Sep 8, 2026
@yamaceay

yamaceay commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

This check went successful after the fix:

from langchain_core.prompts import PromptTemplate
from langchain_core.output_parsers import StrOutputParser
from packages.gen.gen_ai_hub.proxy.langchain import init_llm
 
template = """Question: {question}
    Answer: Let's think step by step."""
prompt = PromptTemplate(template=template, input_variables=['question'])
question = 'What is a supernova?'

llm = init_llm('gpt-5', max_tokens=300)
chain = prompt | llm | StrOutputParser()
response = chain.invoke({'question': question})

@alpkom alpkom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but let's add some tests (both unit and integration) for the use case which failed before this fix.

@yamaceay

yamaceay commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Now we have two new unit tests. Both fail in the main branch, and all tests pass in this current PR. I am not sure if we will need integration tests, because the bug is not a network or deployment issue per se, just a simple wiring issue. The unit tests should fully cover the fix.

Co-authored-by: yamaceay <46201716+yamaceay@users.noreply.github.com>
@yamaceay
yamaceay requested a review from alpkom September 9, 2026 08:21
@yamaceay yamaceay linked an issue Sep 9, 2026 that may be closed by this pull request
3 tasks
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

Successfully merging this pull request may close these issues.

init_llm(...) does not work in 7.2.0

3 participants