Skip to content

Commit f7d63e5

Browse files
authored
Merge pull request #34 from future-agi/feature/revamp
updated- observe, prompt sdk
2 parents 39fcaa4 + 77b2765 commit f7d63e5

14 files changed

Lines changed: 556 additions & 11 deletions

File tree

‎future-agi/products/dataset/how-to/manually-create-dataset.mdx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: "Manually Create a Dataset"
3+
---
4+
35
The manual dataset creation feature allows users to define a dataset structure from scratch, adding rows and columns according to specific requirements.
46

57
---

‎future-agi/products/experimentation/concept.mdx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
title: Concept
33
---
44

5-
`[demo video]`
6-
75
Experimentation is an evaluation-driven development approach to systematically select best prompt configuration and achieve consistent performance. It enables users to rapidly test, validate, and compare different prompt configurations against various evaluation criteria within a structured framework.
86

97
> A prompt configuration here includes not only the input text but also the model configuration and other parameters that influence the model's behaviour and output.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: "Components of Observability"
3+
---
4+
5+
Observability in LLM-based applications relies on a structured framework that captures execution details at different levels of granularity. Each request follows a well-defined path, where **individual operations are recorded, grouped into execution flows, and organized for broader analysis.** This structured approach enables teams to **track model performance, debug failures, and optimize system efficiency.**
6+
7+
---
8+
9+
### **Spans**
10+
A Span represents a single operation within an execution flow, recording input-output data, execution time, and errors. Each span provides insight into specific steps such as:
11+
12+
- LLM Calls – Capturing model invocation, prompt processing, and response generation.
13+
- Retrieval Operations – Logging queries made to external databases or indexes.
14+
- Tool Executions – Tracking API calls and function invocations.
15+
- Error Handling – Recording failures, timeouts, and system issues.
16+
17+
Spans provide fine-grained visibility into each operation, allowing teams to identify where delays, errors, or inefficiencies originate.
18+
19+
---
20+
21+
### **Traces**
22+
A Trace connects multiple spans to represent the full execution flow of a request. It provides a structured view of how different operations interact within an LLM-powered system. Traces help teams:
23+
24+
- Analyze dependencies between retrieval, inference, and tool execution.
25+
- Identify performance bottlenecks by measuring latency across spans.
26+
- Debug unexpected behaviors by tracing execution paths from input to output.
27+
28+
For instance, a trace for an AI-driven search system may include:
29+
1. A retrieval span fetching relevant documents.
30+
2. An LLM span generating a response.
31+
3. A tool execution span calling an external API.
32+
33+
By correlating these spans within a trace, teams can reconstruct the entire request flow, making it easier to analyze system behavior and optimize workflows.
34+
35+
---
36+
37+
### **3. Projects**
38+
A Project provides a structured way to manage multiple traces, ensuring observability is organized across different applications, use cases, or deployments. Projects allow teams to:
39+
40+
- Segment and categorize observability data for different LLM-powered applications.
41+
- Compare model versions to track improvements in accuracy and performance.
42+
- Filter and analyze execution trends across multiple traces.
43+
44+
For example, an organization might maintain separate projects for:
45+
- Customer Support AI – Handling traces related to automated support queries.
46+
- Content Generation AI – Managing traces for LLM-powered writing assistants.
47+
- Legal AI Assistant – Tracking execution flows for contract analysis tasks.
48+
49+
By structuring observability in this way, teams can effectively monitor, compare, and optimize LLM-powered applications at scale.
50+
51+
---
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: "Understanding Observability"
3+
---
4+
5+
As LLMs transition from experimentation to production, ensuring their reliability, fairness, and efficiency becomes critical. The Observe feature is designed to provide AI teams with real-time insights, evaluation metrics, and diagnostic tools to monitor and improve LLM-based applications.
6+
7+
This feature goes beyond simple monitoring, it enables teams to trace model behaviour, detect anomalies, measure AI performance, and diagnose issues such as hallucinations, inconsistencies, and inefficiencies.
8+
9+
By leveraging automated scoring, structured evaluation criteria, and historical trend analysis, Observe helps AI teams fine-tune LLM performance, debug failures, and optimize models for long-term reliability.
10+
11+
​
12+
## Features of Observe
13+
The Observe feature is built with five core objectives that help AI teams track, diagnose, and optimize LLM behaviour in production environments:
14+
15+
1. Real-Time Monitoring
16+
Track LLM-generated responses, system telemetry, and model behaviour in live applications.
17+
Visualise AI operations with structured trace logs and session analysis.
18+
​
19+
2. Ensuring Model Reliability
20+
Detect unexpected hallucinations, misinformation, or irrelevant outputs.
21+
Identify task completion failures and ambiguous AI responses.
22+
​
23+
3. Improving Model Accuracy & Alignment
24+
Apply predefined evaluation templates to measure coherence, accuracy, and response quality.
25+
Automate scoring based on performance benchmarks and structured criteria.
26+
​
27+
4. Accelerating Debugging & Problem-Solving
28+
Pinpoint issues by analysing traces, sessions, and response deviations.
29+
Use structured logs and failure patterns to diagnose and fix model inefficiencies.
30+
​
31+
5. Monitoring Bias & Fairness
32+
Evaluate AI responses for ethical risks, safety concerns, and compliance adherence.
33+
Apply bias-detection metrics to maintain responsible AI behaviour.
34+
​
35+
## Core Components of Observe
36+
**1. LLM Tracing & Debugging**
37+
38+
Observability starts with LLM Tracing, which captures every input-output interaction, system response, and processing time in an LLM-based application.
39+
40+
- **Trace Identification** – Assigns a unique trace ID to every AI response for tracking and debugging.
41+
- **Response Auditing** – Logs input queries, AI-generated responses, and execution times.
42+
- **Error Detection** – Highlights failed completions, latency issues, and incomplete outputs.
43+
> Use Case: An AI-powered chatbot generates a misleading response—the trace log helps pinpoint the issue and diagnose why it occurred.
44+
45+
​
46+
**2. Session-Based Observability**
47+
48+
LLM applications often involve multi-turn interactions, making it essential to group related traces into sessions.
49+
50+
- **Session IDs** – Cluster multiple interactions within a single conversation or task execution.
51+
- **Conversation Analysis** – Evaluate how AI performs across a sequence of exchanges.
52+
- **Performance Trends** – Track how AI evolves within a session, ensuring consistency.
53+
> Use Case: A virtual assistant handling customer queries must track response relevance over multiple turns to ensure coherent assistance.
54+
55+
​
56+
**3. Automated Evaluation & Scoring**
57+
58+
Observe provides structured evaluation criteria to score AI performance based on predefined metrics.
59+
60+
- **Evaluation Templates** – Predefined models for coherence, completeness, and user satisfaction.
61+
- **Scoring System** – Uses quantitative metrics to assess response effectiveness.
62+
- **Pass/Fail Flags** – Automatically detect responses that fall below a quality threshold.
63+
- **Real-Time Evaluations** – Apply automated scoring to AI-generated responses as they occur.
64+
- **Custom Criteria** – Define organization-specific evaluation metrics to tailor observability to unique use cases.
65+
> Use Case: A content generation model produces AI-written summaries. Observe automatically scores the summary’s accuracy, coherence, and relevance.
66+
67+
​
68+
**4. Historical Trend Analysis**
69+
70+
Observability is not just about real-time monitoring—it also involves tracking model behaviour over time.
71+
72+
- **Performance Trends** – Compare past vs. present AI behaviour to measure improvement.
73+
- **Cross-Model Comparisons** – Analyze different versions of an LLM to assess enhancements.
74+
- **Statistical Insights** – Apply standard deviation, percentiles, and response distributions to detect long-term anomalies.
75+
> Use Case: A team updates its legal AI assistant—historical data shows whether the new version improves or worsens accuracy.
76+
77+
​
78+
**5. Automated Issue Detection & Alerts**
79+
80+
To ensure AI systems remain functional, Observe enables automated issue detection and alerting.
81+
82+
- **Live Monitoring** – Observe token consumption, processing delays, and response failures in real time.
83+
- **Threshold-Based Alerts** – Notify users if error rates or latency exceed safe limits.
84+
- **Workflow Automation** – Automatically flag and log problematic interactions for further analysis.
85+
> Use Case: A customer service AI model starts generating unexpected responses—Observe triggers an alert, allowing the team to investigate immediately.
86+
87+
By providing a comprehensive observability framework, Observe empowers AI teams to build more reliable, fair, and high-performing LLM applications in production environments.
88+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: "Spans"
3+
---
4+
5+
Spans are the fundamental units of tracing in observability frameworks, providing structured, event-level data for monitoring, debugging, and performance analysis. A span represents a discrete operation executed within a system, capturing execution timing, hierarchical relationships, and metadata relevant to the operation’s context.
6+
7+
They are aggregated into traces, which collectively depict the flow of execution across various system components. This document provides an in-depth technical analysis of spans, their attributes, classifications, and their role in system observability.
8+
9+
---
10+
11+
## Structure of Spans
12+
13+
A span consists of multiple attributes that encapsulate its execution details. These attributes can be categorized into the following sections:
14+
15+
- **Identification and context** provide the span's unique ID, trace ID, and optional parent span ID, establishing hierarchical relationships. It may also include a project reference for system-wide organization.
16+
17+
- **Execution details** define the operation recorded, including a descriptive name, span type (e.g., function call, API request, database query), and input/output data. If an operation fails, error metadata captures failure details like error codes, messages, and stack traces.
18+
19+
- **Timing and performance** track execution efficiency through start and end timestamps, latency measurement, and resource usage, such as computational cost or token consumption for LLM-related spans.
20+
21+
- **Metadata and custom attributes** provide additional context via tags, annotations, and JSON-based extensible fields. Execution environment details, including host machine, service instance, and deployment version, further enrich observability.
22+
23+
---
24+
25+
## Types of Spans
26+
Spans are categorized based on the type of operation they capture. This classification ensures structured trace analysis and aids in performance monitoring.
27+
28+
- **Tool Spans**
29+
It tracks operations executed by external tools or functions. It captures essential details, including the tool’s name, description, parameters, and performance metrics, enabling comprehensive monitoring of tool interactions.
30+
31+
- **Chain Spans**
32+
It represents individual steps in a sequential workflow where data flows through multiple interconnected operations. It facilitates the visualization and analysis of execution pipelines, helping optimize process efficiency and detect bottlenecks.
33+
34+
- **LLM Spans**
35+
It captures interactions with large language models, recording input prompts, generated completions, token usage, and invocation parameters. These spans provide insights into model performance, response times, and computational costs.
36+
37+
- **Retriever Spans**
38+
It logs data retrieval operations, such as querying a database or fetching documents from an index. It stores search parameters and results, ensuring traceability and facilitating performance assessment of retrieval mechanisms.
39+
40+
- **Embedding Spans**
41+
It tracks text-to-vector transformations used in machine learning applications. It records embedding vectors, associated model metadata, and processing details, supporting efficient monitoring of vectorization processes.
42+
43+
- **Agent Spans**
44+
It documents actions performed by autonomous agents, including decision-making logic and tool interactions. It captures the rationale behind an agent’s choices, providing transparency into automated workflows and AI-driven decision processes.
45+
46+
- **Reranker Spans**
47+
It logs result reordering or ranking adjustments based on specific scoring criteria. It retains input documents and their updated rankings, facilitating analysis of ranking models and relevance optimization.
48+
49+
- **Unknown Spans**
50+
It serves as a fallback for operations that do not fit predefined span types. It ensures that all observed activities are recorded, even when their category is not explicitly defined.
51+
52+
- **Guardrail Spans**
53+
It monitors compliance and enforce safety rules within a system. It captures validation results, applied policies, and compliance status, ensuring adherence to predefined operational constraints.
54+
55+
- **Evaluator Spans**
56+
It represents assessment activities conducted to measure system performance or model effectiveness. It tracks evaluation metrics, scoring data, and feedback, supporting the continuous improvement of models and workflows.
57+
58+
---
59+
60+
61+

