diff --git a/.github/workflows/documentation_cookbook_tests.yml b/.github/workflows/documentation_cookbook_tests.yml index 302a467c47..6da2f444f6 100644 --- a/.github/workflows/documentation_cookbook_tests.yml +++ b/.github/workflows/documentation_cookbook_tests.yml @@ -30,6 +30,7 @@ jobs: - apps/opik-documentation/documentation/docs/cookbook/openai.ipynb - apps/opik-documentation/documentation/docs/cookbook/litellm.ipynb - apps/opik-documentation/documentation/docs/cookbook/ragas.ipynb + - apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb env: NOTEBOOK_TO_TEST: ${{ matrix.notebooks }} steps: diff --git a/apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb b/apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb index 8e32a0ae98..99faa15e45 100644 --- a/apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb +++ b/apps/opik-documentation/documentation/docs/cookbook/dspy.ipynb @@ -37,9 +37,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "OPIK: Opik is already configured. You can check the settings by viewing the config file at /Users/jacquesverre/.opik.config\n" + ] + } + ], "source": [ "import opik\n", "\n", @@ -48,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -70,14 +78,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import dspy\n", "from opik.integrations.dspy.callback import OpikCallback\n", "\n", - "lm = dspy.LM('openai/gpt-4o-mini')\n", + "lm = dspy.LM(\"openai/gpt-4o-mini\")\n", "\n", "project_name = \"DSPY\"\n", "opik_callback = OpikCallback(project_name=project_name)\n", @@ -87,9 +95,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:langfuse:Langfuse client is disabled since no public_key was provided as a parameter or environment variable 'LANGFUSE_PUBLIC_KEY'. See our docs: https://langfuse.com/docs/sdk/python/low-level-sdk#initialize-client\n", + "OPIK: Started logging traces to the \"DSPY\" project at https://www.comet.com/opik/jacques-comet/redirect/projects?name=DSPY.\n" + ] + }, + { + "data": { + "text/plain": [ + "Prediction(\n", + " reasoning='The meaning of life is a philosophical question that has been contemplated by humans for centuries. Different cultures, religions, and individuals have proposed various interpretations. Some suggest that the meaning of life is to seek happiness, fulfillment, and personal growth, while others believe it is about serving a higher purpose or contributing to the well-being of others. Ultimately, the meaning of life may vary from person to person, shaped by personal experiences, beliefs, and values.',\n", + " answer=\"The meaning of life is subjective and can vary greatly among individuals. It may involve seeking happiness, personal growth, and contributing to the well-being of others, or fulfilling a higher purpose, depending on one's beliefs and experiences.\"\n", + ")" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "cot = dspy.ChainOfThought(\"question -> answer\")\n", "cot(question=\"What is the meaning of life?\")" @@ -107,7 +137,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "py312_llm_eval", "language": "python", "name": "python3" }, @@ -121,7 +151,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.12.4" } }, "nbformat": 4, diff --git a/apps/opik-documentation/documentation/docs/tracing/integrations/dspy.md b/apps/opik-documentation/documentation/docs/tracing/integrations/dspy.md index bc853d35cb..385c116927 100644 --- a/apps/opik-documentation/documentation/docs/tracing/integrations/dspy.md +++ b/apps/opik-documentation/documentation/docs/tracing/integrations/dspy.md @@ -9,6 +9,13 @@ description: Describes how to track DSPy calls using Opik Opik integrates with DSPy to log traces for all DSPy calls. +