Skip to content

Commit add8b1f

Browse files
authored
Add tomtom intagration (refs in path params) (vblagoje#2)
1 parent 044ad6f commit add8b1f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ env:
3434
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
3535
FIRECRAWL_API_KEY: ${{ secrets.FIRECRAWL_API_KEY }}
3636
SERPERDEV_API_KEY: ${{ secrets.SERPERDEV_API_KEY }}
37+
TOMTOM_API_KEY: ${{ secrets.TOMTOM_API_KEY }}
3738
HF_API_TOKEN: ${{ secrets.HF_API_TOKEN }}
3839
OLLAMA_LLM_FOR_TESTS: "llama3.2:3b"
3940

test/test_openapi_client_live_openai.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,31 @@ def test_firecrawl(self):
128128
assert service_response.get("success", False), "Firecrawl search API call failed"
129129
assert len(service_response.get("data", [])) == top_k
130130
assert "Sam" in str(service_response)
131+
132+
@pytest.mark.integration
133+
@pytest.mark.skipif(not os.environ.get("OPENAI_API_KEY", ""), reason="OPENAI_API_KEY not set or empty")
134+
@pytest.mark.skipif(not os.environ.get("TOMTOM_API_KEY", ""), reason="TOMTOM_API_KEY not set or empty")
135+
def test_tomtom(self, test_files_path):
136+
137+
# LLM can't accept the original operation name with {} and other special characters,
138+
# so we need to normalize it, see normalize_operation_name in utils.py
139+
target_operation = "search_versionNumber_categorySearch_query_ext__get"
140+
spec="https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/tomtom.com/search/1.0.0/openapi.yaml"
141+
config = ClientConfig(openapi_spec=create_openapi_spec(spec),
142+
credentials=os.getenv("TOMTOM_API_KEY"),
143+
allowed_operations=["search_versionNumber_categorySearch_query_ext__get"])
144+
145+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
146+
response = client.chat.completions.create(
147+
model="gpt-4o",
148+
messages=[{"role": "user", "content": "Search for pizza in San Francisco, US and don't use long/lat"}],
149+
tools=config.get_tool_definitions(),
150+
)
151+
api = OpenAPIClient(config)
152+
service_response = api.invoke(response)
153+
154+
# verify that we get some valid response
155+
assert isinstance(service_response, dict)
156+
assert "pizza" in str(service_response)
157+
assert "summary" in str(service_response)
158+
assert "countrySubdivisionCode" in str(service_response)

0 commit comments

Comments
 (0)