langtrace-python-sdk 2.1.23__py3-none-any.whl → 2.1.25__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- examples/dspy_example/react.py +17 -5
- examples/weaviate_example/query_text.py +1659 -0
- langtrace_python_sdk/constants/instrumentation/ollama.py +3 -5
- langtrace_python_sdk/constants/instrumentation/weaviate.py +30 -0
- langtrace_python_sdk/instrumentation/dspy/patch.py +12 -12
- langtrace_python_sdk/instrumentation/ollama/patch.py +22 -7
- langtrace_python_sdk/instrumentation/openai/patch.py +37 -14
- langtrace_python_sdk/instrumentation/weaviate/instrumentation.py +1 -1
- langtrace_python_sdk/instrumentation/weaviate/patch.py +2 -1
- langtrace_python_sdk/version.py +1 -1
- {langtrace_python_sdk-2.1.23.dist-info → langtrace_python_sdk-2.1.25.dist-info}/METADATA +1 -1
- {langtrace_python_sdk-2.1.23.dist-info → langtrace_python_sdk-2.1.25.dist-info}/RECORD +15 -15
- {langtrace_python_sdk-2.1.23.dist-info → langtrace_python_sdk-2.1.25.dist-info}/WHEEL +0 -0
- {langtrace_python_sdk-2.1.23.dist-info → langtrace_python_sdk-2.1.25.dist-info}/entry_points.txt +0 -0
- {langtrace_python_sdk-2.1.23.dist-info → langtrace_python_sdk-2.1.25.dist-info}/licenses/LICENSE +0 -0
examples/dspy_example/react.py
CHANGED
|
@@ -3,25 +3,36 @@ import os
|
|
|
3
3
|
import dspy
|
|
4
4
|
|
|
5
5
|
# Add the local src folder to the Python path
|
|
6
|
-
sys.path.insert(
|
|
6
|
+
sys.path.insert(
|
|
7
|
+
0,
|
|
8
|
+
os.path.abspath(
|
|
9
|
+
"/Users/karthikkalyanaraman/work/langtrace/langtrace-python-sdk/src"
|
|
10
|
+
),
|
|
11
|
+
)
|
|
7
12
|
|
|
8
13
|
# flake8: noqa
|
|
9
14
|
from langtrace_python_sdk import langtrace, with_langtrace_root_span
|
|
15
|
+
|
|
10
16
|
langtrace.init()
|
|
11
17
|
|
|
12
|
-
turbo = dspy.OpenAI(model=
|
|
18
|
+
turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=250)
|
|
13
19
|
dspy.settings.configure(lm=turbo)
|
|
14
20
|
|
|
15
|
-
colbertv2_wiki17_abstracts = dspy.ColBERTv2(
|
|
21
|
+
colbertv2_wiki17_abstracts = dspy.ColBERTv2(
|
|
22
|
+
url="http://20.102.90.50:2017/wiki17_abstracts"
|
|
23
|
+
)
|
|
16
24
|
dspy.settings.configure(rm=colbertv2_wiki17_abstracts)
|
|
17
25
|
retriever = dspy.Retrieve(k=3)
|
|
18
26
|
|
|
27
|
+
|
|
19
28
|
# Define a simple signature for basic question answering
|
|
20
29
|
class BasicQA(dspy.Signature):
|
|
21
30
|
"""Answer questions with short factoid answers."""
|
|
31
|
+
|
|
22
32
|
question = dspy.InputField()
|
|
23
33
|
answer = dspy.OutputField(desc="often between 1 and 5 words")
|
|
24
34
|
|
|
35
|
+
|
|
25
36
|
@with_langtrace_root_span(name="react_example")
|
|
26
37
|
def example():
|
|
27
38
|
|
|
@@ -29,11 +40,12 @@ def example():
|
|
|
29
40
|
react_module = dspy.ReAct(BasicQA)
|
|
30
41
|
|
|
31
42
|
# Call the ReAct module on a particular input
|
|
32
|
-
question =
|
|
43
|
+
question = "Aside from the Apple Remote, what other devices can control the program Apple Remote was originally designed to interact with?"
|
|
33
44
|
result = react_module(question=question)
|
|
34
45
|
|
|
35
46
|
print(f"Question: {question}")
|
|
36
47
|
print(f"Final Predicted Answer (after ReAct process): {result.answer}")
|
|
37
48
|
|
|
38
|
-
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
39
51
|
example()
|