88from langchain_openai import ChatOpenAI , OpenAIEmbeddings
99
1010from langtrace_python_sdk import langtrace
11- from langtrace_python_sdk .utils .with_root_span import (
12- with_langtrace_root_span ,
13- with_additional_attributes ,
14- )
11+ from langtrace_python_sdk .utils .with_root_span import with_langtrace_root_span
12+ from openai import OpenAI
1513
1614_ = load_dotenv (find_dotenv ())
1715
18- langtrace .init ()
16+ langtrace .init (
17+ write_spans_to_console = False ,
18+ disable_tracing_for_functions = {"langchain" : ["RunnableSequence.invoke" ]},
19+ )
1920
2021
2122def api_call_1 ():
@@ -29,7 +30,8 @@ def api_call_1():
2930 output_parser = StrOutputParser ()
3031 chain = prompt | llm | output_parser
3132 res = chain .invoke ({"input" : "how can langsmith help with testing?" })
32- print (res )
33+ # print(res)
34+ return res
3335
3436
3537def api_call_2 ():
@@ -43,13 +45,26 @@ def api_call_2():
4345 output_parser = StrOutputParser ()
4446 chain = prompt | llm | output_parser
4547 res = chain .invoke ({"input" : "how can langsmith help with testing?" })
46- print (res )
48+ # print(res)
49+ return res
4750
4851
4952@with_langtrace_root_span ()
5053def basic_app ():
5154 api_call_1 ()
52- api_call_2 ()
55+ # api_call_2()
56+ client = OpenAI ()
57+ response = client .chat .completions .create (
58+ model = "gpt-4" ,
59+ messages = [
60+ {"role" : "system" , "content" : "Talk like a pirate" },
61+ {"role" : "user" , "content" : "Tell me a story in 3 sentences or less." },
62+ ],
63+ # stream=True,
64+ stream = False ,
65+ )
66+
67+ return response
5368
5469
5570@with_langtrace_root_span ()
0 commit comments