feat(tests): make inference_recorder into api_recorder (include tool_invoke) (#3403)

Renames `inference_recorder.py` to `api_recorder.py` and extends it to
support recording/replaying tool invocations in addition to inference
calls.

This allows us to record web-search, etc. tool calls and thereafter
apply recordings for `tests/integration/responses`

## Test Plan

```
export OPENAI_API_KEY=...
export TAVILY_SEARCH_API_KEY=...

./scripts/integration-tests.sh --stack-config ci-tests \
   --suite responses --inference-mode record-if-missing
```
This commit is contained in:
Ashwin Bharambe 2025-10-09 14:27:51 -07:00 committed by GitHub
parent 26fd5dbd34
commit f50ce11a3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
284 changed files with 296191 additions and 631 deletions

View file

@ -7,7 +7,7 @@
import time
def new_vector_store(openai_client, name):
def new_vector_store(openai_client, name, embedding_model, embedding_dimension):
"""Create a new vector store, cleaning up any existing one with the same name."""
# Ensure we don't reuse an existing vector store
vector_stores = openai_client.vector_stores.list()
@ -16,7 +16,21 @@ def new_vector_store(openai_client, name):
openai_client.vector_stores.delete(vector_store_id=vector_store.id)
# Create a new vector store
vector_store = openai_client.vector_stores.create(name=name)
# OpenAI SDK client uses extra_body for non-standard parameters
from openai import OpenAI
if isinstance(openai_client, OpenAI):
# OpenAI SDK client - use extra_body
vector_store = openai_client.vector_stores.create(
name=name,
extra_body={"embedding_model": embedding_model, "embedding_dimension": embedding_dimension},
)
else:
# LlamaStack client - direct parameter
vector_store = openai_client.vector_stores.create(
name=name, embedding_model=embedding_model, embedding_dimension=embedding_dimension
)
return vector_store