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
-
Hi @georgelocw ,
I found the solution below suggested in this issue. Could you please try if it works?
Could you make sure that you are providing the correct url for your azure deployment? It should look like this "https://your-endpoint-base.openai.azure.com/openai/deployments/your-azure-model-name/completions?api-version=2022-12-01". And if you provide the right url, then it shouldn't try to stream.
0 -
Thank raksina.samasiri.
My original path : https://hkust.azure-api.net
I tried a new one: https://hkust.azure-api.net/openai/deployments/gpt-35-turbo/completions?api-version=2024-02-01
Both give the same error code.
But I can run the first part of the code in https://developers.lseg.com/en/article-catalog/article/bond-copilot--unleashing-rd-lib-search-api-with-ai-llm-langchain
By modification of the original code from
from langchain.chat_models import ChatOpenAI
llm = ChatOpenAI(temperature=0, model_name='gpt-3.5-turbo', openai_api_key='YOUR OPENAI API KEY')
to below code
from langchain.chat_models import AzureChatOpenAI
llm = AzureChatOpenAI(temperature=0,azure_deployment="gpt-35-turbo",api_version="2024-02-01",azure_endpoint="https://hkust.azure-api.net", api_key="xxxxxxx")
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