Skip to content

Commit 84eb184

Browse files
committed
add APIs for llm obs
1 parent a8108c6 commit 84eb184

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package datadog.trace.api.llmobs;
2+
3+
import datadog.trace.api.llmobs.noop.NoOpLLMObsSpan;
4+
import javax.annotation.Nullable;
5+
6+
public class LLMObs {
7+
8+
9+
public static LLMObsSpan startLLMSpan(
10+
String modelName, String name, @Nullable String modelProvider, @Nullable String sessionID, @Nullable String mlApp) {
11+
12+
return NoOpLLMObsSpan.INSTANCE;
13+
}
14+
15+
public static LLMObsSpan startAgentSpan(
16+
String name, @Nullable String sessionID, @Nullable String mlApp) {
17+
18+
return NoOpLLMObsSpan.INSTANCE;
19+
}
20+
21+
public static LLMObsSpan startToolSpan(
22+
String name, @Nullable String sessionID, @Nullable String mlApp) {
23+
24+
return NoOpLLMObsSpan.INSTANCE;
25+
}
26+
27+
public static LLMObsSpan startTaskSpan(
28+
String name, @Nullable String sessionID, @Nullable String mlApp) {
29+
30+
return NoOpLLMObsSpan.INSTANCE;
31+
}
32+
33+
public static LLMObsSpan startWorkflowSpan(
34+
String name, @Nullable String sessionID, @Nullable String mlApp) {
35+
36+
return NoOpLLMObsSpan.INSTANCE;
37+
}
38+
39+
public interface LLMObsSpanFactory {
40+
LLMObsSpan startLLMSpan(String modelName, String name, @Nullable String modelProvider, @Nullable String sessionID, @Nullable String mlApp);
41+
LLMObsSpan startAgentSpan(String name, @Nullable String sessionID, @Nullable String mlApp);
42+
LLMObsSpan startToolSpan(String name, @Nullable String sessionID, @Nullable String mlApp);
43+
LLMObsSpan startTaskSpan(String name, @Nullable String sessionID, @Nullable String mlApp);
44+
LLMObsSpan startWorkflowSpan(String name, @Nullable String sessionID, @Nullable String mlApp);
45+
}
46+
47+
private class NoOpLLMObsSpanFactory implements LLMObsSpanFactory{
48+
public LLMObsSpan startLLMSpan(String modelName, String name, @Nullable String modelProvider, @Nullable String sessionID, @Nullable String mlApp) {
49+
return NoOpLLMObsSpan.INSTANCE;
50+
}
51+
public LLMObsSpan startAgentSpan(String name, @Nullable String sessionID, @Nullable String mlApp);
52+
LLMObsSpan startToolSpan(String name, @Nullable String sessionID, @Nullable String mlApp);
53+
LLMObsSpan startTaskSpan(String name, @Nullable String sessionID, @Nullable String mlApp);
54+
LLMObsSpan startWorkflowSpan(String name, @Nullable String sessionID, @Nullable String mlApp);
55+
}
56+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package datadog.trace.api.llmobs;
2+
3+
/**
4+
* This interface represent an individual LLM Obs span.
5+
*/
6+
public interface LLMObsSpan {
7+
8+
/**
9+
* Annotate spans with inputs, outputs, and metadata.
10+
*
11+
* @param key The name of the tag
12+
* @param value The value of the tag
13+
*/
14+
void annotate(String key, Object value);
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package datadog.trace.api.llmobs.noop;
2+
3+
import datadog.trace.api.llmobs.LLMObsSpan;
4+
5+
public class NoOpLLMObsSpan implements LLMObsSpan {
6+
public static final LLMObsSpan INSTANCE = new NoOpLLMObsSpan();
7+
8+
@Override
9+
public void annotate(String key, Object value) {}
10+
}

0 commit comments

Comments
 (0)