Skip to content

Commit

Permalink
cleanup the example
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking committed Jan 24, 2024
1 parent b8bd22e commit e5b8cc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dspy
import os
from openinference.instrumentation.dspy import DSPyInstrumentor
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
Expand All @@ -9,10 +10,13 @@
resource = Resource(attributes={})
tracer_provider = trace_sdk.TracerProvider(resource=resource)
span_console_exporter = ConsoleSpanExporter()
# Logs to the Phoenix Collector if running locally
span_otlp_exporter = OTLPSpanExporter(endpoint="http://127.0.0.1:6006/v1/traces")
tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter=span_console_exporter))
tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter=span_otlp_exporter))
# Logs to the Phoenix Collector if running locally
if os.environ.get("PHOENIX_COLLECTOR_ENDPOINT"):
endpoint = os.environ["PHOENIX_COLLECTOR_ENDPOINT"] + "/v1/traces"
span_otlp_exporter = OTLPSpanExporter(endpoint=endpoint)
tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter=span_otlp_exporter))

trace_api.set_tracer_provider(tracer_provider=tracer_provider)


Expand All @@ -36,6 +40,6 @@ class BasicQA(dspy.Signature):

# Call the predictor on a particular input.
pred = generate_answer(
question="What is the nationality of the chef and restaurateur featured in Restaurant: Impossible?" # noqa: E501
question="What is the capital of the united states?" # noqa: E501
) # noqa: E501
print(f"Predicted Answer: {pred.answer}")
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dspy-ai >= 2.1.0
opentelemetry-sdk
opentelemetry-exporter-otlp
openinference-instrumentation-dspy

0 comments on commit e5b8cc4

Please sign in to comment.