Last active
October 26, 2023 07:27
-
-
Save vrushankportkey/49c27de71bc9afd50418cc0d5b223ba9 to your computer and use it in GitHub Desktop.
Langchain <> Anyscale <> Portey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from langchain.chat_models import ChatOpenAI | |
from langchain.schema import HumanMessage, SystemMessage | |
os.environ["OPENAI_API_BASE"]="https://api.portkey.ai/v1/proxy" | |
anyscale_key = "..." | |
headers = { | |
"x-portkey-api-key": "...", | |
"x-portkey-mode": "proxy anyscale", | |
} | |
chat = ChatOpenAI(openai_api_key=anyscale_key, headers=headers, model="meta-llama/Llama-2-7b-chat-hf") | |
messages = [ | |
SystemMessage(content="You are a helpful assistant"), | |
HumanMessage(content="Who is Doraemon?") | |
] | |
chat(messages) | |
print(chat) |
Also, why do we need to talk about trace_id here?
yeah 🤔 removing trace id. it's not needed.
we can't use Portkey's langchain integration here because there we are setting the OpenAI API Base upstream in the Portkey module and it can't be changed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can we do it like this?