Skip to content

Commit 4a0fea3

Browse files
authored
Merge pull request #221 from Scale3-Labs/add-weaviate-generate-support
feat: adding weaviate generate query support
2 parents c5b8601 + 28ca4ac commit 4a0fea3

File tree

7 files changed

+1751
-27
lines changed

7 files changed

+1751
-27
lines changed

src/examples/dspy_example/react.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,49 @@
33
import dspy
44

55
# Add the local src folder to the Python path
6-
sys.path.insert(0, os.path.abspath('/Users/karthikkalyanaraman/work/langtrace/langtrace-python-sdk/src'))
6+
sys.path.insert(
7+
0,
8+
os.path.abspath(
9+
"/Users/karthikkalyanaraman/work/langtrace/langtrace-python-sdk/src"
10+
),
11+
)
712

813
# flake8: noqa
914
from langtrace_python_sdk import langtrace, with_langtrace_root_span
15+
1016
langtrace.init()
1117

12-
turbo = dspy.OpenAI(model='gpt-3.5-turbo', max_tokens=250)
18+
turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=250)
1319
dspy.settings.configure(lm=turbo)
1420

15-
colbertv2_wiki17_abstracts = dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
21+
colbertv2_wiki17_abstracts = dspy.ColBERTv2(
22+
url="http://20.102.90.50:2017/wiki17_abstracts"
23+
)
1624
dspy.settings.configure(rm=colbertv2_wiki17_abstracts)
1725
retriever = dspy.Retrieve(k=3)
1826

27+
1928
# Define a simple signature for basic question answering
2029
class BasicQA(dspy.Signature):
2130
"""Answer questions with short factoid answers."""
31+
2232
question = dspy.InputField()
2333
answer = dspy.OutputField(desc="often between 1 and 5 words")
2434

35+
2536
@with_langtrace_root_span(name="react_example")
2637
def example():
2738

2839
# Pass signature to ReAct module
2940
react_module = dspy.ReAct(BasicQA)
3041

3142
# Call the ReAct module on a particular input
32-
question = 'Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?'
43+
question = "Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?"
3344
result = react_module(question=question)
3445

3546
print(f"Question: {question}")
3647
print(f"Final Predicted Answer (after ReAct process): {result.answer}")
3748

38-
if __name__ == '__main__':
49+
50+
if __name__ == "__main__":
3951
example()

0 commit comments

Comments
 (0)