Skip to content

Commit

Permalink
[Fix]: Typo GEN_AI_RESPONSE_IMAGE_ in SemanticConvetion (openlit#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
CherishCai authored Jun 19, 2024
1 parent 5d2d205 commit c260fdd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
6 changes: 3 additions & 3 deletions docs/latest/features/tracing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ These attributes detail the specifics of requests sent to LLMs, including config
| `gen_ai.request.fine_tune_batch_size` | int | Batch size used in the finetuning process. | `16` |
| `gen_ai.request.validation_file` | string | Location or type of validation file used in the training process. | `val_data.json` |
| `gen_ai.request.training_file` | string | Location or type of training file used for the LLM. | `train_data.json` |
| `gen_ai.request.image_size` | string | Size specifications for the generated image. | `1024x768` |
| `gen_ai.request.image_quality` | int | Quality parameter for the generated image, usually a percentage. | `90` |
| `gen_ai.request.image_style` | string | Style or theme of the generated image. | `van_gogh` |

#### Response Attributes

Expand All @@ -193,9 +196,6 @@ Attributes in this category help trace and understand responses from LLMs, encap
| `gen_ai.response.id` | string | The unique identifier for the response. | `resp-456` |
| `gen_ai.response.finish_reasons` | string | Reasons the model stopped generating tokens. | `stop` |
| `gen_ai.response.image` | string | The image content generated by the LLM. | `<image URL or base64 string>` |
| `gen_ai.response.image_size` | string | Size specifications for the generated image. | `1024x768` |
| `gen_ai.response.image_quality` | int | Quality parameter for the generated image, usually a percentage. | `90` |
| `gen_ai.response.image_style` | string | Style or theme of the generated image. | `van_gogh` |

#### Usage Attributes

Expand Down
4 changes: 2 additions & 2 deletions sdk/python/src/openlit/instrumentation/bedrock/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def handle_image(span, model, request_body, response_body):
quality = request_body.get("imageGenerationConfig", {}).get("quality", "standard")
n = request_body.get("imageGenerationConfig", {}).get("numberOfImages", 1)

span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_SIZE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
size)
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_QUALITY,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
quality)
# Calculate cost of the operation
cost = n * get_image_model_cost(model,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,11 @@ async def wrapper(wrapped, instance, args, kwargs):
application_name)
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
"azure_" + kwargs.get("model", "dall-e-3"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_SIZE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_QUALITY,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
kwargs.get("quality", "standard"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_STYLE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_STYLE,
kwargs.get("style", "vivid"))
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_REVISED_PROMPT,
items.revised_prompt if response.revised_prompt else "")
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/src/openlit/instrumentation/openai/async_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,11 @@ async def wrapper(wrapped, instance, args, kwargs):
application_name)
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
kwargs.get("model", "dall-e-2"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_SIZE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_QUALITY,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
kwargs.get("quality", "standard"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_STYLE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_STYLE,
kwargs.get("style", "vivid"))
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_REVISED_PROMPT,
items.revised_prompt if items.revised_prompt else "")
Expand Down Expand Up @@ -724,9 +724,9 @@ async def wrapper(wrapped, instance, args, kwargs):
kwargs.get("model", "dall-e-2"))
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_SIZE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_QUALITY,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
"standard")
if trace_content:
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_PROMPT,
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/src/openlit/instrumentation/openai/azure_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,11 @@ def wrapper(wrapped, instance, args, kwargs):
application_name)
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
"azure_" + kwargs.get("model", "dall-e-3"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_SIZE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_QUALITY,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
kwargs.get("quality", "standard"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_STYLE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_STYLE,
kwargs.get("style", "vivid"))
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_REVISED_PROMPT,
items.revised_prompt if response.revised_prompt else "")
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/src/openlit/instrumentation/openai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,11 @@ def wrapper(wrapped, instance, args, kwargs):
application_name)
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_MODEL,
kwargs.get("model", "dall-e-2"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_SIZE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_QUALITY,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
kwargs.get("quality", "standard"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_STYLE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_STYLE,
kwargs.get("style", "vivid"))
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_REVISED_PROMPT,
items.revised_prompt if items.revised_prompt else "")
Expand Down Expand Up @@ -739,9 +739,9 @@ def wrapper(wrapped, instance, args, kwargs):
kwargs.get("model", "dall-e-2"))
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_USER,
kwargs.get("user", ""))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_SIZE,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_SIZE,
kwargs.get("size", "1024x1024"))
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_IMAGE_QUALITY,
span.set_attribute(SemanticConvetion.GEN_AI_REQUEST_IMAGE_QUALITY,
"standard")
if trace_content:
span.set_attribute(SemanticConvetion.GEN_AI_CONTENT_PROMPT,
Expand Down
7 changes: 4 additions & 3 deletions sdk/python/src/openlit/semcov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class SemanticConvetion:
GEN_AI_REQUEST_VALIDATION_FILE = "gen_ai.request.validation_file"
GEN_AI_REQUEST_TRAINING_FILE = "gen_ai.request.training_file"

GEN_AI_REQUEST_IMAGE_SIZE = "gen_ai.request.image_size"
GEN_AI_REQUEST_IMAGE_QUALITY = "gen_ai.request.image_quality"
GEN_AI_REQUEST_IMAGE_STYLE = "gen_ai.request.image_style"

# GenAI Usage
GEN_AI_USAGE_PROMPT_TOKENS = "gen_ai.usage.prompt_tokens"
GEN_AI_USAGE_COMPLETION_TOKENS = "gen_ai.usage.completion_tokens"
Expand All @@ -63,9 +67,6 @@ class SemanticConvetion:
GEN_AI_RESPONSE_ID = "gen_ai.response.id"
GEN_AI_RESPONSE_FINISH_REASON = "gen_ai.response.finish_reason"
GEN_AI_RESPONSE_IMAGE = "gen_ai.response.image" # Not used directly in code yet
GEN_AI_RESPONSE_IMAGE_SIZE = "gen_ai.request.image_size"
GEN_AI_RESPONSE_IMAGE_QUALITY = "gen_ai.request.image_quality"
GEN_AI_RESPONSE_IMAGE_STYLE = "gen_ai.request.image_style"

# GenAI Content
GEN_AI_CONTENT_PROMPT = "gen_ai.prompt"
Expand Down

0 comments on commit c260fdd

Please sign in to comment.