Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: When an exception is thrown after setting langfuse_context.update_current_trace, the values set in update_current_trace do not affect #2093

Open
DanrForetellix opened this issue May 17, 2024 · 1 comment
Labels

Comments

@DanrForetellix
Copy link

DanrForetellix commented May 17, 2024

Describe the bug

When an exception is thrown after setting langfuse_context.update_current_trace, the values set in update_current_trace do not affect

To reproduce

from langfuse.decorators import observe, langfuse_context
from langfuse.openai import OpenAI

client = OpenAI()
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Who is Obama"},
]

@observe()
def get_openai_response():
    num = 0
    response = client.chat.completions.create(
        model="gpt-3.5-turbo",
        messages=messages,
    )
    raise Exception("Some exception")

@observe()
def main():
    langfuse_context.update_current_trace(
        name="my_trace_name",
        metadata={"value": "some_value"},
    )
    get_openai_response()

main()

SDK and container versions

No response

Additional information

No response

Are you interested to contribute a fix for this bug?

No

@marcklingen
Copy link
Member

thanks for reporting!

@marcklingen marcklingen changed the title bug: bug: When an exception is thrown after setting langfuse_context.update_current_trace, the values set in update_current_trace do not affect May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants