Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
pip install traceAI-DSPy dspy
import os
os.environ["OPENAI_API_KEY"] = "your-openai-api-key"
os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="dspy_project",
)
from traceai_dspy import DSPyInstrumentor
DSPyInstrumentor().instrument(tracer_provider=trace_provider)
import dspy
class BasicQA(dspy.Signature):
"""Answer questions with short factoid answers."""
question = dspy.InputField()
answer = dspy.OutputField(desc="often between 1 and 5 words")
if __name__ == "__main__":
turbo = dspy.LM(model="openai/gpt-4")
dspy.settings.configure(lm=turbo)
# Define the predictor.
generate_answer = dspy.Predict(BasicQA)
# Call the predictor on a particular input.
pred = generate_answer(question="What is the capital of the united states?")
print(f"Predicted Answer: {pred.answer}")
Was this page helpful?