Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Cookbook: Example for Fetching Scores from Langfuse #857

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
1,320 changes: 1,320 additions & 0 deletions cookbook/example_usage_of_fetch_scores.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pages/docs/integrations/dspy.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@ print(f"Retrieved Contexts (truncated): {[c[:200] + '...' for c in pred.context]
Question: Who conducts the draft in which Marc-Andre Fleury was drafted to the Vegas Golden Knights for the 2017-18 season????????
Predicted Answer: National Hockey League
Retrieved Contexts (truncated): ['2017–18 Pittsburgh Penguins season | The 2017–18 Pittsburgh Penguins season will be the 51st season for the National Hockey League ice hockey team that was established on June 5, 1967. They will enter...', 'Marc-André Fleury | Marc-André Fleury (born November 28, 1984) is a French-Canadian professional ice hockey goaltender playing for the Vegas Golden Knights of the National Hockey League (NHL). Drafted...', "2017 NHL Expansion Draft | The 2017 NHL Expansion Draft was an expansion draft conducted by the National Hockey League on June 18–20, 2017 to fill the roster of the league's expansion team for the 201..."]


Example query trace in Langfuse: https://cloud.langfuse.com/project/cloramnkj0002jz088vzn1ja4/traces/baf30bf5-0741-493c-aba3-2a66290d4d1d
4 changes: 2 additions & 2 deletions pages/docs/integrations/langchain/example-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ console.log(res.content)

Why did the bear wear a fur coat to the BBQ?
Because it was grizzly cold outside!


### `stream`

Expand Down Expand Up @@ -107,7 +107,7 @@ for await (const chunk of stream) {
light
!



## Explore the trace in Langfuse

Expand Down
10 changes: 5 additions & 5 deletions pages/docs/integrations/langchain/example-python-langgraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ for s in graph.stream({"messages": [HumanMessage(content = "What is Langfuse?")]
```

{'chatbot': {'messages': [AIMessage(content='Langfuse is a tool designed to help developers monitor and observe the performance of their Large Language Model (LLM) applications. It provides detailed insights into how these applications are functioning, allowing for better debugging, optimization, and overall management. Langfuse offers features such as tracking key metrics, visualizing data, and identifying potential issues in real-time, making it easier for developers to maintain and improve their LLM-based solutions.', response_metadata={'token_usage': {'completion_tokens': 86, 'prompt_tokens': 13, 'total_tokens': 99}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_400f27fa1f', 'finish_reason': 'stop', 'logprobs': None}, id='run-9a0c97cb-ccfe-463e-902c-5a5900b796b4-0', usage_metadata={'input_tokens': 13, 'output_tokens': 86, 'total_tokens': 99})]}}


### View traces in Langfuse

Expand Down Expand Up @@ -353,7 +353,7 @@ for s in graph_2.stream({"messages": [HumanMessage(content = "How does photosynt
----
{'supervisor': {'next': 'FINISH'}}
----



```python
Expand All @@ -370,7 +370,7 @@ for s in graph_2.stream({"messages": [HumanMessage(content = "What time is it?")
----
{'supervisor': {'next': 'FINISH'}}
----


### See traces in Langfuse

Expand Down Expand Up @@ -516,7 +516,7 @@ print(langchain_system_prompt)
```

You are a translator that translates every input text into Spanish.


Now we can use the new system prompt string to update our assistant.

Expand Down Expand Up @@ -566,7 +566,7 @@ for s in graph.stream({"messages": [HumanMessage(content = "What is Langfuse?")]
```

{'chatbot': {'messages': [AIMessage(content='¿Qué es Langfuse?', response_metadata={'token_usage': {'completion_tokens': 6, 'prompt_tokens': 30, 'total_tokens': 36}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_400f27fa1f', 'finish_reason': 'stop', 'logprobs': None}, id='run-1f419fe3-73e2-4413-aa6c-96560bbd09c8-0', usage_metadata={'input_tokens': 30, 'output_tokens': 6, 'total_tokens': 36})]}}


## Feedback

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ print(response)
```

He made home movies using a Super 8 camera.


Example trace: https://cloud.langfuse.com/project/cloramnkj0002jz088vzn1ja4/traces/d933c7cc-20bf-4db3-810d-bab1c8d9a2a1

Expand All @@ -90,7 +90,7 @@ print(response)
```

He made home movies using a Super 8 camera growing up.


Example trace: https://cloud.langfuse.com/project/cloramnkj0002jz088vzn1ja4/traces/4e285b8f-9789-4cf0-a8b4-45473ac420f1

Expand Down
4 changes: 2 additions & 2 deletions pages/docs/integrations/mirascope/example-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ print(response.content)
```

I recommend **"The House in the Cerulean Sea" by TJ Klune**. It's a heartwarming fantasy that follows Linus Baker, a caseworker for magical children, who is sent on a special assignment to a mysterious orphanage. There, he discovers unique and lovable characters and confronts themes of acceptance, found family, and the importance of love and kindness. The book combines whimsy, humor, and poignant moments, making it a delightful read for fantasy lovers.


[**Example trace**](https://cloud.langfuse.com/project/cloramnkj0002jz088vzn1ja4/traces/84bbb50e-aebc-424a-ae8a-e1012914d46b)

Expand Down Expand Up @@ -87,7 +87,7 @@ generate_facts(3)
Sure! Frogs can breathe through their skin, allowing them to absorb oxygen and release carbon dioxide directly into and out of their bloodstream. This process is known as cutaneous respiration.
Some species of frogs can absorb water through their skin, meaning they don't need to drink water with their mouths.
Frogs can breathe through their skin! This adaptation allows them to absorb oxygen directly from water, which is especially useful when they're submerged.


Head over to the Langfuse Traces table [in Langfuse Cloud](https://cloud.langfuse.com ) to see the entire chat history, token counts, cost, model, latencies and more

Expand Down
4 changes: 2 additions & 2 deletions pages/docs/integrations/mistral-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ stream_find_best_five_painter_from("Spain")
ó
.





Expand Down Expand Up @@ -500,7 +500,7 @@ await async_stream_find_best_five_musician_from("Spain")
ía
.





Expand Down
4 changes: 2 additions & 2 deletions pages/docs/integrations/ollama.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ print(response.choices[0].message.content)
```

A famous moment in history! When Neil Armstrong took his historic first steps on the moon, his first words were: "That's one small step for man, one giant leap for mankind." (Note: The word was actually "man", not "men" - it's often been reported as "one small step for men", but Armstrong himself said he meant to say "man")


### **Step 4:** See Traces in Langfuse

Expand Down Expand Up @@ -200,7 +200,7 @@ print(response.choices[0].message.content)
```

The most recently confirmed element is oganesson (Og), with symbol Og and atomic number 118. It was officially recognized by IUPAC (International Union of Pure and Applied Chemistry) in 2016, following the synthesis of several atoms at laboratories in Russia and Germany. The latest unofficially-recognized element is ununsextium (Uus), with atomic number 138. However, its synthesis is still under investigation, and IUPAC has yet to officially confirm its existence.


### Step 4: See Traces in Langfuse

Expand Down
6 changes: 3 additions & 3 deletions pages/docs/integrations/openai/python/structured-outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ print(result.content)
```

{"steps":[{"explanation":"We need to isolate the term with the variable, 8x. So, we start by subtracting 7 from both sides to remove the constant term on the left side.","output":"8x + 7 - 7 = -23 - 7"},{"explanation":"The +7 and -7 on the left side cancel each other out, leaving us with 8x. The right side simplifies to -30.","output":"8x = -30"},{"explanation":"To solve for x, divide both sides of the equation by 8, which is the coefficient of x.","output":"x = -30 / 8"},{"explanation":"Simplify the fraction -30/8 by finding the greatest common divisor, which is 2.","output":"x = -15 / 4"}],"final_answer":"x = -15/4"}



```python
Expand Down Expand Up @@ -178,7 +178,7 @@ print(final_answer)


x = -15/4


## Step 3: See your trace in Langfuse

Expand Down Expand Up @@ -229,7 +229,7 @@ print(result.final_answer)
[Step(explanation='To isolate the term with the variable on one side of the equation, start by subtracting 7 from both sides.', output='8x = -23 - 7'), Step(explanation='Combine like terms on the right side to simplify the equation.', output='8x = -30'), Step(explanation='Divide both sides by 8 to solve for x.', output='x = -30 / 8'), Step(explanation='Simplify the fraction by dividing both the numerator and the denominator by their greatest common divisor, which is 2.', output='x = -15 / 4')]
Final answer:
x = -15/4


## See your trace in Langfuse

Expand Down
4 changes: 2 additions & 2 deletions pages/docs/prompts/example-langchain.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ print(f"Prompt model configurations\nModel: {model}\nTemperature: {temperature}"
Prompt model configurations
Model: gpt-3.5-turbo-1106
Temperature: 0


### Create Langchain chain based on prompt

Expand Down Expand Up @@ -191,7 +191,7 @@ print(response.content)
- Transportation: Eco-friendly shuttle service

Overall, the wedding will be a beautiful blend of art and nature, with a focus on sustainability and creativity. The event will showcase the couple's love for each other and their shared passions, creating a memorable and unique experience for all in attendance.


## View Trace in Langfuse

Expand Down
Loading
Loading