Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Update doc with standard example

Abdul Dridiac0ff872207c
diff --git a/docs/api/local_language_model_clients/LlamaCpp.md b/docs/api/local_language_model_clients/LlamaCpp.md
index 699505f70..47120d65b 100644
--- a/docs/api/local_language_model_clients/LlamaCpp.md
+++ b/docs/api/local_language_model_clients/LlamaCpp.md
@@ -39,4 +39,24 @@ After initializing the Llama model, you can interact with it using the `LlamaCpp
import dspy
llamalm = dspy.LlamaCpp(model="llama", llama_model=llm, model_type="chat", temperature=0.4)
+dspy.settings.configure(lm=llamalm)
+
+
+#Define a simple signature for basic question answering
+class BasicQA(dspy.Signature):
+ """Answer questions with short factoid answers."""
+ question = dspy.InputField()
+ answer = dspy.OutputField(desc="often between 1 and 5 words")
+
+#Pass signature to Predict module
+generate_answer = dspy.Predict(BasicQA)
+
+# Call the predictor on a particular input.
+question='What is the color of the sky?'
+pred = generate_answer(question=question)
+
+print(f"Question: {question}")
+print(f"Predicted Answer: {pred.answer}")
+
+
```
\ No newline at end of file