from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-05-01-preview"
)
normal_chain = (
ChatPromptTemplate.from_messages([("system", "write a tweet about {topic} in the style of Elon Musk") ])
| client
| StrOutputParser()
)
In this code, I am getting Expected type 'Runnable[Any, Other] | (Any) -> Other | (Iterator) -> Iterator[Other] | Mapping[str, Runnable[Any, Other] | (Any) -> Other | Any]', got 'AzureOpenAI' instead. How to make the client as Runnable? Is there any other way to do the same thing?
I tried all the available options from LangChain, but it is not working.
client = AzureOpenAI(
azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-05-01-preview"
)
completion = client.chat.completions.create(
model=finetuned_deployment,
messages=[
{
"role": "user",
"content": f"Write a tweet about {topic}"
}],
max_tokens=800,
temperature=0.7,
top_p=0.95,
)
completion.to_json()
This code snippet worked.