BerriAI / litellm

Python SDK, Proxy Server (LLM Gateway) to call 100+ LLM APIs in OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]
https://docs.litellm.ai/docs/
Other
13.94k stars 1.64k forks source link

[Bug]: Team/Key Based Logging #5907

Closed langgg0511 closed 1 month ago

langgg0511 commented 1 month ago

What happened?

The first team can write to Langfuse, while the second team has no records of writing to Langfuse.

general_settings:
  master_key: "sk-xxx"
  alerting: ["webhook"]

litellm_settings:
  database_url: "postgresql://postgres:difyai123456@localhost:5432/litellm"
  store_model_in_db: true

  cache: True
  cache_params:
    type: redis
    namespace: "litellm_caching"
    host: "localhost"
    port: "6379"
    ttl: 600

  num_retries: 0
  allowed_fails: 10 # cooldown model if it fails > 1 call in a minute.
  cooldown_time: 30 # how long to cooldown model if fails/min > allowed_fails

  fallbacks:
    - claude-3-haiku: ["azure/gpt-4o-mini"]

  redact_user_api_key_info: true

  default_team_settings:
    - team_id: "09ae376d-f6c8-42cd-88be-59717135684d" # team 1
      success_callbacks: ["langfuse"]
      langfuse_public_key: "pk-lf-1"
      langfuse_secret: "sk-lf-1"
      langfuse_host: ""

    - team_id: "e5db79db-d623-4a5b-afd5-162be56074df" # team2
      success_callback: ["langfuse"]
      langfuse_public_key: "pk-lf-2"
      langfuse_secret: "sk-lf-2"
      langfuse_host: ""

router_settings:
  model_group_alias:
    claude-3-haiku: "anthropic.claude-3-haiku-20240307-v1:0"
    claude-3-sonnet: "anthropic.claude-3-sonnet-20240229-v1:0"
    claude-3-5-sonnet: "anthropic.claude-3-5-sonnet-20240620-v1:0"

Relevant log output

No response

Twitter / LinkedIn details

No response

krrishdholakia commented 1 month ago

What version is this on? @langgg0511

langgg0511 commented 1 month ago

@krrishdholakia v1.48.1

krrishdholakia commented 1 month ago

Hi @langgg0511 i just ran this on latest, and i can't repro this.

Here's a video of me creating 2 keys for different teams, and it working as expected - https://drive.google.com/file/d/1FtEZl7op2wMjkYX-zYH-m6ro2zfbxO__/view?usp=sharing.

while the second team has no records of writing to Langfuse

This was an issue we resolved a few versions ago. It had to do with the langfuse client not being re-initialized.

If you're running a fork, check this line - https://github.com/BerriAI/litellm/blob/9fb1ee229464e486ebb3befdbb512b823e90f315/litellm/litellm_core_utils/litellm_logging.py#L1010

To confirm the langfuse credentials are being passed.

They are set here - https://github.com/BerriAI/litellm/blob/9fb1ee229464e486ebb3befdbb512b823e90f315/litellm/proxy/litellm_pre_call_utils.py#L359

You can also confirm the value of data passed contains {'success_callback': ['langfuse'], 'langfuse_public_key': 'pk-lf-..

krrishdholakia commented 1 month ago

closing as unable to repro