graphiti/graphiti_core/llm_client
Daniel Chalef 189e45617f
Add group_id parameter to language extraction function (#952)
* Add group_id parameter to get_extraction_language_instruction

Enable consumers to provide group-specific language extraction
instructions by passing group_id through the call chain.

Changes:
- Add optional group_id parameter to get_extraction_language_instruction()
- Add group_id parameter to all LLMClient.generate_response() methods
- Pass group_id through to language instruction function
- Maintain backward compatibility with default None value

Users can now customize extraction per group:
```python
def custom_instruction(group_id: str | None = None) -> str:
    if group_id == 'spanish-users':
        return '\n\nExtract in Spanish.'
    return '\n\nExtract in original language.'

client.get_extraction_language_instruction = custom_instruction
```

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

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

* Pass group_id to generate_response in extraction operations

Thread group_id parameter through all extraction-related generate_response()
calls where it's naturally available (via episode.group_id or node.group_id).
This enables consumers to override get_extraction_language_instruction() with
group-specific language preferences.

Changes:
- edge_operations.py: Pass group_id in extract_edges()
- node_operations.py: Pass episode.group_id in extract_nodes() and
  node.group_id in extract_attributes_from_node()
- node_operations.py: Add group_id parameter to extract_nodes_reflexion()

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

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

* Fix type inconsistency in extract_nodes_reflexion parameter

Change group_id parameter from str = '' to str | None = None to match
the pattern used throughout the codebase and align with the optional
nature of group_id in generate_response().

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

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

* Remove ensure_ascii parameter and uv.lock file

* Reset uv.lock to main branch version

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-03 09:05:45 -07:00
..
__init__.py Add support for falkordb (#575) 2025-06-13 12:06:57 -04:00
anthropic_client.py Refactor imports (#675) 2025-07-05 08:57:07 -07:00
azure_openai_client.py Azure OpenAI improvements and fixes; Improve Graphiti Azure OpenAI config (#620) 2025-06-25 14:48:12 -04:00
client.py Add group_id parameter to language extraction function (#952) 2025-10-03 09:05:45 -07:00
config.py Gpt 5 default (#849) 2025-08-21 12:10:57 -04:00
errors.py Anthropic client (#361) 2025-04-16 12:35:07 -07:00
gemini_client.py Add group_id parameter to language extraction function (#952) 2025-10-03 09:05:45 -07:00
groq_client.py Refactor imports (#675) 2025-07-05 08:57:07 -07:00
openai_base_client.py Add group_id parameter to language extraction function (#952) 2025-10-03 09:05:45 -07:00
openai_client.py Gpt 5 default (#849) 2025-08-21 12:10:57 -04:00
openai_generic_client.py Add group_id parameter to language extraction function (#952) 2025-10-03 09:05:45 -07:00
utils.py update new names with input_data (#204) 2024-10-29 11:03:31 -04:00