langtrace-python-sdk 2.0.1__tar.gz → 2.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/PKG-INFO +1 -1
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/cohere/patch.py +34 -26
- langtrace_python_sdk-2.0.2/src/langtrace_python_sdk/version.py +1 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/anthropic/conftest.py +0 -3
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/anthropic/test_anthropic.py +6 -29
- langtrace_python_sdk-2.0.2/src/tests/cohere/cassettes/test_cohere_chat.yaml +91 -0
- langtrace_python_sdk-2.0.2/src/tests/cohere/cassettes/test_cohere_chat_streaming.yaml +275 -0
- langtrace_python_sdk-2.0.2/src/tests/cohere/cassettes/test_cohere_embed.yaml +73 -0
- langtrace_python_sdk-2.0.2/src/tests/cohere/cassettes/test_cohere_rerank.yaml +76 -0
- langtrace_python_sdk-2.0.2/src/tests/cohere/conftest.py +30 -0
- langtrace_python_sdk-2.0.2/src/tests/cohere/test_cohere_chat.py +116 -0
- langtrace_python_sdk-2.0.2/src/tests/cohere/test_cohere_embed.py +35 -0
- langtrace_python_sdk-2.0.2/src/tests/cohere/test_cohere_rerank.py +52 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/conftest.py +5 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/conftest.py +0 -3
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/test_chat_completion.py +19 -30
- langtrace_python_sdk-2.0.2/src/tests/utils.py +44 -0
- langtrace_python_sdk-2.0.1/src/langtrace_python_sdk/version.py +0 -1
- langtrace_python_sdk-2.0.1/src/tests/utils.py +0 -21
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/.gitignore +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/LICENSE +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/README.md +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/pyproject.toml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/anthropic_example/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/anthropic_example/completion.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/chroma_example/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/chroma_example/basic.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/cohere_example/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/cohere_example/chat.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/cohere_example/chat_stream.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/cohere_example/embed.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/cohere_example/rerank.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/cohere_example/tools.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/fastapi_example/basic_route.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/hiveagent_example/basic.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/langchain_example/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/langchain_example/basic.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/langchain_example/groq_example.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/langchain_example/langgraph_example.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/langchain_example/tool.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/llamaindex_example/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/llamaindex_example/agent.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/llamaindex_example/basic.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/llamaindex_example/data/abramov.txt +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/async_tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/async_tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/chat_completion.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/embeddings_create.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/function_calling.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/images_generate.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/tool_calling.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/tool_calling_nonstreaming.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/openai_example/tool_calling_streaming.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/perplexity_example/basic.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/pinecone_example/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/pinecone_example/basic.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/qdrant_example/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/examples/qdrant_example/basic.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/cohere.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/common.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/groq.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/constants/instrumentation/qdrant.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/cohere/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/cohere/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/groq/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/groq/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/groq/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langgraph/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langgraph/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/langgraph/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/openai/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/qdrant/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/qdrant/instrumentation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/instrumentation/qdrant/patch.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/langtrace.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/utils/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/utils/llm.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/langtrace_python_sdk/utils/with_root_span.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/run_example.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/__init__.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/anthropic/cassettes/test_anthropic.yaml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/anthropic/cassettes/test_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/anthropic/cassettes/test_async_anthropic_streaming.yaml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/chroma/test_chroma.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/langchain/test_langchain.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/langchain/test_langchain_community.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/langchain/test_langchain_core.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/cassettes/test_async_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/cassettes/test_async_image_generation.yaml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/cassettes/test_chat_completion.yaml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/cassettes/test_chat_completion_streaming.yaml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/cassettes/test_image_generation.yaml +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/test_embeddings.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/openai/test_image_generation.py +0 -0
- {langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/pinecone/test_pinecone.py +0 -0
|
@@ -23,7 +23,9 @@ from opentelemetry.trace.status import Status, StatusCode
|
|
|
23
23
|
|
|
24
24
|
from langtrace_python_sdk.constants.instrumentation.cohere import APIS
|
|
25
25
|
from langtrace_python_sdk.constants.instrumentation.common import (
|
|
26
|
-
LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
|
|
26
|
+
LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY,
|
|
27
|
+
SERVICE_PROVIDERS,
|
|
28
|
+
)
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
def rerank(original_method, version, tracer):
|
|
@@ -103,9 +105,7 @@ def rerank(original_method, version, tracer):
|
|
|
103
105
|
else 0
|
|
104
106
|
),
|
|
105
107
|
}
|
|
106
|
-
span.set_attribute(
|
|
107
|
-
"llm.token.counts", json.dumps(usage_dict)
|
|
108
|
-
)
|
|
108
|
+
span.set_attribute("llm.token.counts", json.dumps(usage_dict))
|
|
109
109
|
|
|
110
110
|
span.set_status(StatusCode.OK)
|
|
111
111
|
span.end()
|
|
@@ -187,9 +187,7 @@ def embed(original_method, version, tracer):
|
|
|
187
187
|
else 0
|
|
188
188
|
),
|
|
189
189
|
}
|
|
190
|
-
span.set_attribute(
|
|
191
|
-
"llm.token.counts", json.dumps(usage_dict)
|
|
192
|
-
)
|
|
190
|
+
span.set_attribute("llm.token.counts", json.dumps(usage_dict))
|
|
193
191
|
|
|
194
192
|
span.set_status(StatusCode.OK)
|
|
195
193
|
span.end()
|
|
@@ -226,9 +224,7 @@ def chat_create(original_method, version, tracer):
|
|
|
226
224
|
item.get("role") if item.get("role") is not None else "USER"
|
|
227
225
|
),
|
|
228
226
|
"content": (
|
|
229
|
-
item.get("message")
|
|
230
|
-
if item.get("message") is not None
|
|
231
|
-
else ""
|
|
227
|
+
item.get("message") if item.get("message") is not None else ""
|
|
232
228
|
),
|
|
233
229
|
}
|
|
234
230
|
for item in chat_history
|
|
@@ -312,7 +308,11 @@ def chat_create(original_method, version, tracer):
|
|
|
312
308
|
span.set_attribute("llm.is_search_required", result.is_search_required)
|
|
313
309
|
|
|
314
310
|
if kwargs.get("stream") is False or kwargs.get("stream") is None:
|
|
315
|
-
if
|
|
311
|
+
if (
|
|
312
|
+
hasattr(result, "text")
|
|
313
|
+
and result.text is not None
|
|
314
|
+
and result.text != ""
|
|
315
|
+
):
|
|
316
316
|
if (
|
|
317
317
|
hasattr(result, "chat_history")
|
|
318
318
|
and result.chat_history is not None
|
|
@@ -321,8 +321,7 @@ def chat_create(original_method, version, tracer):
|
|
|
321
321
|
{
|
|
322
322
|
"role": (
|
|
323
323
|
item.role
|
|
324
|
-
if hasattr(item, "role")
|
|
325
|
-
and item.role is not None
|
|
324
|
+
if hasattr(item, "role") and item.role is not None
|
|
326
325
|
else "USER"
|
|
327
326
|
),
|
|
328
327
|
"content": (
|
|
@@ -336,9 +335,7 @@ def chat_create(original_method, version, tracer):
|
|
|
336
335
|
]
|
|
337
336
|
span.set_attribute("llm.responses", json.dumps(responses))
|
|
338
337
|
else:
|
|
339
|
-
responses = [
|
|
340
|
-
{"role": "CHATBOT", "content": result.text}
|
|
341
|
-
]
|
|
338
|
+
responses = [{"role": "CHATBOT", "content": result.text}]
|
|
342
339
|
span.set_attribute("llm.responses", json.dumps(responses))
|
|
343
340
|
elif hasattr(result, "tool_calls") and result.tool_calls is not None:
|
|
344
341
|
tool_calls = []
|
|
@@ -422,9 +419,7 @@ def chat_stream(original_method, version, tracer):
|
|
|
422
419
|
item.get("role") if item.get("role") is not None else "USER"
|
|
423
420
|
),
|
|
424
421
|
"content": (
|
|
425
|
-
item.get("message")
|
|
426
|
-
if item.get("message") is not None
|
|
427
|
-
else ""
|
|
422
|
+
item.get("message") if item.get("message") is not None else ""
|
|
428
423
|
),
|
|
429
424
|
}
|
|
430
425
|
for item in chat_history
|
|
@@ -485,7 +480,7 @@ def chat_stream(original_method, version, tracer):
|
|
|
485
480
|
# stringify the list of objects
|
|
486
481
|
attributes.llm_tool_results = json.dumps(kwargs.get("tool_results"))
|
|
487
482
|
|
|
488
|
-
span = tracer.start_span(APIS["
|
|
483
|
+
span = tracer.start_span(APIS["CHAT_STREAM"]["METHOD"], kind=SpanKind.CLIENT)
|
|
489
484
|
for field, value in attributes.model_dump(by_alias=True).items():
|
|
490
485
|
if value is not None:
|
|
491
486
|
span.set_attribute(field, value)
|
|
@@ -503,19 +498,28 @@ def chat_stream(original_method, version, tracer):
|
|
|
503
498
|
Event.STREAM_OUTPUT.value, {"response": "".join(content)}
|
|
504
499
|
)
|
|
505
500
|
|
|
506
|
-
if
|
|
501
|
+
if (
|
|
502
|
+
hasattr(event, "finish_reason")
|
|
503
|
+
and event.finish_reason == "COMPLETE"
|
|
504
|
+
):
|
|
507
505
|
response = event.response
|
|
508
506
|
|
|
509
507
|
if (hasattr(response, "generation_id")) and (
|
|
510
508
|
response.generation_id is not None
|
|
511
509
|
):
|
|
512
|
-
span.set_attribute(
|
|
513
|
-
|
|
510
|
+
span.set_attribute(
|
|
511
|
+
"llm.generation_id", response.generation_id
|
|
512
|
+
)
|
|
513
|
+
if (hasattr(response, "response_id")) and (
|
|
514
|
+
response.response_id is not None
|
|
515
|
+
):
|
|
514
516
|
span.set_attribute("llm.response_id", response.response_id)
|
|
515
517
|
if (hasattr(response, "is_search_required")) and (
|
|
516
518
|
response.is_search_required is not None
|
|
517
519
|
):
|
|
518
|
-
span.set_attribute(
|
|
520
|
+
span.set_attribute(
|
|
521
|
+
"llm.is_search_required", response.is_search_required
|
|
522
|
+
)
|
|
519
523
|
|
|
520
524
|
# Set the response attributes
|
|
521
525
|
if hasattr(response, "text") and response.text is not None:
|
|
@@ -540,12 +544,16 @@ def chat_stream(original_method, version, tracer):
|
|
|
540
544
|
}
|
|
541
545
|
for item in response.chat_history
|
|
542
546
|
]
|
|
543
|
-
span.set_attribute(
|
|
547
|
+
span.set_attribute(
|
|
548
|
+
"llm.responses", json.dumps(responses)
|
|
549
|
+
)
|
|
544
550
|
else:
|
|
545
551
|
responses = [
|
|
546
552
|
{"role": "CHATBOT", "content": response.text}
|
|
547
553
|
]
|
|
548
|
-
span.set_attribute(
|
|
554
|
+
span.set_attribute(
|
|
555
|
+
"llm.responses", json.dumps(responses)
|
|
556
|
+
)
|
|
549
557
|
|
|
550
558
|
# Get the usage
|
|
551
559
|
if hasattr(response, "meta") and response.meta is not None:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.0.2"
|
{langtrace_python_sdk-2.0.1 → langtrace_python_sdk-2.0.2}/src/tests/anthropic/test_anthropic.py
RENAMED
|
@@ -2,6 +2,7 @@ import pytest
|
|
|
2
2
|
import json
|
|
3
3
|
import importlib
|
|
4
4
|
from langtrace_python_sdk.constants.instrumentation.anthropic import APIS
|
|
5
|
+
from tests.utils import assert_response_format, assert_token_count
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
@pytest.mark.vcr()
|
|
@@ -16,7 +17,7 @@ def test_anthropic(anthropic_client, exporter):
|
|
|
16
17
|
"stream": False,
|
|
17
18
|
"max_tokens": 1024,
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
anthropic_client.messages.create(**kwargs)
|
|
20
21
|
spans = exporter.get_finished_spans()
|
|
21
22
|
completion_span = spans[-1]
|
|
22
23
|
|
|
@@ -36,20 +37,8 @@ def test_anthropic(anthropic_client, exporter):
|
|
|
36
37
|
assert attributes.get("llm.prompts") == json.dumps(messages_value)
|
|
37
38
|
assert attributes.get("llm.stream") is False
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
prompt_tokens = tokens.get("input_tokens")
|
|
42
|
-
total_tokens = tokens.get("total_tokens")
|
|
43
|
-
|
|
44
|
-
assert output_tokens and prompt_tokens and total_tokens
|
|
45
|
-
assert output_tokens + prompt_tokens == total_tokens
|
|
46
|
-
|
|
47
|
-
langtrace_responses = json.loads(attributes.get("llm.responses"))
|
|
48
|
-
assert isinstance(langtrace_responses, list)
|
|
49
|
-
for langtrace_response in langtrace_responses:
|
|
50
|
-
assert isinstance(langtrace_response, dict)
|
|
51
|
-
assert "role" in langtrace_response
|
|
52
|
-
assert "content" in langtrace_response
|
|
40
|
+
assert_token_count(attributes)
|
|
41
|
+
assert_response_format(attributes)
|
|
53
42
|
|
|
54
43
|
|
|
55
44
|
@pytest.mark.vcr()
|
|
@@ -93,17 +82,5 @@ def test_anthropic_streaming(anthropic_client, exporter):
|
|
|
93
82
|
|
|
94
83
|
assert len(events) - 2 == chunk_count # -2 for start and end events
|
|
95
84
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
prompt_tokens = tokens.get("input_tokens")
|
|
99
|
-
total_tokens = tokens.get("total_tokens")
|
|
100
|
-
|
|
101
|
-
assert output_tokens and prompt_tokens and total_tokens
|
|
102
|
-
assert output_tokens + prompt_tokens == total_tokens
|
|
103
|
-
|
|
104
|
-
langtrace_responses = json.loads(attributes.get("llm.responses"))
|
|
105
|
-
assert isinstance(langtrace_responses, list)
|
|
106
|
-
for langtrace_response in langtrace_responses:
|
|
107
|
-
assert isinstance(langtrace_response, dict)
|
|
108
|
-
assert "role" in langtrace_response
|
|
109
|
-
assert "content" in langtrace_response
|
|
85
|
+
assert_token_count(attributes)
|
|
86
|
+
assert_response_format(attributes)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
interactions:
|
|
2
|
+
- request:
|
|
3
|
+
body: '{"message": "Tell me a story in 3 sentences or less?", "stream": false,
|
|
4
|
+
"model": "command", "preamble": "answer like a pirate", "chat_history": [{"role":
|
|
5
|
+
"USER", "message": "Who discovered gravity?"}, {"role": "CHATBOT", "message":
|
|
6
|
+
"The man who is widely credited with discovering gravity is Sir Isaac Newton"}],
|
|
7
|
+
"connectors": [{"id": "web-search"}], "temperature": 0.1}'
|
|
8
|
+
headers:
|
|
9
|
+
accept:
|
|
10
|
+
- '*/*'
|
|
11
|
+
accept-encoding:
|
|
12
|
+
- gzip, deflate
|
|
13
|
+
connection:
|
|
14
|
+
- keep-alive
|
|
15
|
+
content-length:
|
|
16
|
+
- '370'
|
|
17
|
+
content-type:
|
|
18
|
+
- application/json
|
|
19
|
+
host:
|
|
20
|
+
- api.cohere.ai
|
|
21
|
+
user-agent:
|
|
22
|
+
- python-httpx/0.27.0
|
|
23
|
+
x-fern-language:
|
|
24
|
+
- Python
|
|
25
|
+
x-fern-sdk-name:
|
|
26
|
+
- cohere
|
|
27
|
+
x-fern-sdk-version:
|
|
28
|
+
- 5.3.2
|
|
29
|
+
method: POST
|
|
30
|
+
uri: https://api.cohere.ai/v1/chat
|
|
31
|
+
response:
|
|
32
|
+
body:
|
|
33
|
+
string: '{"response_id":"27cf0e2e-b4d5-427b-9866-d108307022de","text":"Argh,
|
|
34
|
+
many years ago, a bold explorer named Isaac Newton sat beneath an apple tree
|
|
35
|
+
for many hours, contemplating the nature of the universe and the motions of
|
|
36
|
+
the heavenly bodies. He posited that all objects in the universe are attracted
|
|
37
|
+
to each other. Then one day, his theory was proven true when a juicy apple
|
|
38
|
+
fell from the tree and struck him on the head, inspiring his theory of gravity
|
|
39
|
+
and changing science forever.","generation_id":"2a7babaa-f1da-468f-9891-5171f137ba04","chat_history":[{"role":"USER","message":"Who
|
|
40
|
+
discovered gravity?"},{"role":"CHATBOT","message":"The man who is widely credited
|
|
41
|
+
with discovering gravity is Sir Isaac Newton"},{"role":"USER","message":"Tell
|
|
42
|
+
me a story in 3 sentences or less?"},{"role":"CHATBOT","message":"Argh, many
|
|
43
|
+
years ago, a bold explorer named Isaac Newton sat beneath an apple tree for
|
|
44
|
+
many hours, contemplating the nature of the universe and the motions of the
|
|
45
|
+
heavenly bodies. He posited that all objects in the universe are attracted
|
|
46
|
+
to each other. Then one day, his theory was proven true when a juicy apple
|
|
47
|
+
fell from the tree and struck him on the head, inspiring his theory of gravity
|
|
48
|
+
and changing science forever."}],"finish_reason":"COMPLETE","meta":{"api_version":{"version":"1"},"billed_units":{"input_tokens":31,"output_tokens":85},"tokens":{"input_tokens":49,"output_tokens":85}},"documents":[]}'
|
|
49
|
+
headers:
|
|
50
|
+
Alt-Svc:
|
|
51
|
+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
|
52
|
+
Via:
|
|
53
|
+
- 1.1 google
|
|
54
|
+
access-control-expose-headers:
|
|
55
|
+
- X-Debug-Trace-ID
|
|
56
|
+
cache-control:
|
|
57
|
+
- no-cache, no-store, no-transform, must-revalidate, private, max-age=0
|
|
58
|
+
content-length:
|
|
59
|
+
- '1420'
|
|
60
|
+
content-type:
|
|
61
|
+
- application/json
|
|
62
|
+
date:
|
|
63
|
+
- Fri, 26 Apr 2024 13:51:11 GMT
|
|
64
|
+
expires:
|
|
65
|
+
- Thu, 01 Jan 1970 00:00:00 UTC
|
|
66
|
+
num_chars:
|
|
67
|
+
- '220'
|
|
68
|
+
num_tokens:
|
|
69
|
+
- '116'
|
|
70
|
+
pragma:
|
|
71
|
+
- no-cache
|
|
72
|
+
server:
|
|
73
|
+
- envoy
|
|
74
|
+
vary:
|
|
75
|
+
- Origin
|
|
76
|
+
x-accel-expires:
|
|
77
|
+
- '0'
|
|
78
|
+
x-debug-trace-id:
|
|
79
|
+
- 6e0f777a5f86c8b5453bf374fd3fadbd
|
|
80
|
+
x-endpoint-monthly-call-limit:
|
|
81
|
+
- '1000'
|
|
82
|
+
x-envoy-upstream-service-time:
|
|
83
|
+
- '3037'
|
|
84
|
+
x-trial-endpoint-call-limit:
|
|
85
|
+
- '40'
|
|
86
|
+
x-trial-endpoint-call-remaining:
|
|
87
|
+
- '39'
|
|
88
|
+
status:
|
|
89
|
+
code: 200
|
|
90
|
+
message: OK
|
|
91
|
+
version: 1
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
interactions:
|
|
2
|
+
- request:
|
|
3
|
+
body: '{"message": "Tell me a story in 3 sentences or less?", "stream": true,
|
|
4
|
+
"model": "command", "preamble": "answer like a pirate", "chat_history": [{"role":
|
|
5
|
+
"USER", "message": "Who discovered gravity?"}, {"role": "CHATBOT", "message":
|
|
6
|
+
"The man who is widely credited with discovering gravity is Sir Isaac Newton"}],
|
|
7
|
+
"connectors": [{"id": "web-search"}], "temperature": 0.1}'
|
|
8
|
+
headers:
|
|
9
|
+
accept:
|
|
10
|
+
- '*/*, text/event-stream, application/stream+json'
|
|
11
|
+
accept-encoding:
|
|
12
|
+
- gzip, deflate
|
|
13
|
+
connection:
|
|
14
|
+
- keep-alive
|
|
15
|
+
content-length:
|
|
16
|
+
- '369'
|
|
17
|
+
content-type:
|
|
18
|
+
- application/json
|
|
19
|
+
host:
|
|
20
|
+
- api.cohere.ai
|
|
21
|
+
user-agent:
|
|
22
|
+
- python-httpx/0.27.0
|
|
23
|
+
x-fern-language:
|
|
24
|
+
- Python
|
|
25
|
+
x-fern-sdk-name:
|
|
26
|
+
- cohere
|
|
27
|
+
x-fern-sdk-version:
|
|
28
|
+
- 5.3.2
|
|
29
|
+
method: POST
|
|
30
|
+
uri: https://api.cohere.ai/v1/chat
|
|
31
|
+
response:
|
|
32
|
+
body:
|
|
33
|
+
string: '{"is_finished":false,"event_type":"stream-start","generation_id":"1d521296-3008-42bf-8062-8b744d997ba0"}
|
|
34
|
+
|
|
35
|
+
{"is_finished":false,"event_type":"text-generation","text":"Ar"}
|
|
36
|
+
|
|
37
|
+
{"is_finished":false,"event_type":"text-generation","text":"gh"}
|
|
38
|
+
|
|
39
|
+
{"is_finished":false,"event_type":"text-generation","text":","}
|
|
40
|
+
|
|
41
|
+
{"is_finished":false,"event_type":"text-generation","text":" here"}
|
|
42
|
+
|
|
43
|
+
{"is_finished":false,"event_type":"text-generation","text":" be"}
|
|
44
|
+
|
|
45
|
+
{"is_finished":false,"event_type":"text-generation","text":" the"}
|
|
46
|
+
|
|
47
|
+
{"is_finished":false,"event_type":"text-generation","text":" story"}
|
|
48
|
+
|
|
49
|
+
{"is_finished":false,"event_type":"text-generation","text":" of"}
|
|
50
|
+
|
|
51
|
+
{"is_finished":false,"event_type":"text-generation","text":" Gold"}
|
|
52
|
+
|
|
53
|
+
{"is_finished":false,"event_type":"text-generation","text":"il"}
|
|
54
|
+
|
|
55
|
+
{"is_finished":false,"event_type":"text-generation","text":"ocks"}
|
|
56
|
+
|
|
57
|
+
{"is_finished":false,"event_type":"text-generation","text":" and"}
|
|
58
|
+
|
|
59
|
+
{"is_finished":false,"event_type":"text-generation","text":" the"}
|
|
60
|
+
|
|
61
|
+
{"is_finished":false,"event_type":"text-generation","text":" Three"}
|
|
62
|
+
|
|
63
|
+
{"is_finished":false,"event_type":"text-generation","text":" Bears"}
|
|
64
|
+
|
|
65
|
+
{"is_finished":false,"event_type":"text-generation","text":" told"}
|
|
66
|
+
|
|
67
|
+
{"is_finished":false,"event_type":"text-generation","text":" in"}
|
|
68
|
+
|
|
69
|
+
{"is_finished":false,"event_type":"text-generation","text":" three"}
|
|
70
|
+
|
|
71
|
+
{"is_finished":false,"event_type":"text-generation","text":" sentences"}
|
|
72
|
+
|
|
73
|
+
{"is_finished":false,"event_type":"text-generation","text":" or"}
|
|
74
|
+
|
|
75
|
+
{"is_finished":false,"event_type":"text-generation","text":" less"}
|
|
76
|
+
|
|
77
|
+
{"is_finished":false,"event_type":"text-generation","text":":"}
|
|
78
|
+
|
|
79
|
+
{"is_finished":false,"event_type":"text-generation","text":"\n\nOnce"}
|
|
80
|
+
|
|
81
|
+
{"is_finished":false,"event_type":"text-generation","text":" upon"}
|
|
82
|
+
|
|
83
|
+
{"is_finished":false,"event_type":"text-generation","text":" a"}
|
|
84
|
+
|
|
85
|
+
{"is_finished":false,"event_type":"text-generation","text":" time"}
|
|
86
|
+
|
|
87
|
+
{"is_finished":false,"event_type":"text-generation","text":","}
|
|
88
|
+
|
|
89
|
+
{"is_finished":false,"event_type":"text-generation","text":" a"}
|
|
90
|
+
|
|
91
|
+
{"is_finished":false,"event_type":"text-generation","text":" little"}
|
|
92
|
+
|
|
93
|
+
{"is_finished":false,"event_type":"text-generation","text":" girl"}
|
|
94
|
+
|
|
95
|
+
{"is_finished":false,"event_type":"text-generation","text":" named"}
|
|
96
|
+
|
|
97
|
+
{"is_finished":false,"event_type":"text-generation","text":" Gold"}
|
|
98
|
+
|
|
99
|
+
{"is_finished":false,"event_type":"text-generation","text":"il"}
|
|
100
|
+
|
|
101
|
+
{"is_finished":false,"event_type":"text-generation","text":"ocks"}
|
|
102
|
+
|
|
103
|
+
{"is_finished":false,"event_type":"text-generation","text":" stumbled"}
|
|
104
|
+
|
|
105
|
+
{"is_finished":false,"event_type":"text-generation","text":" into"}
|
|
106
|
+
|
|
107
|
+
{"is_finished":false,"event_type":"text-generation","text":" the"}
|
|
108
|
+
|
|
109
|
+
{"is_finished":false,"event_type":"text-generation","text":" home"}
|
|
110
|
+
|
|
111
|
+
{"is_finished":false,"event_type":"text-generation","text":" of"}
|
|
112
|
+
|
|
113
|
+
{"is_finished":false,"event_type":"text-generation","text":" three"}
|
|
114
|
+
|
|
115
|
+
{"is_finished":false,"event_type":"text-generation","text":" bears"}
|
|
116
|
+
|
|
117
|
+
{"is_finished":false,"event_type":"text-generation","text":","}
|
|
118
|
+
|
|
119
|
+
{"is_finished":false,"event_type":"text-generation","text":" she"}
|
|
120
|
+
|
|
121
|
+
{"is_finished":false,"event_type":"text-generation","text":" ate"}
|
|
122
|
+
|
|
123
|
+
{"is_finished":false,"event_type":"text-generation","text":" their"}
|
|
124
|
+
|
|
125
|
+
{"is_finished":false,"event_type":"text-generation","text":" food"}
|
|
126
|
+
|
|
127
|
+
{"is_finished":false,"event_type":"text-generation","text":","}
|
|
128
|
+
|
|
129
|
+
{"is_finished":false,"event_type":"text-generation","text":" broke"}
|
|
130
|
+
|
|
131
|
+
{"is_finished":false,"event_type":"text-generation","text":" their"}
|
|
132
|
+
|
|
133
|
+
{"is_finished":false,"event_type":"text-generation","text":" chairs"}
|
|
134
|
+
|
|
135
|
+
{"is_finished":false,"event_type":"text-generation","text":","}
|
|
136
|
+
|
|
137
|
+
{"is_finished":false,"event_type":"text-generation","text":" and"}
|
|
138
|
+
|
|
139
|
+
{"is_finished":false,"event_type":"text-generation","text":" slept"}
|
|
140
|
+
|
|
141
|
+
{"is_finished":false,"event_type":"text-generation","text":" in"}
|
|
142
|
+
|
|
143
|
+
{"is_finished":false,"event_type":"text-generation","text":" their"}
|
|
144
|
+
|
|
145
|
+
{"is_finished":false,"event_type":"text-generation","text":" beds"}
|
|
146
|
+
|
|
147
|
+
{"is_finished":false,"event_type":"text-generation","text":"."}
|
|
148
|
+
|
|
149
|
+
{"is_finished":false,"event_type":"text-generation","text":" When"}
|
|
150
|
+
|
|
151
|
+
{"is_finished":false,"event_type":"text-generation","text":" the"}
|
|
152
|
+
|
|
153
|
+
{"is_finished":false,"event_type":"text-generation","text":" three"}
|
|
154
|
+
|
|
155
|
+
{"is_finished":false,"event_type":"text-generation","text":" bears"}
|
|
156
|
+
|
|
157
|
+
{"is_finished":false,"event_type":"text-generation","text":" returned"}
|
|
158
|
+
|
|
159
|
+
{"is_finished":false,"event_type":"text-generation","text":" they"}
|
|
160
|
+
|
|
161
|
+
{"is_finished":false,"event_type":"text-generation","text":" were"}
|
|
162
|
+
|
|
163
|
+
{"is_finished":false,"event_type":"text-generation","text":" outraged"}
|
|
164
|
+
|
|
165
|
+
{"is_finished":false,"event_type":"text-generation","text":","}
|
|
166
|
+
|
|
167
|
+
{"is_finished":false,"event_type":"text-generation","text":" but"}
|
|
168
|
+
|
|
169
|
+
{"is_finished":false,"event_type":"text-generation","text":" Gold"}
|
|
170
|
+
|
|
171
|
+
{"is_finished":false,"event_type":"text-generation","text":"il"}
|
|
172
|
+
|
|
173
|
+
{"is_finished":false,"event_type":"text-generation","text":"ocks"}
|
|
174
|
+
|
|
175
|
+
{"is_finished":false,"event_type":"text-generation","text":" had"}
|
|
176
|
+
|
|
177
|
+
{"is_finished":false,"event_type":"text-generation","text":" disappeared"}
|
|
178
|
+
|
|
179
|
+
{"is_finished":false,"event_type":"text-generation","text":" -"}
|
|
180
|
+
|
|
181
|
+
{"is_finished":false,"event_type":"text-generation","text":" she"}
|
|
182
|
+
|
|
183
|
+
{"is_finished":false,"event_type":"text-generation","text":" had"}
|
|
184
|
+
|
|
185
|
+
{"is_finished":false,"event_type":"text-generation","text":" run"}
|
|
186
|
+
|
|
187
|
+
{"is_finished":false,"event_type":"text-generation","text":" away"}
|
|
188
|
+
|
|
189
|
+
{"is_finished":false,"event_type":"text-generation","text":"."}
|
|
190
|
+
|
|
191
|
+
{"is_finished":false,"event_type":"text-generation","text":"\n\nAr"}
|
|
192
|
+
|
|
193
|
+
{"is_finished":false,"event_type":"text-generation","text":"gh"}
|
|
194
|
+
|
|
195
|
+
{"is_finished":false,"event_type":"text-generation","text":","}
|
|
196
|
+
|
|
197
|
+
{"is_finished":false,"event_type":"text-generation","text":" that"}
|
|
198
|
+
|
|
199
|
+
{"is_finished":false,"event_type":"text-generation","text":" be"}
|
|
200
|
+
|
|
201
|
+
{"is_finished":false,"event_type":"text-generation","text":" the"}
|
|
202
|
+
|
|
203
|
+
{"is_finished":false,"event_type":"text-generation","text":" end"}
|
|
204
|
+
|
|
205
|
+
{"is_finished":false,"event_type":"text-generation","text":" of"}
|
|
206
|
+
|
|
207
|
+
{"is_finished":false,"event_type":"text-generation","text":" the"}
|
|
208
|
+
|
|
209
|
+
{"is_finished":false,"event_type":"text-generation","text":" story"}
|
|
210
|
+
|
|
211
|
+
{"is_finished":false,"event_type":"text-generation","text":" me"}
|
|
212
|
+
|
|
213
|
+
{"is_finished":false,"event_type":"text-generation","text":" heart"}
|
|
214
|
+
|
|
215
|
+
{"is_finished":false,"event_type":"text-generation","text":"ies"}
|
|
216
|
+
|
|
217
|
+
{"is_finished":false,"event_type":"text-generation","text":"!"}
|
|
218
|
+
|
|
219
|
+
{"is_finished":true,"event_type":"stream-end","response":{"response_id":"86b73a20-0cfa-414b-b148-e7857669ef3e","text":"Argh,
|
|
220
|
+
here be the story of Goldilocks and the Three Bears told in three sentences
|
|
221
|
+
or less:\n\nOnce upon a time, a little girl named Goldilocks stumbled into
|
|
222
|
+
the home of three bears, she ate their food, broke their chairs, and slept
|
|
223
|
+
in their beds. When the three bears returned they were outraged, but Goldilocks
|
|
224
|
+
had disappeared - she had run away.\n\nArgh, that be the end of the story
|
|
225
|
+
me hearties!","generation_id":"1d521296-3008-42bf-8062-8b744d997ba0","chat_history":[{"role":"USER","message":"Who
|
|
226
|
+
discovered gravity?"},{"role":"CHATBOT","message":"The man who is widely credited
|
|
227
|
+
with discovering gravity is Sir Isaac Newton"},{"role":"USER","message":"Tell
|
|
228
|
+
me a story in 3 sentences or less?"},{"role":"CHATBOT","message":"Argh, here
|
|
229
|
+
be the story of Goldilocks and the Three Bears told in three sentences or
|
|
230
|
+
less:\n\nOnce upon a time, a little girl named Goldilocks stumbled into the
|
|
231
|
+
home of three bears, she ate their food, broke their chairs, and slept in
|
|
232
|
+
their beds. When the three bears returned they were outraged, but Goldilocks
|
|
233
|
+
had disappeared - she had run away.\n\nArgh, that be the end of the story
|
|
234
|
+
me hearties!"}],"finish_reason":"COMPLETE","meta":{"api_version":{"version":"1"},"billed_units":{"input_tokens":31,"output_tokens":96},"tokens":{"input_tokens":49,"output_tokens":96}},"documents":[]},"finish_reason":"COMPLETE"}
|
|
235
|
+
|
|
236
|
+
'
|
|
237
|
+
headers:
|
|
238
|
+
Alt-Svc:
|
|
239
|
+
- h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
|
|
240
|
+
Via:
|
|
241
|
+
- 1.1 google
|
|
242
|
+
access-control-expose-headers:
|
|
243
|
+
- X-Debug-Trace-ID
|
|
244
|
+
cache-control:
|
|
245
|
+
- no-cache, no-store, no-transform, must-revalidate, private, max-age=0
|
|
246
|
+
content-type:
|
|
247
|
+
- application/stream+json
|
|
248
|
+
date:
|
|
249
|
+
- Fri, 26 Apr 2024 13:59:03 GMT
|
|
250
|
+
expires:
|
|
251
|
+
- Thu, 01 Jan 1970 00:00:00 UTC
|
|
252
|
+
pragma:
|
|
253
|
+
- no-cache
|
|
254
|
+
server:
|
|
255
|
+
- envoy
|
|
256
|
+
transfer-encoding:
|
|
257
|
+
- chunked
|
|
258
|
+
vary:
|
|
259
|
+
- Origin
|
|
260
|
+
x-accel-expires:
|
|
261
|
+
- '0'
|
|
262
|
+
x-debug-trace-id:
|
|
263
|
+
- 2803337aa161b7c4f034921bb2bb1444
|
|
264
|
+
x-endpoint-monthly-call-limit:
|
|
265
|
+
- '1000'
|
|
266
|
+
x-envoy-upstream-service-time:
|
|
267
|
+
- '66'
|
|
268
|
+
x-trial-endpoint-call-limit:
|
|
269
|
+
- '40'
|
|
270
|
+
x-trial-endpoint-call-remaining:
|
|
271
|
+
- '39'
|
|
272
|
+
status:
|
|
273
|
+
code: 200
|
|
274
|
+
message: OK
|
|
275
|
+
version: 1
|