graphiti/graphiti_core/llm_client
Daniel Chalef 90d7757c17
Use OpenAI structured output API for response validation (#1061)
* Use OpenAI structured output API for response validation

Replace prompt-based schema injection with native json_schema response format. This improves token efficiency and reliability by having OpenAI enforce the schema directly instead of embedding it in the prompt message.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add type ignore for response_format to fix pyright error

* Increase OpenAIGenericClient max_tokens to 16K and update docs

- Set default max_tokens to 16384 (16K) for OpenAIGenericClient to better support local models
- Add documentation note clarifying OpenAIGenericClient should be used for Ollama and LM Studio
- Previous default was 8192 (8K)

* Refactor max_tokens override to use constructor parameter pattern

- Add max_tokens parameter to __init__ with 16K default
- Override self.max_tokens after super().__init__() instead of mutating config
- Consistent with OpenAIBaseClient and AnthropicClient patterns
- Avoids unintended config mutation side effects

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-11 06:53:37 -08:00
..
__init__.py Add support for falkordb (#575) 2025-06-13 12:06:57 -04:00
anthropic_client.py Remove JSON indentation from prompts to reduce token usage (#985) 2025-10-06 16:08:43 -07:00
azure_openai_client.py Fix Azure structured completions (#1039) 2025-11-01 18:40:43 -07:00
client.py Add OpenTelemetry distributed tracing support (#982) 2025-10-05 12:26:14 -07:00
config.py Gpt 5 default (#849) 2025-08-21 12:10:57 -04:00
errors.py
gemini_client.py Add OpenTelemetry distributed tracing support (#982) 2025-10-05 12:26:14 -07:00
groq_client.py Refactor imports (#675) 2025-07-05 08:57:07 -07:00
openai_base_client.py feat: MCP Server v1.0.0 - Modular architecture with multi-provider support (#1024) 2025-10-30 22:59:01 -07:00
openai_client.py feat: MCP Server v1.0.0 - Modular architecture with multi-provider support (#1024) 2025-10-30 22:59:01 -07:00
openai_generic_client.py Use OpenAI structured output API for response validation (#1061) 2025-11-11 06:53:37 -08:00
utils.py