<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: GENERATIVE AI HUB SDK - Python Error in Artificial Intelligence Forum</title>
    <link>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13799815#M389</link>
    <description>&lt;P&gt;Thanks, Mario, it worked perfectly&lt;/P&gt;&lt;P&gt;Leo&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2024 18:43:22 GMT</pubDate>
    <dc:creator>lnog</dc:creator>
    <dc:date>2024-08-19T18:43:22Z</dc:date>
    <item>
      <title>GENERATIVE AI HUB SDK - Python Error</title>
      <link>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13794888#M384</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Looking to deploy a simple model using generative-ai-hub-sdk (using python 3.12) and after setup, I'm finding the following error executing the following script from console (jupyter notebook):&amp;nbsp;&lt;/P&gt;&lt;P&gt;from gen_ai_hub.proxy.langchain.init_models import init_llm&lt;/P&gt;&lt;P&gt;prompt = """Translate to danish: Guten Morgen"""&lt;/P&gt;&lt;P&gt;llm = init_llm('gpt-35-turbo', temperature=0., max_tokens=256)&lt;BR /&gt;llm.invoke(prompt).content&lt;/P&gt;&lt;P&gt;-------------------------------------------------------&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;ValidationError&lt;/SPAN&gt;&lt;SPAN class=""&gt;: 1 validation error for ChatOpenAI&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;__root__&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;Parameters {'top_p'} should be specified explicitly. Instead they were passed in as part of `model_kwargs` parameter. (type=value_error)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 15:07:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13794888#M384</guid>
      <dc:creator>lnog</dc:creator>
      <dc:date>2024-08-14T15:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: GENERATIVE AI HUB SDK - Python Error</title>
      <link>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13796001#M385</link>
      <description>&lt;P&gt;Hi! Since apparently you want to use the Langchain API, the `init_llm` function is likely a wrapper around the `ChatOpenAI` class, which is used to interact with OpenAI. Let me know how this goes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from gen_ai_hub.proxy.langchain.openai import ChatOpenAI
from gen_ai_hub.proxy.core.proxy_clients import get_proxy_client
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate

# Initialize proxy client
proxy_client = get_proxy_client('gen-ai-hub')

# Set up the chat model
chat_llm = ChatOpenAI(proxy_model_name='gpt-35-turbo', proxy_client=proxy_client)

# Define the prompt
prompt_template = PromptTemplate(input_variables=["text"], template="Translate to Danish: {text}")

# Create the LLMChain
chain = LLMChain(llm=chat_llm, prompt=prompt_template)

# Run the chain with the input text
response = chain.run("Guten Morgen")

# Print the output
print(response)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 11:26:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13796001#M385</guid>
      <dc:creator>MarioDeFelipe</dc:creator>
      <dc:date>2024-08-15T11:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: GENERATIVE AI HUB SDK - Python Error</title>
      <link>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13796333#M386</link>
      <description>&lt;P&gt;Thanks Mario! It worked, but I got the following warnings:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_core/_api/deprecation.py:141: LangChainDeprecationWarning: The class `LLMChain` was deprecated in LangChain 0.1.17 and will be removed in 1.0. Use RunnableSequence, e.g., `prompt | llm` instead.&lt;BR /&gt;warn_deprecated(&lt;BR /&gt;/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain_core/_api/deprecation.py:141: LangChainDeprecationWarning: The method `Chain.run` was deprecated in langchain 0.1.0 and will be removed in 0.3.0. Use invoke instead.&lt;BR /&gt;warn_deprecated(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Leandro&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 15:10:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13796333#M386</guid>
      <dc:creator>lnog</dc:creator>
      <dc:date>2024-08-15T15:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: GENERATIVE AI HUB SDK - Python Error</title>
      <link>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13799763#M387</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1537943"&gt;@lnog&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so happy to see progress!&lt;/P&gt;&lt;P&gt;Could be the case that your Langchain library got an update, and I might have provided also old instructions, but first make sure you update LangChain Version.&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;pip install --upgrade langchain &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;Instead of using the deprecated&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;LLMChain&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;class, the warning suggests using&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;RunnableSequence&lt;/SPAN&gt;&lt;SPAN&gt;. 1. Then lets replace the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;LLMChain&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;usage with the suggested alternative.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;# Old deprecated usage&lt;/SPAN&gt; &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;chain &lt;SPAN class=""&gt;=&lt;/SPAN&gt; LLMChain&lt;SPAN class=""&gt;(&lt;/SPAN&gt;prompt&lt;SPAN class=""&gt;=&lt;/SPAN&gt;prompt&lt;SPAN class=""&gt;,&lt;/SPAN&gt; llm&lt;SPAN class=""&gt;=&lt;/SPAN&gt;llm&lt;SPAN class=""&gt;)&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;# New recommended usage&lt;/SPAN&gt; &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;chain &lt;SPAN class=""&gt;=&lt;/SPAN&gt; prompt &lt;SPAN class=""&gt;|&lt;/SPAN&gt; llm &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;2. Instead of using the deprecated&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;Chain.run&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;method, the warning recommends using&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;invoke&lt;/U&gt;&lt;SPAN&gt;. &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;# Old deprecated usage&lt;/SPAN&gt; &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;output &lt;SPAN class=""&gt;=&lt;/SPAN&gt; chain&lt;SPAN class=""&gt;.&lt;/SPAN&gt;run&lt;SPAN class=""&gt;(&lt;/SPAN&gt;input_data&lt;SPAN class=""&gt;)&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;# New recommended usage&lt;/SPAN&gt; &lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;output &lt;SPAN class=""&gt;=&lt;/SPAN&gt; chain&lt;SPAN class=""&gt;.&lt;/SPAN&gt;invoke&lt;SPAN class=""&gt;(&lt;/SPAN&gt;input_data&lt;SPAN class=""&gt;)&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Let me know how it goes&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 19 Aug 2024 17:58:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13799763#M387</guid>
      <dc:creator>MarioDeFelipe</dc:creator>
      <dc:date>2024-08-19T17:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: GENERATIVE AI HUB SDK - Python Error</title>
      <link>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13799815#M389</link>
      <description>&lt;P&gt;Thanks, Mario, it worked perfectly&lt;/P&gt;&lt;P&gt;Leo&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 18:43:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/artificial-intelligence-forum/generative-ai-hub-sdk-python-error/m-p/13799815#M389</guid>
      <dc:creator>lnog</dc:creator>
      <dc:date>2024-08-19T18:43:22Z</dc:date>
    </item>
  </channel>
</rss>

