Skip to content

Commit 6f3e131

Browse files
authored
test: address tests failing locally (#537)
* test: address tests failing locally Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> * fix: fix macos mypy error Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> * test: address review and changes in main Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> --------- Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
1 parent d8dc1a3 commit 6f3e131

12 files changed

Lines changed: 485 additions & 70 deletions

File tree

docs/examples/agents/react/react_from_scratch/react.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pytest: ollama, llm
1+
# pytest: ollama, llm, qualitative
22

33
import datetime
44
import inspect
@@ -92,7 +92,7 @@ def tool_name_schema(self):
9292
def get_tool_from_schema(self, content: str):
9393
schema = self.tool_name_schema()
9494
validated = schema.model_validate_json(content)
95-
return self.get_tool_from_name(validated.tool)
95+
return self.get_tool_from_name(validated.tool.value)
9696

9797

9898
class IsDoneModel(pydantic.BaseModel):

docs/examples/agents/react/react_from_scratch/react_instruct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pytest: ollama, llm
1+
# pytest: ollama, llm, qualitative
22

33
import datetime
44
import inspect
@@ -89,7 +89,7 @@ def tool_name_schema(self):
8989
def get_tool_from_schema(self, content: str):
9090
schema = self.tool_name_schema()
9191
validated = schema.model_validate_json(content)
92-
return self.get_tool_from_name(validated.tool)
92+
return self.get_tool_from_name(validated.tool.value)
9393

9494

9595
class IsDoneModel(pydantic.BaseModel):

docs/examples/agents/react/react_using_mellea.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# pytest: ollama, llm
2+
13
"""React examples using the Mellea library's framework."""
24

35
import asyncio
@@ -12,7 +14,7 @@
1214

1315
m = start_session()
1416

15-
# Simple tool for searching. Requires the langchain_communities package.
17+
# Simple tool for searching. Requires the langchain-community package.
1618
# Mellea allows you to interop with langchain defined tools.
1719
lc_ddg_search = DuckDuckGoSearchResults(output_format="list")
1820
search_tool = MelleaTool.from_langchain(lc_ddg_search)

docs/examples/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ def _check_optional_imports(file_path):
164164
except ImportError:
165165
return True, "langchain_core not installed"
166166

167+
# Check for langchain_community specifically
168+
if (
169+
"from langchain_community" in content
170+
or "import langchain_community" in content
171+
):
172+
try:
173+
import langchain_community
174+
except ImportError:
175+
return (
176+
True,
177+
"langchain_community not installed (install with: uv pip install mellea[tools])",
178+
)
179+
167180
except Exception:
168181
pass
169182

docs/examples/image_text_models/vision_litellm_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pytest: litellm, llm
1+
# pytest: litellm, llm, ollama
22

33
"""Examples of using vision models with LiteLLM backend."""
44

docs/examples/library_interop/langchain_messages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pytest: ollama, llm
1+
# pytest: ollama, llm, qualitative
22

33
# Installing langchain is necessary for this example, but it works for any library
44
# you may want to use Mellea with.
@@ -37,9 +37,9 @@
3737
# Utilize that new ChatContext to ask the assistant about its past messages.
3838
m = start_session(ctx=ctx)
3939
response = m.chat(
40-
"What was the last assistant message?",
40+
"What exact words did the AI assistant use in its most recent response?",
4141
model_options={
42-
ModelOption.SEED: 2
42+
ModelOption.SEED: 123
4343
}, # Utilizing a seed for consistency in the example.
4444
).content
4545

docs/examples/m_decompose/python/python_decompose_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pytest: ollama, llm, slow
1+
# pytest: ollama, llm, slow, qualitative
22
#!/usr/bin/env python3
33
"""
44
Example: Using Mellea's decompose functionality programmatically

docs/examples/telemetry/telemetry_example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# pytest: ollama, llm
2+
13
"""Example demonstrating OpenTelemetry tracing in Mellea.
24
35
This example shows how to use the two independent trace scopes:

docs/examples/tools/smolagents_example.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@
3636
print(f"Response: {result}")
3737

3838
if result.tool_calls:
39-
calc_result = result.tool_calls[python_tool.name].call_func()
40-
print(f"\nCalculation result: {calc_result}")
39+
try:
40+
calc_result = result.tool_calls[python_tool.name].call_func()
41+
print(f"\nCalculation result: {calc_result}")
42+
except Exception as e:
43+
print(f"\nTool execution failed: {e}")
4144

4245
except ImportError as e:
4346
print("Please install smolagents: uv pip install 'mellea[smolagents]'")

pyproject.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ docling = [
8484
"docling>=2.45.0",
8585
]
8686

87-
smolagents = [
87+
tools = [
8888
"smolagents>=1.0.0",
89+
"langchain-community>=0.3.0",
90+
"ddgs>=9.0.0", # Required by DuckDuckGoSearchResults in langchain-community
8991
]
9092

9193
telemetry = [
@@ -95,7 +97,7 @@ telemetry = [
9597
"opentelemetry-distro>=0.59b0",
9698
]
9799

98-
all = ["mellea[watsonx,docling,hf,vllm,litellm,smolagents,telemetry]"]
100+
all = ["mellea[watsonx,docling,hf,vllm,litellm,tools,telemetry]"]
99101

100102
[dependency-groups]
101103
# Use these like:
@@ -203,6 +205,13 @@ disable_error_code = [
203205
"import-not-found",
204206
]
205207

208+
[[tool.mypy.overrides]]
209+
# vLLM is an optional backend that doesn't work on macOS
210+
module = "mellea.backends.vllm"
211+
disable_error_code = [
212+
"import-not-found",
213+
]
214+
206215
[tool.codespell]
207216
ignore-words-list = 'mellea,hashi,noo,Asai,asai,nd,mot,rouge,Rouge,Strat,Wight'
208217
check-filenames = true

0 commit comments

Comments
 (0)