‎future-agi/products/observe/concept/traces.mdx‎

Whitespace-only changes.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: "Observe LangChain Application"
3+
---
4+
5+
This guide provides a detailed walkthrough of setting up and using Observe in your LangChain projects.
6+
7+
---
8+
9+
### **1. Install FutureAGI**
10+
Install the FutureAGI package, which includes the Observe framework.
11+
```bash
12+
pip install futureagi
13+
```
14+
This package provides the essential tools for tracing, monitoring, and evaluating LangChain applications.
15+
16+
### 2. Configure Environment Variables
17+
Set up your environment with the necessary API keys for OpenAI and FutureAGI. These credentials are crucial for:
18+
- Accessing OpenAI's language models.
19+
- Authenticating with FutureAGI's observability services.
20+
- Securely transmitting telemetry data.
21+
22+
```python
23+
import os
24+
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
25+
os.environ["FI_API_KEY"] = "your-futureagi-api-key"
26+
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"
27+
```
28+
29+
### 3. Initialize Trace Provider
30+
The trace provider is the core component that enables observability.
31+
- Creates a new project in the Observe platform
32+
- Establishes a connection for sending telemetry data
33+
- Sets up versioning for tracking changes over time
34+
- Initializes OpenTelemetry integration for distributed tracing
35+
36+
```python
37+
from fi.integrations.otel import register
38+
from fi.integrations.otel.types import ProjectType
39+
40+
trace_provider = register(
41+
project_type=ProjectType.OBSERVE,
42+
project_name="langchain_demo",
43+
project_version_name="v1"
44+
)
45+
```
46+
47+
### 4. Setup LangChain Instrumentation
48+
Configure automatic instrumentation for your LangChain components. The instrumentation:
49+
- Automatically captures all LangChain operations
50+
- Tracks prompt templates and their parameters
51+
- Monitors model calls and responses
52+
- Records timing information for each step
53+
- Enables detailed tracing of the chain execution
54+
55+
```python
56+
from fi.integrations.otel import LangChainInstrumentor
57+
from langchain_core.prompts import ChatPromptTemplate
58+
from langchain_openai import ChatOpenAI
59+
60+
LangChainInstrumentor().instrument(tracer_provider=trace_provider)
61+
62+
prompt = ChatPromptTemplate.from_template("{x} {y} {z}?").partial(x="why is", z="blue")
63+
chain = prompt | ChatOpenAI(model_name="gpt-3.5-turbo")
64+
```
65+
66+
### 5. Execute Chain with Observability
67+
Run your chain with full observability enabled:
68+
69+
```python
70+
def run_chain():
71+
try:
72+
result = chain.invoke({"y": "sky"})
73+
print(f"Response: {result}")
74+
except Exception as e:
75+
print(f"Error executing chain: {e}")
76+
77+
if __name__ == "__main__":
78+
run_chain()
79+
```
80+
During execution:
81+
- Each step of the chain is automatically traced
82+
- Prompts and completions are logged
83+
- Errors are captured and recorded
84+
- Performance metrics are collected
85+
- All data is sent to your Observe dashboard
86+
87+
---
88+
With the instrumentation setup from SDK, all telemetry data flows into Observe's UI, where you can interact with real-time dashboards, apply filters, and analyze performance.
89+
90+
91+
### 6. LLM Tracing
92+
LLM Tracing is pivotal for obtaining granular insights into your application's interactions with language models. After adding a project to the observability platform, users can access a detailed view of trace information, which includes:
93+
94+
- **Node Type**: Specifies the type of operation (e.g., input handling, model inference).
95+
- **Trace ID**: A unique identifier that allows you to track individual interactions.
96+
- **Input/Output**: Displays the input provided to the model along with its output.
97+
98+
You can also view the evaluation metrics for your traces here. You can setup the evals from the [Evals & Tasks](#8-evals-and-tasks) section. These metrics quantify response quality, allowing you to apply evaluations that compute key statistics, such as count, average, and standard deviation—and visualize insights through interactive graphs.
99+
100+
---
101+
102+
### 7. Sessions
103+
Sessions enable to group and manage related tracing activities, providing comprehensive insights into the interaction history between users and AI. This includes:
104+
- **Timeframe Filtering**: You can filter sessions by specific time intervals, making trend analysis straightforward.
105+
- **Detailed Interaction Histories**: Access a chronological log of interactions within a session, crucial for understanding conversation flows in applications like chatbots.
106+
- **Contextual Analysis**: View complete session data to analyze user behavior and model response patterns effectively.
107+
108+
---
109+
110+
### 8. Evals & Tasks
111+
This section automates model evaluation and monitoring, streamlining performance analysis by enabling you to define sampling rates, apply filters, set evaluation criteria, and manage tasks. By specifying the percentage of data to evaluate, you can optimize resource efficiency while ensuring meaningful insights.
112+
113+
[Click here to learn about all the evals provided by FutureAGI.]( /future-agi/products/evaluation/eval-definition/overview)
114+
115+
Filters allow you to narrow evaluations to specific data subsets based on custom criteria, providing a targeted approach to analysis. Evaluation criteria can be established to assess model performance comprehensively, incorporating key metrics that reflect accuracy, consistency, and relevance.
116+
117+
---
118+
With features like detailed LLM Tracing, session-centric data analysis, and automated evaluation tasks, Observe empowers teams to maintain high-quality, reliable AI systems.
119+
120+
---

future-agi/products/prompt-engineering/how-to/generate-prompt.mdx renamed to future-agi/products/prompt-engineering/how-to/generate-prompt/using-interface.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Generate a Prompt
2+
title: "Using Interface"
33
---
44

55
This feature simplifies prompt design by analyzing user instructions and dynamically generating a well-structured prompt.

0 commit comments

Comments
 (0)