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

feat(ui): allow filtering for null values (trace.name) #1198

Open
reza-mohideen opened this issue Feb 18, 2024 · 1 comment · May be fixed by #1245
Open

feat(ui): allow filtering for null values (trace.name) #1198

reza-mohideen opened this issue Feb 18, 2024 · 1 comment · May be fixed by #1245
Labels

Comments

@reza-mohideen
Copy link

reza-mohideen commented Feb 18, 2024

Describe the bug

In my trace dashboard, I am seeing a trace name show up as "Unknown", however, if I try to filter by "Unknown" on the individual trace page "Unknown" is not an option. Wondering why this is. Also, would be nice to be able to click on the number in the dashboard and it automatically apply the "name" filter so that I can dig in quicker and easily understand how that number came to be.

Screenshot 2024-02-18 at 7 28 12 AM Screenshot 2024-02-18 at 7 28 46 AM

To reproduce

from langchain_openai import AzureChatOpenAI
from langfuse.callback import CallbackHandler
from langchain.prompts import PromptTemplate
from langchain.prompts.chat import (
    ChatPromptTemplate,
    SystemMessagePromptTemplate,
    AIMessagePromptTemplate,
    HumanMessagePromptTemplate,
)

llm = AzureChatOpenAI(
        azure_endpoint=os.environ.get("AZURE_OPENAI_API_BASE"),
        azure_deployment="gpt35-turbo",
        openai_api_version="2023-03-15-preview",
        openai_api_key=os.environ.get("AZURE_OPENAI_API_KEY"),
    )

class OpenAIRequest(BaseModel):
    system_message: str = "You are a helpful assistant"
    query: str
    temperature: float = 0
    model_name: CHAT_MODELS = CHAT_MODELS.gpt35_turbo
    output_parser: Optional[Literal["list", "object"]] = None
    object_schema: Optional[dict] = (
        None  # Example of how to setup pydantic model (MUST NAME CLASS OutputClassGPT): https://python.langchain.com/docs/modules/model_io/output_parsers/pydantic
    )
    source: str
    user: str = None
    project_name: str = None # will be used for tracing in langfuse
    metadata: Optional[dict] = None
    version: Optional[str] = None

@llm_app.post("/generate/chat")
def generate_chat(request: OpenAIRequest):

system_message_prompt = SystemMessagePromptTemplate.from_template(
            "you are a helpful assistant"
        )
prompt = PromptTemplate(
                template=request.prompt,
                input_variables=[],
            )
human_message_prompt = HumanMessagePromptTemplate(prompt=prompt)
chat_prompt = ChatPromptTemplate.from_messages(
            [system_message_prompt, human_message_prompt]
        )

formatted_prompt = chat_prompt.format_prompt().to_messages()

trace = langfuse.trace(
name=request.project_name,
user_id=request.user,
tags=[request.source],
metadata=request.metadata if request.metadata else {},
version=request.version if request.version else "1",
input=formatted_prompt,
)
langfuse_handler = trace.get_langchain_handler()
resp = chatgpt.invoke(formatted_prompt, config={"callbacks": [langfuse_handler]})
result = resp.content
trace.update(output=result)

Additional information

No response

@marcklingen
Copy link
Member

Hi @reza-mohideen,

Unknown is basically the null value if no trace name was provided:

name: item.traceName ? (item.traceName as string) : "Unknown",
value: item.countTraceId as number,

I think it makes sense to make this more clear, is [no-trace-name] or null more intuitive than Unknown?

Being able to filter for trace.name=null is a great feature request, I'll update this issue accordingly.

@marcklingen marcklingen changed the title bug: "Unknown" Trace name in Dashboard but not present as trace name filter feat(ui): allow filtering for null values (trace.name) Feb 21, 2024
@khareyash05 khareyash05 linked a pull request Feb 23, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants