May 17, 2026, 11:40 PM
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
LANGCHAIN_TRACING_V2=True
|
||||
LANGCHAIN_ENDPOINT="https://eu.api.smith.langchain.com"
|
||||
LANGCHAIN_API_KEY="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"
|
||||
LANGCHAIN_PROJECT="pr-crushing-contingency-24"
|
||||
|
||||
|
||||
|
||||
import openai
|
||||
from langsmith.wrappers import wrap_openai
|
||||
from langsmith import traceable
|
||||
import os
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = "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"
|
||||
|
||||
|
||||
# Auto-trace LLM calls in-context
|
||||
client = wrap_openai(openai.Client())
|
||||
|
||||
@traceable # Auto-trace this function
|
||||
def pipeline(user_input: str):
|
||||
result = client.chat.completions.create(
|
||||
messages=[{"role": "user", "content": user_input}],
|
||||
model="gpt-3.5-turbo"
|
||||
)
|
||||
return result.choices[0].message.content
|
||||
|
||||
print(pipeline("Hello, world!"))
|
||||
# Out: Hello there! How can I assist you today?
|
||||
Reference in New Issue
Block a user