File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed
examples/azureopenai_example Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 1+ from examples .azureopenai_example .completion import chat_completion
2+ from langtrace_python_sdk import with_langtrace_root_span , langtrace
3+
4+ langtrace .init ()
5+
6+ class AzureOpenAIRunner :
7+ @with_langtrace_root_span ("AzureOpenAI" )
8+ def run (self ):
9+ chat_completion ()
Original file line number Diff line number Diff line change 1+ import os
2+ from langchain_openai import AzureChatOpenAI
3+
4+ from langtrace_python_sdk .utils .with_root_span import with_langtrace_root_span
5+
6+ model = AzureChatOpenAI (
7+ azure_endpoint = os .environ ['AZURE_OPENAI_ENDPOINT' ],
8+ azure_deployment = os .environ ['AZURE_OPENAI_DEPLOYMENT_NAME' ],
9+ openai_api_version = os .environ ['AZURE_OPENAI_API_VERSION' ],
10+ )
11+
12+ @with_langtrace_root_span ()
13+ def chat_completion ():
14+ messages = [
15+ (
16+ "system" ,
17+ "You are a helpful assistant that translates English to French. Translate the user sentence." ,
18+ ),
19+ ("human" , "I love programming." ),
20+ ]
21+ result = model .invoke (messages )
22+ print (result )
Original file line number Diff line number Diff line change 22
33ENABLED_EXAMPLES = {
44 "anthropic" : False ,
5+ "azureopenai" : True ,
56 "chroma" : False ,
67 "cohere" : False ,
78 "fastapi" : False ,
89 "langchain" : False ,
910 "llamaindex" : False ,
1011 "hiveagent" : False ,
11- "openai" : True ,
12+ "openai" : False ,
1213 "perplexity" : False ,
1314 "pinecone" : False ,
1415 "qdrant" : False ,
110111
111112 print (Fore .BLUE + "Running Mistral example" + Fore .RESET )
112113 MistralRunner ().run ()
114+
115+ if ENABLED_EXAMPLES ["azureopenai" ]:
116+ from examples .azureopenai_example import AzureOpenAIRunner
117+
118+ print (Fore .BLUE + "Running Azure OpenAI example" + Fore .RESET )
119+ AzureOpenAIRunner ().run ()
You can’t perform that action at this time.
0 commit comments