5. Create DSPy Components and Run your application
Run DSPy as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform.
Copy
Ask AI
import dspyclass 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}")