| 
 | 1 | +<a id="camel.utils.langfuse"></a>  | 
 | 2 | + | 
 | 3 | +<a id="camel.utils.langfuse.configure_langfuse"></a>  | 
 | 4 | + | 
 | 5 | +## configure_langfuse  | 
 | 6 | + | 
 | 7 | +```python  | 
 | 8 | +def configure_langfuse(  | 
 | 9 | +    public_key: Optional[str] = None,  | 
 | 10 | +    secret_key: Optional[str] = None,  | 
 | 11 | +    host: Optional[str] = None,  | 
 | 12 | +    debug: Optional[bool] = None,  | 
 | 13 | +    enabled: Optional[bool] = None  | 
 | 14 | +):  | 
 | 15 | +```  | 
 | 16 | + | 
 | 17 | +Configure Langfuse for CAMEL models.  | 
 | 18 | + | 
 | 19 | +**Parameters:**  | 
 | 20 | + | 
 | 21 | +- **public_key** (Optional[str]): Langfuse public key. Can be set via LANGFUSE_PUBLIC_KEY. (default: :obj:`None`)  | 
 | 22 | +- **secret_key** (Optional[str]): Langfuse secret key. Can be set via LANGFUSE_SECRET_KEY. (default: :obj:`None`)  | 
 | 23 | +- **host** (Optional[str]): Langfuse host URL. Can be set via LANGFUSE_HOST. (default: :obj:`https://cloud.langfuse.com`)  | 
 | 24 | +- **debug** (Optional[bool]): Enable debug mode. Can be set via LANGFUSE_DEBUG. (default: :obj:`None`)  | 
 | 25 | +- **enabled** (Optional[bool]): Enable/disable tracing. Can be set via LANGFUSE_ENABLED. (default: :obj:`None`)  | 
 | 26 | +- **Note**: This function configures the native langfuse_context which works with @observe() decorators. Set enabled=False to disable all tracing.  | 
 | 27 | + | 
 | 28 | +<a id="camel.utils.langfuse.is_langfuse_available"></a>  | 
 | 29 | + | 
 | 30 | +## is_langfuse_available  | 
 | 31 | + | 
 | 32 | +```python  | 
 | 33 | +def is_langfuse_available():  | 
 | 34 | +```  | 
 | 35 | + | 
 | 36 | +Check if Langfuse is configured.  | 
 | 37 | + | 
 | 38 | +<a id="camel.utils.langfuse.set_current_agent_session_id"></a>  | 
 | 39 | + | 
 | 40 | +## set_current_agent_session_id  | 
 | 41 | + | 
 | 42 | +```python  | 
 | 43 | +def set_current_agent_session_id(session_id: str):  | 
 | 44 | +```  | 
 | 45 | + | 
 | 46 | +Set the session ID for the current agent in thread-local storage.  | 
 | 47 | + | 
 | 48 | +**Parameters:**  | 
 | 49 | + | 
 | 50 | +- **session_id** (str): The session ID to set for the current agent.  | 
 | 51 | + | 
 | 52 | +<a id="camel.utils.langfuse.get_current_agent_session_id"></a>  | 
 | 53 | + | 
 | 54 | +## get_current_agent_session_id  | 
 | 55 | + | 
 | 56 | +```python  | 
 | 57 | +def get_current_agent_session_id():  | 
 | 58 | +```  | 
 | 59 | + | 
 | 60 | +**Returns:**  | 
 | 61 | + | 
 | 62 | +  Optional[str]: The session ID for the current agent.  | 
 | 63 | + | 
 | 64 | +<a id="camel.utils.langfuse.update_langfuse_trace"></a>  | 
 | 65 | + | 
 | 66 | +## update_langfuse_trace  | 
 | 67 | + | 
 | 68 | +```python  | 
 | 69 | +def update_langfuse_trace(  | 
 | 70 | +    session_id: Optional[str] = None,  | 
 | 71 | +    user_id: Optional[str] = None,  | 
 | 72 | +    metadata: Optional[Dict[str, Any]] = None,  | 
 | 73 | +    tags: Optional[List[str]] = None  | 
 | 74 | +):  | 
 | 75 | +```  | 
 | 76 | + | 
 | 77 | +Update the current Langfuse trace with session ID and metadata.  | 
 | 78 | + | 
 | 79 | +**Parameters:**  | 
 | 80 | + | 
 | 81 | +- **session_id** (Optional[str]): Optional session ID to use. If :obj:`None` uses the current agent's session ID. (default: :obj:`None`)  | 
 | 82 | +- **user_id** (Optional[str]): Optional user ID for the trace. (default: :obj:`None`)  | 
 | 83 | +- **metadata** (Optional[Dict[str, Any]]): Optional metadata dictionary. (default: :obj:`None`)  | 
 | 84 | +- **tags** (Optional[List[str]]): Optional list of tags. (default: :obj:`None`)  | 
 | 85 | + | 
 | 86 | +**Returns:**  | 
 | 87 | + | 
 | 88 | +  bool: True if update was successful, False otherwise.  | 
 | 89 | + | 
 | 90 | +<a id="camel.utils.langfuse.update_current_observation"></a>  | 
 | 91 | + | 
 | 92 | +## update_current_observation  | 
 | 93 | + | 
 | 94 | +```python  | 
 | 95 | +def update_current_observation(  | 
 | 96 | +    input: Optional[Dict[str, Any]] = None,  | 
 | 97 | +    output: Optional[Dict[str, Any]] = None,  | 
 | 98 | +    model: Optional[str] = None,  | 
 | 99 | +    model_parameters: Optional[Dict[str, Any]] = None,  | 
 | 100 | +    usage_details: Optional[Dict[str, Any]] = None,  | 
 | 101 | +    **kwargs  | 
 | 102 | +):  | 
 | 103 | +```  | 
 | 104 | + | 
 | 105 | +Update the current Langfuse observation with input, output,  | 
 | 106 | +model, model_parameters, and usage_details.  | 
 | 107 | + | 
 | 108 | +**Parameters:**  | 
 | 109 | + | 
 | 110 | +- **input** (Optional[Dict[str, Any]]): Optional input dictionary. (default: :obj:`None`)  | 
 | 111 | +- **output** (Optional[Dict[str, Any]]): Optional output dictionary. (default: :obj:`None`)  | 
 | 112 | +- **model** (Optional[str]): Optional model name. (default: :obj:`None`)  | 
 | 113 | +- **model_parameters** (Optional[Dict[str, Any]]): Optional model parameters dictionary. (default: :obj:`None`)  | 
 | 114 | +- **usage_details** (Optional[Dict[str, Any]]): Optional usage details dictionary. (default: :obj:`None`)  | 
 | 115 | + | 
 | 116 | +**Returns:**  | 
 | 117 | + | 
 | 118 | +  None  | 
 | 119 | + | 
 | 120 | +<a id="camel.utils.langfuse.get_langfuse_status"></a>  | 
 | 121 | + | 
 | 122 | +## get_langfuse_status  | 
 | 123 | + | 
 | 124 | +```python  | 
 | 125 | +def get_langfuse_status():  | 
 | 126 | +```  | 
 | 127 | + | 
 | 128 | +**Returns:**  | 
 | 129 | + | 
 | 130 | +  Dict[str, Any]: Status information including configuration state.  | 
 | 131 | + | 
 | 132 | +<a id="camel.utils.langfuse.observe"></a>  | 
 | 133 | + | 
 | 134 | +## observe  | 
 | 135 | + | 
 | 136 | +```python  | 
 | 137 | +def observe(*args, **kwargs):  | 
 | 138 | +```  | 
0 commit comments