Skip to content

Commit 354ab68

Browse files
committed
fix: docs that are based on notebooks
1 parent ab5ee2d commit 354ab68

File tree

5 files changed

+175
-93
lines changed

5 files changed

+175
-93
lines changed

cookbook/integration_haystack.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@
16731673
"- Through user feedback\n",
16741674
"- Model-based evaluation\n",
16751675
"- Through SDK/API\n",
1676-
"- Manually, in the Langfuise UI\n",
1676+
"- Using annotation in the Langfuse UI\n",
16771677
"\n",
16781678
"The example below walks through a simple way to score the chat generator's response via the Python SDK. It adds a score of 1 to the trace above with the comment \"Cordial and relevant\" because the model's response was very polite and factually correct. You can then sort these scores to identify low-quality output or to monitor the quality of responses."
16791679
]

cookbook/python_decorators.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@
509509
"source": [
510510
"### Scoring\n",
511511
"\n",
512-
"[Scores](https://langfuse.com/docs/scores/overview) are used to evaluate single observations or entire traces. You can create them manually in the Langfuse UI, run model-based evaluation or ingest via the SDK.\n",
512+
"[Scores](https://langfuse.com/docs/scores/overview) are used to evaluate single observations or entire traces. You can create them via our annotation workflow in the Langfuse UI, run model-based evaluation or ingest via the SDK.\n",
513513
"\n",
514514
"| Parameter | Type | Optional | Description\n",
515515
"| --- | --- | --- | ---\n",

cookbook/python_sdk_low_level.ipynb

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@
525525
"source": [
526526
"## Scores\n",
527527
"\n",
528-
"[Scores](https://langfuse.com/docs/scores/overview) are used to evaluate single executions/traces. They can created manually via the Langfuse UI or via the SDKs.\n",
528+
"[Scores](https://langfuse.com/docs/scores/overview) are used to evaluate single executions/traces. They can be created via Annotation in the Langfuse UI or via the SDKs.\n",
529529
"\n",
530530
"If the score relates to a specific step of the trace, specify the `observation_id`.\n",
531531
"\n",
@@ -704,6 +704,43 @@
704704
"langfuse.auth_check()"
705705
]
706706
},
707+
{
708+
"cell_type": "markdown",
709+
"metadata": {},
710+
"source": [
711+
"### Google Cloud Functions\n",
712+
"\n",
713+
"When using Langfuse in a Google Cloud Function or a Firebase Function, the underlying managed Python runtime has issues with threading whenever threads are spawned off the main scope and not inside the actual function scope. [See here](https://www.googlecloudcommunity.com/gc/Serverless/The-issue-with-pythons-s-threading-on-Google-Function/m-p/614384). Since Langfuse uses background threads to deliver the observability events, this will lead to incomplete traces.\n",
714+
"\n",
715+
"Make sure to initialize Langfuse always _inside_ the function body. If you want to reuse the created Langfuse clients in different modules, use lazy initialization of the Langfuse client to ensure the actual initialization occurs inside the function execution context.\n",
716+
"\n",
717+
"```python\n",
718+
"import functions_framework\n",
719+
"from langfuse import Langfuse\n",
720+
"\n",
721+
"\n",
722+
"# Lazy initialization of the Langfuse client to allow imports in other modules\n",
723+
"def get_langfuse():\n",
724+
" if not hasattr(get_langfuse, \"langfuse\"):\n",
725+
" get_langfuse.langfuse = Langfuse(debug=True)\n",
726+
"\n",
727+
" return get_langfuse.langfuse\n",
728+
"\n",
729+
"\n",
730+
"# Google Cloud Function\n",
731+
"@functions_framework.http\n",
732+
"def hello_world(request):\n",
733+
" langfuse = get_langfuse()\n",
734+
"\n",
735+
" response = \"Hello world!\"\n",
736+
" langfuse.trace(name=\"my-cloud-function\", output=response)\n",
737+
"\n",
738+
" langfuse.flush() # Ensure all events are sent before the function terminates\n",
739+
"\n",
740+
" return response\n",
741+
"```"
742+
]
743+
},
707744
{
708745
"cell_type": "markdown",
709746
"metadata": {

0 commit comments

Comments
 (0)