-
Notifications
You must be signed in to change notification settings - Fork 873
Description
Which component is this bug for?
LlamaIndex Instrumentation
📜 Description
The set_llm_chat_request_model_attributes function in LLama Index fails to access the correct fields for the model and temperature attributes when using StructuredLLM.
Specifically, it tries to access model_dict.model instead of model_dict.llm.model. The same issue occurs for the temperature field.
It is very likely that this issue also occurs with completions calls as well.
Below is the error log observed:
Invalid type NoneType for attribute 'gen_ai.request.model' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types👟 Reproduction steps
- Use a StructuredLLM instance.
- Run
achatfunction - Observe the error log indicating invalid NoneType for gen_ai.request.model
class Invoice(BaseModel):
"""A representation of information from an invoice."""
invoice_id: str = Field(
description="A unique identifier for this invoice, often a number"
)
date: datetime = Field(description="The date this invoice was created")
line_items: list[LineItem] = Field(
description="A list of all the items in this invoice"
)
from llama_index.llms.openai import OpenAI
llm = OpenAI(model="gpt-4o")
sllm = llm.as_structured_llm(Invoice)
messages = [
ChatMessage(role="system", content="dummy prompt"),
ChatMessage(role="user", content="dummy prompt"),
]
response = sllm.achat(messages)👍 Expected behavior
The set_llm_chat_request_model_attributes function should correctly access the model and temperature fields from model_dict.llm.model and model_dict.llm.temperature (or equivalent), ensuring proper attribute values are set.
👎 Actual Behavior with Screenshots
The function incorrectly accesses model_dict.model and model_dict.temperature, resulting in a NoneType error for the model and temperature fields.
🤖 Python Version
3.12
📃 Provide any additional context for the Bug.
No response
👀 Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
None