mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-05 09:25:14 +03:00
5.3 KiB
5.3 KiB
In [ ]:
!pip install openaiIn [3]:
import os
os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "2023-05-15"
os.environ["OPENAI_API_BASE"] = "..."
os.environ["OPENAI_API_KEY"] = "..."In [4]:
# Import Azure OpenAI
from langchain.llms import AzureOpenAIIn [5]:
# Create an instance of Azure OpenAI
# Replace the deployment name with your own
llm = AzureOpenAI(
deployment_name="td2",
model_name="text-davinci-002",
)In [6]:
# Run the LLM
llm("Tell me a joke")Out [6]:
"\n\nWhy couldn't the bicycle stand up by itself? Because it was...two tired!"
In [4]:
print(llm)[1mAzureOpenAI[0m
Params: {'deployment_name': 'text-davinci-002', 'model_name': 'text-davinci-002', 'temperature': 0.7, 'max_tokens': 256, 'top_p': 1, 'frequency_penalty': 0, 'presence_penalty': 0, 'n': 1, 'best_of': 1}
In [ ]: