Please help to modify the below code to use AzureopenAI, thanks.

Original article: https://developers.lseg.com/en/article-catalog/article/bond-copilot--unleashing-rd-lib-search-api-with-ai-llm-langchain


original code using openAI:

df = bond_copilot("list all the active green bonds")

# Importing necessary modules to facilitate data analysis using natural language processing.

from langchain.llms import OpenAI

from langchain.agents import create_pandas_dataframe_agent,create_csv_agent

# Creating an agent that allows us to perform natural language queries on the dataset.

# The agent uses ChatGPT, OpenAI's language model to understand and process the queries.

bond_analytics = create_pandas_dataframe_agent(OpenAI(temperature=0, openai_api_key='YOUR OPENAI API KEY'), df, verbose=False)

#bond_analytics = create_csv_agent(OpenAI(temperature=0), "green_bond.csv", verbose=False)


My code

from langchain.llms import AzureOpenAI

from langchain_experimental.agent import create_panda_dataframe,create_csv_agent

llm1=AzureOpenAI(temperature=0,azure_deployment="gpt-35-turbo",api_version="2024-02-01",azure_endpoint="xxx",api_key="xxx")

bond_analytics = create_pandas_dataframe_agent(llm1,df,verbose=False)


Error code:

BadRequestError: Error code: 400 - {'message': "Streaming completion is not support yet, please remove 'stream' key value in the request payload."}

Answers