yangdx
7b76211066
Add fallback to AZURE_OPENAI_API_VERSION for embedding API version
2025-11-22 00:14:35 +08:00
yangdx
ffd8da512e
Improve Azure OpenAI compatibility and error handling
...
• Reduce log noise for Azure content filters
• Add default API version fallback
• Change warning to debug log level
• Handle empty choices in streaming
• Better Azure OpenAI integration
2025-11-21 23:51:18 +08:00
yangdx
fafa1791f4
Fix Azure OpenAI model parameter to use deployment name consistently
...
- Use deployment name for Azure API calls
- Fix model param in embed function
- Consistent api_model logic
- Prevent Azure model name conflicts
2025-11-21 23:41:52 +08:00
yangdx
ac9f2574a5
Improve Azure OpenAI wrapper functions with full parameter support
...
• Add missing parameters to wrappers
• Update docstrings for clarity
• Ensure API consistency
• Fix parameter forwarding
• Maintain backward compatibility
2025-11-21 19:24:32 +08:00
yangdx
45f4f82392
Refactor Azure OpenAI client creation to support client_configs merging
...
- Handle None client_configs case
- Merge configs with explicit params
- Override client_configs with params
- Use dict unpacking for client init
- Maintain parameter precedence
2025-11-21 19:14:16 +08:00
yangdx
0c4cba3860
Fix double decoration in azure_openai_embed and document decorator usage
...
• Remove redundant @retry decorator
• Call openai_embed.func directly
• Add detailed decorator documentation
• Prevent double parameter injection
• Fix EmbeddingFunc wrapping issues
2025-11-21 18:03:53 +08:00
yangdx
b46c152306
Fix linting
2025-11-21 17:16:44 +08:00
yangdx
b709f8f869
Consolidate Azure OpenAI implementation into main OpenAI module
...
• Unified OpenAI/Azure client creation
• Azure module now re-exports functions
• Backward compatibility maintained
• Reduced code duplication
2025-11-21 17:12:33 +08:00
yangdx
02fdceb959
Update OpenAI client to use stable API and bump minimum version to 2.0.0
...
- Remove beta prefix from completions.parse
- Update OpenAI dependency to >=2.0.0
- Fix whitespace formatting
- Update all requirement files
- Clean up pyproject.toml dependencies
2025-11-21 12:55:44 +08:00
yangdx
9f69c5bf85
feat: Support structured output parsed from OpenAI
...
Added support for structured output (JSON mode) from the OpenAI API in `openai.py` and `azure_openai.py`.
When `response_format` is used to request structured data, the new logic checks for the `message.parsed` attribute. If it exists, it's serialized into a JSON string as the final content. If not, the code falls back to the existing `message.content` handling, ensuring backward compatibility.
2025-11-21 12:46:31 +08:00
yangdx
c9e1c86e81
Refactor keyword extraction handling to centralize response format logic
...
• Move response format to core function
• Remove duplicate format assignments
• Standardize keyword extraction flow
• Clean up redundant parameter handling
• Improve Azure OpenAI compatibility
2025-11-21 12:10:04 +08:00
yangdx
46ce6d9a13
Fix Azure OpenAI embedding model parameter fallback
...
- Use model param if provided
- Fall back to deployment name
- Fix embedding API call
- Improve parameter handling
2025-11-20 18:20:22 +08:00
Amritpal Singh
30e86fa331
use deployment variable which extracted value from .env file or have default value
2025-11-20 09:00:27 +00:00
yangdx
680e36c6eb
Improve Bedrock error handling with retry logic and custom exceptions
...
• Add specific exception types
• Implement proper retry mechanism
• Better error classification
• Enhanced logging and validation
• Enable embedding retry decorator
2025-11-14 18:51:41 +08:00
yangdx
05852e1ab2
Add max_token_size parameter to embedding function decorators
...
- Add max_token_size=8192 to all embed funcs
- Move siliconcloud to deprecated folder
- Import wrap_embedding_func_with_attrs
- Update EmbeddingFunc docstring
- Fix langfuse import type annotation
2025-11-14 18:41:43 +08:00
yangdx
77ad906d3a
Improve error handling and logging in cloud model detection
2025-11-13 20:41:44 +08:00
LacombeLouis
844537e378
Add a better regex
2025-11-13 12:17:51 +01:00
Louis Lacombe
f7432a260e
Add support for environment variable fallback for API key and default host for cloud models
2025-11-12 16:11:05 +00:00
yangdx
2f16065256
Refactor keyword_extraction from kwargs to explicit parameter
...
• Add keyword_extraction param to functions
• Remove kwargs.pop() calls
• Update function signatures
• Improve parameter documentation
• Make parameter handling consistent
2025-11-09 12:02:17 +08:00
yangdx
88ab73f6ae
HotFix: Restore streaming response in OpenAI LLM
...
The stream and timeout parameters were moved from **kwargs to explicit
parameters in a previous commit, but were not being passed to the OpenAI
API, causing streaming responses to fail and fall back to non-streaming
mode.Fixes the issue where stream=True was being silently ignored, resulting
in unexpected non-streaming behavior.
2025-11-09 11:52:26 +08:00
yangdx
3d9de5ed03
feat: improve Gemini client error handling and retry logic
...
• Add google-api-core dependency
• Add specific exception handling
• Create InvalidResponseError class
• Update retry decorators
• Fix empty response handling
2025-11-08 22:10:09 +08:00
yangdx
de4ed73652
Add Gemini embedding support
...
- Implement gemini_embed function
- Add gemini to embedding binding choices
- Add L2 normalization for dims < 3072
2025-11-08 03:34:30 +08:00
yangdx
f83ea3394e
Add section header comment for Gemini binding options
2025-11-08 02:07:31 +08:00
yangdx
ffeeae4208
refactor: simplify jina embedding dimension handling
2025-11-07 22:09:57 +08:00
yangdx
01b07b2be5
Refactor Jina embedding dimension by changing param to optional with default
2025-11-07 22:04:34 +08:00
yangdx
d8a6355e41
Merge branch 'main' into apply-dim-to-embedding-call
2025-11-07 20:48:22 +08:00
yangdx
33a1482f7f
Add optional embedding dimension parameter control via env var
...
* Add EMBEDDING_SEND_DIM environment variable
* Update Jina/OpenAI embed functions
* Add send_dimensions to EmbeddingFunc
* Auto-inject embedding_dim when enabled
* Add parameter validation warnings
2025-11-07 20:46:40 +08:00
yangdx
fc40a36968
Add timeout support to Gemini LLM and improve parameter handling
...
• Add timeout parameter to Gemini client
• Convert timeout seconds to milliseconds
• Update function signatures consistently
• Add Gemini thinking config example
• Clean up parameter documentation
2025-11-07 15:50:14 +08:00
yangdx
3cb4eae492
Add Chain of Thought support to Gemini LLM integration
...
- Extract thoughts from response parts
- Add COT enable/disable parameter
2025-11-07 15:22:14 +08:00
yangdx
6686edfd35
Update Gemini LLM options: add seed and thinking config, remove MIME type
2025-11-07 14:32:42 +08:00
Yasiru Rangana
d94aae9c5e
Add dimensions parameter support to openai_embed()
2025-11-07 09:55:06 +11:00
yangdx
8c27555358
Fix Gemini response parsing to avoid warnings from non-text parts
2025-11-07 04:00:37 +08:00
yangdx
6e36ff41e1
Fix linting
2025-11-06 16:01:24 +08:00
yangdx
5f49cee20f
Merge branch 'main' into VOXWAVE-FOUNDRY/main
2025-11-06 15:37:35 +08:00
yangdx
10f6e6955f
Improve Langfuse integration and stream response cleanup handling
...
• Check env vars before enabling Langfuse
• Move imports after env check logic
• Handle wrapper client aclose() issues
• Add debug logs for cleanup failures
2025-11-03 13:09:45 +08:00
anouarbm
9495778c2d
refactor: reorder Langfuse import logic for improved clarity
...
Moved logger import before Langfuse block to fix NameError.
2025-11-03 05:27:41 +01:00
anouarbm
626b42bc40
feat: add optional Langfuse observability integration
...
This contribution adds optional Langfuse support for LLM observability and tracing.
Langfuse provides a drop-in replacement for the OpenAI client that automatically
tracks all LLM interactions without requiring code changes.
Features:
- Optional Langfuse integration with graceful fallback
- Automatic LLM request/response tracing
- Token usage tracking
- Latency metrics
- Error tracking
- Zero code changes required for existing functionality
Implementation:
- Modified lightrag/llm/openai.py to conditionally use Langfuse's AsyncOpenAI
- Falls back to standard OpenAI client if Langfuse is not installed
- Logs observability status on import
Configuration:
To enable Langfuse tracing, install the observability extras and set environment variables:
```bash
pip install lightrag-hku[observability]
export LANGFUSE_PUBLIC_KEY="your_public_key"
export LANGFUSE_SECRET_KEY="your_secret_key"
export LANGFUSE_HOST="https://cloud.langfuse.com " # or your self-hosted instance
```
If Langfuse is not installed or environment variables are not set, LightRAG
will use the standard OpenAI client without any functionality changes.
Changes:
- Modified lightrag/llm/openai.py (added optional Langfuse import)
- Updated pyproject.toml with optional 'observability' dependencies
Dependencies (optional):
- langfuse>=3.8.1
2025-11-01 21:40:22 +01:00
Humphry
0b3d31507e
extended to use gemini, sswitched to use gemini-flash-latest
2025-10-20 13:17:16 +03:00
yangdx
a5c05f1b92
Add offline deployment support with cache management and layered deps
...
• Add tiktoken cache downloader CLI
• Add layered offline dependencies
• Add offline requirements files
• Add offline deployment guide
2025-10-11 10:28:14 +08:00
Yasiru Rangana
ae9f4ae73f
fix: Remove trailing whitespace for pre-commit linting
2025-10-09 15:01:53 +11:00
Yasiru Rangana
ec40b17eea
feat: Add token tracking support to openai_embed function
...
- Add optional token_tracker parameter to openai_embed()
- Track prompt_tokens and total_tokens for embedding API calls
- Enables monitoring of embedding token usage alongside LLM calls
- Maintains backward compatibility with existing code
2025-10-08 14:36:08 +11:00
yangdx
b9c37bd937
Fix linting
2025-10-03 02:10:02 +08:00
yangdx
112349ed5b
Modernize type hints and remove Python 3.8 compatibility code
...
• Use collections.abc.AsyncIterator only
• Remove sys.version_info checks
• Use union syntax for None types
• Simplify string emptiness checks
2025-10-02 23:15:42 +08:00
yangdx
42d1d04147
Fix boolean parser problem for for LLM environment variable
...
• Add custom boolean parser for argparse in BindingOptions
2025-09-28 19:23:57 +08:00
yangdx
cff6029508
Ensure COT tags are properly closed in all stream termination scenarios
...
- Add COT closure after stream completion
- Handle COT in exception scenarios
- Add final safety check in finally block
- Prevent unclosed thinking tags
- Log COT closure failures
2025-09-22 00:09:27 +08:00
yangdx
077d9be5d7
Add Deepseek Style Chain of Thought (CoT) Support for OpenAI Compatible LLM providers
...
- Add enable_cot parameter to all LLM APIs
- Implement CoT for OpenAI with <think> tags
- Log warnings for unsupported providers
- Enable CoT in query operations
- Handle streaming and non-streaming CoT
2025-09-09 22:34:36 +08:00
yangdx
451f488f72
Add debug logging for client configs in OpenAI LLM function
2025-09-07 02:29:37 +08:00
yangdx
4b2ef71c25
feat: Add extra_body parameter support for OpenRouter/vLLM compatibility
...
- Enhanced add_args function to handle dict types with JSON parsing
- Added reasoning and extra_body parameters for OpenRouter/vLLM compatibility
- Updated env.example with OpenRouter/vLLM parameter examples
2025-08-21 13:06:28 +08:00
yangdx
aa22772721
Refactor LLM temperature handling to be provider-specific
...
• Remove global temperature parameter
• Add provider-specific temp configs
• Update env example with new settings
• Fix Bedrock temperature handling
• Clean up splash screen display
2025-08-20 23:52:33 +08:00
yangdx
df7bcb1e3d
Add LLM_TIMEOUT configuration for all LLM providers
...
- Add LLM_TIMEOUT env variable
- Apply timeout to all LLM bindings
2025-08-20 23:50:57 +08:00