SimplerLLM 0.3.2.7__tar.gz → 0.3.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/PKG-INFO +1 -1
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/__init__.py +2 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/base.py +4 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/reliable.py +10 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/__init__.py +2 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/anthropic_wrapper.py +78 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/openai_wrapper.py +78 -0
- simplerllm-0.3.3.0/SimplerLLM/language/llm/wrappers/perplexity_wrapper.py +222 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_addons.py +14 -2
- simplerllm-0.3.3.0/SimplerLLM/language/llm_providers/anthropic_llm.py +368 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/llm_response_models.py +1 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/openai_llm.py +143 -0
- simplerllm-0.3.3.0/SimplerLLM/language/llm_providers/perplexity_llm.py +231 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM.egg-info/PKG-INFO +1 -1
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM.egg-info/SOURCES.txt +11 -1
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/setup.py +1 -1
- simplerllm-0.3.3.0/tests/test_anthropic_web_search.py +53 -0
- simplerllm-0.3.3.0/tests/test_llm_providers.py +69 -0
- simplerllm-0.3.3.0/tests/test_perplexity_pydantic.py +49 -0
- simplerllm-0.3.3.0/tests/test_perplexity_web_search.py +32 -0
- simplerllm-0.3.3.0/tests/test_pydantic_vision.py +119 -0
- simplerllm-0.3.3.0/tests/test_reliable_fix.py +60 -0
- simplerllm-0.3.3.0/tests/test_reliable_vision.py +186 -0
- simplerllm-0.3.3.0/tests/test_web_search_pydantic.py +50 -0
- simplerllm-0.3.2.7/SimplerLLM/language/llm_providers/anthropic_llm.py +0 -187
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/LICENSE +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/README.md +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/base.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/providers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/providers/google_image.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/providers/image_response_models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/providers/openai_image.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/providers/stability_image.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/wrappers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/wrappers/google_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/wrappers/openai_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/image/generation/wrappers/stability_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/embeddings.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/flow/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/flow/flow.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/flow/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/flow/tool_registry.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/base.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/exceptions.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/input_guardrails/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/input_guardrails/pii_detection.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/input_guardrails/prompt_injection.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/input_guardrails/topic_filter.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/output_guardrails/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/output_guardrails/content_safety.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/output_guardrails/format_validator.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/output_guardrails/length_validator.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/output_guardrails/pii_detection.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/guardrails/wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/cohere_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/deepseek_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/gemini_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/ollama_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/openrouter_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_brainstorm/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_brainstorm/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_brainstorm/recursive_brainstorm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_clustering/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_clustering/chunk_store.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_clustering/clusterer.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_clustering/flat_clusterer.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_clustering/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_clustering/persistence.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_clustering/tree_builder.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_feedback/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_feedback/feedback_loop.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_feedback/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_judge/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_judge/judge.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_judge/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_provider_router/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_provider_router/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_provider_router/provider_router.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_provider_router/query_classifier.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/cohere_llm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/deepseek_llm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/gemini_llm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/ollama_llm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/openrouter_llm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_providers/voyage_llm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_retrieval/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_retrieval/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_retrieval/retriever.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_router/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_router/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm_router/router.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/prompts/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/prompts/hub/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/prompts/hub/agentic_prompts.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/prompts/hub/prompt_manager.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/prompts/messages_template.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/prompts/prompt_builder.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/apify_api.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/brainstorm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/email_functions.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/file_functions.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/file_loader.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/generic_loader.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/image_helpers.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/json_helpers.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/pandas_func.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/pattern_helpers.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/python_func.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/rapid_api.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/serp.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/text_chunker.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/tools/youtube.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/utils/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/utils/custom_verbose.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/vectors/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/vectors/local_vector_db.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/vectors/qdrant_vector_db.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/vectors/simpler_vector.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/vectors/vector_db.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/vectors/vector_providers.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/dialogue_generator/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/dialogue_generator/audio_merger.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/dialogue_generator/dialogue_generator.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/dialogue_generator/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/live_voice_chat/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/live_voice_chat/audio_player.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/live_voice_chat/audio_recorder.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/live_voice_chat/live_voice_chat.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/live_voice_chat/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/audio_utils.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/base.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/providers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/providers/elevenlabs_convai.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/providers/openai_realtime.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/providers/realtime_response_models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/realtime_voice_chat.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/wrappers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/wrappers/elevenlabs_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/realtime_voice/wrappers/openai_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/stt/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/stt/base.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/stt/providers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/stt/providers/openai_stt.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/stt/providers/stt_response_models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/stt/wrappers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/stt/wrappers/openai_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/base.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/providers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/providers/elevenlabs_tts.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/providers/openai_tts.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/providers/tts_response_models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/wrappers/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/wrappers/elevenlabs_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/tts/wrappers/openai_wrapper.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_dubbing/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_dubbing/audio_sync.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_dubbing/base.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_dubbing/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_dubbing/video_processor.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_transcription/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_transcription/base.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_transcription/caption_generator.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_transcription/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_transcription/utils/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_transcription/utils/subtitle_formatter.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/video_transcription/utils/video_utils.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/voice_chat/__init__.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/voice_chat/conversation.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/voice_chat/models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/voice/voice_chat/voice_chat.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM.egg-info/dependency_links.txt +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM.egg-info/requires.txt +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM.egg-info/top_level.txt +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/setup.cfg +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_agent.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_agent_full.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_cohere.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_cohere_embeddings.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_comprehensive_llm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_embeddings_comprehensive.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_flow_comprehensive.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_llm_brainstorm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_llm_clustering_retrieval.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_llm_feedback.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_llm_judge.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_llm_provider_router.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_nested_models.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_openrouter.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_openrouter_full_response.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_pattern_extraction.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_pattern_helpers.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_production_vector_db.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_pydantic_edge_cases.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_pydantic_edge_cases_llm.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_pydantic_structures.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_qdrant_comprehensive.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_qdrant_connection.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_qdrant_integration_live.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_real_llm_generation.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_router_simple.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_router_youtube_titles.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_unified_vector_interface.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_vision_anthropic.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_vision_openai.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_vision_quick.py +0 -0
- {simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/tests/test_voyage_embeddings.py +0 -0
|
@@ -5,6 +5,7 @@ from .wrappers.gemini_wrapper import GeminiLLM
|
|
|
5
5
|
from .wrappers.anthropic_wrapper import AnthropicLLM
|
|
6
6
|
from .wrappers.ollama_wrapper import OllamaLLM
|
|
7
7
|
from .wrappers.deepseek_wrapper import DeepSeekLLM
|
|
8
|
+
from .wrappers.perplexity_wrapper import PerplexityLLM
|
|
8
9
|
|
|
9
10
|
__all__ = [
|
|
10
11
|
'LLM',
|
|
@@ -16,4 +17,5 @@ __all__ = [
|
|
|
16
17
|
'AnthropicLLM',
|
|
17
18
|
'OllamaLLM',
|
|
18
19
|
'DeepSeekLLM',
|
|
20
|
+
'PerplexityLLM',
|
|
19
21
|
]
|
|
@@ -22,6 +22,7 @@ class LLMProvider(Enum):
|
|
|
22
22
|
DEEPSEEK = 6
|
|
23
23
|
OPENROUTER = 7
|
|
24
24
|
COHERE = 8
|
|
25
|
+
PERPLEXITY = 9
|
|
25
26
|
|
|
26
27
|
class LLM:
|
|
27
28
|
def __init__(
|
|
@@ -77,6 +78,9 @@ class LLM:
|
|
|
77
78
|
if provider == LLMProvider.COHERE:
|
|
78
79
|
from .wrappers.cohere_wrapper import CohereLLM
|
|
79
80
|
return CohereLLM(provider, model_name, temperature, top_p, api_key, verbose=verbose)
|
|
81
|
+
if provider == LLMProvider.PERPLEXITY:
|
|
82
|
+
from .wrappers.perplexity_wrapper import PerplexityLLM
|
|
83
|
+
return PerplexityLLM(provider, model_name, temperature, top_p, api_key, verbose=verbose)
|
|
80
84
|
else:
|
|
81
85
|
return None
|
|
82
86
|
|
|
@@ -96,6 +96,7 @@ class ReliableLLM:
|
|
|
96
96
|
json_mode=False,
|
|
97
97
|
images: list = None,
|
|
98
98
|
detail: str = "auto",
|
|
99
|
+
web_search: bool = False,
|
|
99
100
|
) -> Union[str, LLMFullResponse, Tuple[Union[str, LLMFullResponse], LLMProvider, str]]:
|
|
100
101
|
"""
|
|
101
102
|
Generate a response using the primary LLM, falling back to secondary if primary fails.
|
|
@@ -113,6 +114,7 @@ class ReliableLLM:
|
|
|
113
114
|
json_mode (bool, optional): If True, enables JSON mode for structured output.
|
|
114
115
|
images (list, optional): A list of image URLs or file paths for vision tasks.
|
|
115
116
|
detail (str, optional): Level of detail for image analysis ("low", "high", "auto"). OpenAI-specific parameter. Defaults to "auto".
|
|
117
|
+
web_search (bool, optional): If True, enables web search before generating response. OpenAI-specific parameter. Defaults to False.
|
|
116
118
|
|
|
117
119
|
Returns:
|
|
118
120
|
Union[str, dict, Tuple[Union[str, dict], LLMProvider, str]]:
|
|
@@ -138,6 +140,7 @@ class ReliableLLM:
|
|
|
138
140
|
json_mode=json_mode,
|
|
139
141
|
images=images,
|
|
140
142
|
detail=detail,
|
|
143
|
+
web_search=web_search,
|
|
141
144
|
)
|
|
142
145
|
if self.verbose:
|
|
143
146
|
verbose_print("Primary provider generated response successfully", "info")
|
|
@@ -159,6 +162,7 @@ class ReliableLLM:
|
|
|
159
162
|
json_mode=json_mode,
|
|
160
163
|
images=images,
|
|
161
164
|
detail=detail,
|
|
165
|
+
web_search=web_search,
|
|
162
166
|
)
|
|
163
167
|
if self.verbose:
|
|
164
168
|
verbose_print("Secondary provider generated response successfully", "info")
|
|
@@ -181,6 +185,7 @@ class ReliableLLM:
|
|
|
181
185
|
json_mode=json_mode,
|
|
182
186
|
images=images,
|
|
183
187
|
detail=detail,
|
|
188
|
+
web_search=web_search,
|
|
184
189
|
)
|
|
185
190
|
if self.verbose:
|
|
186
191
|
verbose_print("Secondary provider generated response successfully", "info")
|
|
@@ -203,6 +208,7 @@ class ReliableLLM:
|
|
|
203
208
|
json_mode: bool = False,
|
|
204
209
|
images: list = None,
|
|
205
210
|
detail: str = "auto",
|
|
211
|
+
web_search: bool = False,
|
|
206
212
|
) -> Union[str, LLMFullResponse, Tuple[Union[str, LLMFullResponse], LLMProvider, str]]:
|
|
207
213
|
"""
|
|
208
214
|
Asynchronously generate a response using the primary LLM, falling back to secondary if primary fails.
|
|
@@ -220,6 +226,7 @@ class ReliableLLM:
|
|
|
220
226
|
json_mode (bool, optional): If True, enables JSON mode for structured output.
|
|
221
227
|
images (list, optional): A list of image URLs or file paths for vision tasks.
|
|
222
228
|
detail (str, optional): Level of detail for image analysis ("low", "high", "auto"). OpenAI-specific parameter. Defaults to "auto".
|
|
229
|
+
web_search (bool, optional): If True, enables web search before generating response. OpenAI-specific parameter. Defaults to False.
|
|
223
230
|
|
|
224
231
|
Returns:
|
|
225
232
|
Union[str, dict, Tuple[Union[str, dict], LLMProvider, str]]:
|
|
@@ -245,6 +252,7 @@ class ReliableLLM:
|
|
|
245
252
|
json_mode=json_mode,
|
|
246
253
|
images=images,
|
|
247
254
|
detail=detail,
|
|
255
|
+
web_search=web_search,
|
|
248
256
|
)
|
|
249
257
|
if self.verbose:
|
|
250
258
|
verbose_print("Primary provider generated response successfully", "info")
|
|
@@ -266,6 +274,7 @@ class ReliableLLM:
|
|
|
266
274
|
json_mode=json_mode,
|
|
267
275
|
images=images,
|
|
268
276
|
detail=detail,
|
|
277
|
+
web_search=web_search,
|
|
269
278
|
)
|
|
270
279
|
if self.verbose:
|
|
271
280
|
verbose_print("Secondary provider generated response successfully", "info")
|
|
@@ -288,6 +297,7 @@ class ReliableLLM:
|
|
|
288
297
|
json_mode=json_mode,
|
|
289
298
|
images=images,
|
|
290
299
|
detail=detail,
|
|
300
|
+
web_search=web_search,
|
|
291
301
|
)
|
|
292
302
|
if self.verbose:
|
|
293
303
|
verbose_print("Secondary provider generated response successfully", "info")
|
|
@@ -4,6 +4,7 @@ from .anthropic_wrapper import AnthropicLLM
|
|
|
4
4
|
from .ollama_wrapper import OllamaLLM
|
|
5
5
|
from .deepseek_wrapper import DeepSeekLLM
|
|
6
6
|
from .cohere_wrapper import CohereLLM
|
|
7
|
+
from .perplexity_wrapper import PerplexityLLM
|
|
7
8
|
|
|
8
9
|
__all__ = [
|
|
9
10
|
'OpenAILLM',
|
|
@@ -12,4 +13,5 @@ __all__ = [
|
|
|
12
13
|
'OllamaLLM',
|
|
13
14
|
'DeepSeekLLM',
|
|
14
15
|
'CohereLLM',
|
|
16
|
+
'PerplexityLLM',
|
|
15
17
|
]
|
{simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/anthropic_wrapper.py
RENAMED
|
@@ -29,6 +29,7 @@ class AnthropicLLM(LLM):
|
|
|
29
29
|
cached_input: str = "",
|
|
30
30
|
json_mode=False,
|
|
31
31
|
images: list = None,
|
|
32
|
+
web_search: bool = False,
|
|
32
33
|
):
|
|
33
34
|
"""
|
|
34
35
|
Generate a response using the Anthropic LLM.
|
|
@@ -46,6 +47,7 @@ class AnthropicLLM(LLM):
|
|
|
46
47
|
cached_input (str, optional): The cached input to use if prompt_caching is True. Defaults to "".
|
|
47
48
|
json_mode (bool, optional): If True, enables JSON mode. Defaults to False.
|
|
48
49
|
images (list, optional): List of image sources (URLs or file paths) for vision-capable models. Defaults to None.
|
|
50
|
+
web_search (bool, optional): If True, enables web search before generating response. Defaults to False.
|
|
49
51
|
|
|
50
52
|
Returns:
|
|
51
53
|
The generated response from the Anthropic LLM.
|
|
@@ -53,6 +55,43 @@ class AnthropicLLM(LLM):
|
|
|
53
55
|
Raises:
|
|
54
56
|
ValueError: If both prompt and messages are provided, or if neither is provided.
|
|
55
57
|
"""
|
|
58
|
+
# Handle web search mode
|
|
59
|
+
if web_search:
|
|
60
|
+
if not prompt and not messages:
|
|
61
|
+
raise ValueError("Either 'prompt' or 'messages' must be provided.")
|
|
62
|
+
|
|
63
|
+
effective_model = model_name if model_name else self.model_name
|
|
64
|
+
|
|
65
|
+
# Prepare messages for web search
|
|
66
|
+
if prompt:
|
|
67
|
+
if images:
|
|
68
|
+
user_content = prepare_vision_content_anthropic(prompt, images)
|
|
69
|
+
else:
|
|
70
|
+
user_content = prompt
|
|
71
|
+
model_messages = [{"role": "user", "content": user_content}]
|
|
72
|
+
else:
|
|
73
|
+
model_messages = self.append_messages(messages)
|
|
74
|
+
|
|
75
|
+
if self.verbose:
|
|
76
|
+
verbose_print(f"Generating response with web search using {effective_model}...", "info")
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
response = anthropic_llm.generate_response_with_web_search(
|
|
80
|
+
model_name=effective_model,
|
|
81
|
+
system_prompt=system_prompt,
|
|
82
|
+
messages=model_messages,
|
|
83
|
+
max_tokens=max_tokens,
|
|
84
|
+
full_response=full_response,
|
|
85
|
+
api_key=self.api_key,
|
|
86
|
+
)
|
|
87
|
+
if self.verbose:
|
|
88
|
+
verbose_print("Web search response received successfully", "info")
|
|
89
|
+
return response
|
|
90
|
+
except Exception as e:
|
|
91
|
+
if self.verbose:
|
|
92
|
+
verbose_print(f"Error generating web search response: {str(e)}", "error")
|
|
93
|
+
raise
|
|
94
|
+
|
|
56
95
|
params = self.prepare_params(model_name, temperature, top_p)
|
|
57
96
|
|
|
58
97
|
# Validate inputs
|
|
@@ -130,6 +169,7 @@ class AnthropicLLM(LLM):
|
|
|
130
169
|
cached_input: str = "",
|
|
131
170
|
json_mode=False,
|
|
132
171
|
images: list = None,
|
|
172
|
+
web_search: bool = False,
|
|
133
173
|
):
|
|
134
174
|
"""
|
|
135
175
|
Asynchronously generate a response from the Anthropic LLM.
|
|
@@ -147,6 +187,7 @@ class AnthropicLLM(LLM):
|
|
|
147
187
|
cached_input (str, optional): The cached input to use. Defaults to "".
|
|
148
188
|
json_mode (bool, optional): If True, enables JSON mode. Defaults to False.
|
|
149
189
|
images (list, optional): List of image sources (URLs or file paths) for vision-capable models. Defaults to None.
|
|
190
|
+
web_search (bool, optional): If True, enables web search before generating response. Defaults to False.
|
|
150
191
|
|
|
151
192
|
Returns:
|
|
152
193
|
The asynchronously generated response from the Anthropic LLM.
|
|
@@ -154,6 +195,43 @@ class AnthropicLLM(LLM):
|
|
|
154
195
|
Raises:
|
|
155
196
|
ValueError: If both prompt and messages are provided, or if neither is provided.
|
|
156
197
|
"""
|
|
198
|
+
# Handle web search mode
|
|
199
|
+
if web_search:
|
|
200
|
+
if not prompt and not messages:
|
|
201
|
+
raise ValueError("Either 'prompt' or 'messages' must be provided.")
|
|
202
|
+
|
|
203
|
+
effective_model = model_name if model_name else self.model_name
|
|
204
|
+
|
|
205
|
+
# Prepare messages for web search
|
|
206
|
+
if prompt:
|
|
207
|
+
if images:
|
|
208
|
+
user_content = prepare_vision_content_anthropic(prompt, images)
|
|
209
|
+
else:
|
|
210
|
+
user_content = prompt
|
|
211
|
+
model_messages = [{"role": "user", "content": user_content}]
|
|
212
|
+
else:
|
|
213
|
+
model_messages = self.append_messages(messages)
|
|
214
|
+
|
|
215
|
+
if self.verbose:
|
|
216
|
+
verbose_print(f"Generating response with web search (async) using {effective_model}...", "info")
|
|
217
|
+
|
|
218
|
+
try:
|
|
219
|
+
response = await anthropic_llm.generate_response_with_web_search_async(
|
|
220
|
+
model_name=effective_model,
|
|
221
|
+
system_prompt=system_prompt,
|
|
222
|
+
messages=model_messages,
|
|
223
|
+
max_tokens=max_tokens,
|
|
224
|
+
full_response=full_response,
|
|
225
|
+
api_key=self.api_key,
|
|
226
|
+
)
|
|
227
|
+
if self.verbose:
|
|
228
|
+
verbose_print("Web search response received successfully", "info")
|
|
229
|
+
return response
|
|
230
|
+
except Exception as e:
|
|
231
|
+
if self.verbose:
|
|
232
|
+
verbose_print(f"Error generating web search response: {str(e)}", "error")
|
|
233
|
+
raise
|
|
234
|
+
|
|
157
235
|
params = self.prepare_params(model_name, temperature, top_p)
|
|
158
236
|
|
|
159
237
|
# Validate inputs
|
{simplerllm-0.3.2.7 → simplerllm-0.3.3.0}/SimplerLLM/language/llm/wrappers/openai_wrapper.py
RENAMED
|
@@ -28,6 +28,7 @@ class OpenAILLM(LLM):
|
|
|
28
28
|
json_mode=False,
|
|
29
29
|
images: list = None,
|
|
30
30
|
detail: str = "auto",
|
|
31
|
+
web_search: bool = False,
|
|
31
32
|
):
|
|
32
33
|
"""
|
|
33
34
|
Generate a response using the OpenAI language model.
|
|
@@ -44,6 +45,7 @@ class OpenAILLM(LLM):
|
|
|
44
45
|
json_mode (bool, optional): If True, enables JSON mode. Defaults to False.
|
|
45
46
|
images (list, optional): List of image sources (URLs or file paths) for vision-capable models. Defaults to None.
|
|
46
47
|
detail (str, optional): Level of detail for image processing ("low", "high", "auto"). Defaults to "auto".
|
|
48
|
+
web_search (bool, optional): If True, enables web search before generating response. Defaults to False.
|
|
47
49
|
|
|
48
50
|
Returns:
|
|
49
51
|
str or dict: The generated response as a string, or the full API response as a dictionary if full_response is True.
|
|
@@ -51,6 +53,43 @@ class OpenAILLM(LLM):
|
|
|
51
53
|
Raises:
|
|
52
54
|
ValueError: If both prompt and messages are provided, or if neither is provided.
|
|
53
55
|
"""
|
|
56
|
+
# Handle web search mode - uses Responses API
|
|
57
|
+
if web_search:
|
|
58
|
+
if not prompt and not messages:
|
|
59
|
+
raise ValueError("Either 'prompt' or 'messages' must be provided.")
|
|
60
|
+
|
|
61
|
+
# Combine system prompt and user input for web search
|
|
62
|
+
if prompt:
|
|
63
|
+
input_text = f"{system_prompt}\n\n{prompt}"
|
|
64
|
+
else:
|
|
65
|
+
# Convert messages to a single input string
|
|
66
|
+
input_text = system_prompt + "\n\n"
|
|
67
|
+
for msg in messages:
|
|
68
|
+
role = msg.get("role", "user")
|
|
69
|
+
content = msg.get("content", "")
|
|
70
|
+
input_text += f"{role}: {content}\n"
|
|
71
|
+
|
|
72
|
+
effective_model = model_name if model_name else self.model_name
|
|
73
|
+
|
|
74
|
+
if self.verbose:
|
|
75
|
+
verbose_print(f"Generating response with web search using {effective_model}...", "info")
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
response = openai_llm.generate_response_with_web_search(
|
|
79
|
+
model_name=effective_model,
|
|
80
|
+
input_text=input_text,
|
|
81
|
+
max_tokens=max_tokens,
|
|
82
|
+
full_response=full_response,
|
|
83
|
+
api_key=self.api_key,
|
|
84
|
+
)
|
|
85
|
+
if self.verbose:
|
|
86
|
+
verbose_print("Web search response received successfully", "info")
|
|
87
|
+
return response
|
|
88
|
+
except Exception as e:
|
|
89
|
+
if self.verbose:
|
|
90
|
+
verbose_print(f"Error generating web search response: {str(e)}", "error")
|
|
91
|
+
raise
|
|
92
|
+
|
|
54
93
|
params = self.prepare_params(model_name, temperature, top_p)
|
|
55
94
|
|
|
56
95
|
# Validate inputs
|
|
@@ -126,6 +165,7 @@ class OpenAILLM(LLM):
|
|
|
126
165
|
json_mode=False,
|
|
127
166
|
images: list = None,
|
|
128
167
|
detail: str = "auto",
|
|
168
|
+
web_search: bool = False,
|
|
129
169
|
):
|
|
130
170
|
"""
|
|
131
171
|
Asynchronously generates a response using the OpenAI API.
|
|
@@ -142,6 +182,7 @@ class OpenAILLM(LLM):
|
|
|
142
182
|
json_mode (bool, optional): If True, enables JSON mode. Defaults to False.
|
|
143
183
|
images (list, optional): List of image sources (URLs or file paths) for vision-capable models. Defaults to None.
|
|
144
184
|
detail (str, optional): Level of detail for image processing ("low", "high", "auto"). Defaults to "auto".
|
|
185
|
+
web_search (bool, optional): If True, enables web search before generating response. Defaults to False.
|
|
145
186
|
|
|
146
187
|
Returns:
|
|
147
188
|
str or dict: The generated response as a string, or the full API response as a dictionary if full_response is True.
|
|
@@ -149,6 +190,43 @@ class OpenAILLM(LLM):
|
|
|
149
190
|
Raises:
|
|
150
191
|
ValueError: If both prompt and messages are provided, or if neither is provided.
|
|
151
192
|
"""
|
|
193
|
+
# Handle web search mode - uses Responses API
|
|
194
|
+
if web_search:
|
|
195
|
+
if not prompt and not messages:
|
|
196
|
+
raise ValueError("Either 'prompt' or 'messages' must be provided.")
|
|
197
|
+
|
|
198
|
+
# Combine system prompt and user input for web search
|
|
199
|
+
if prompt:
|
|
200
|
+
input_text = f"{system_prompt}\n\n{prompt}"
|
|
201
|
+
else:
|
|
202
|
+
# Convert messages to a single input string
|
|
203
|
+
input_text = system_prompt + "\n\n"
|
|
204
|
+
for msg in messages:
|
|
205
|
+
role = msg.get("role", "user")
|
|
206
|
+
content = msg.get("content", "")
|
|
207
|
+
input_text += f"{role}: {content}\n"
|
|
208
|
+
|
|
209
|
+
effective_model = model_name if model_name else self.model_name
|
|
210
|
+
|
|
211
|
+
if self.verbose:
|
|
212
|
+
verbose_print(f"Generating response with web search (async) using {effective_model}...", "info")
|
|
213
|
+
|
|
214
|
+
try:
|
|
215
|
+
response = await openai_llm.generate_response_with_web_search_async(
|
|
216
|
+
model_name=effective_model,
|
|
217
|
+
input_text=input_text,
|
|
218
|
+
max_tokens=max_tokens,
|
|
219
|
+
full_response=full_response,
|
|
220
|
+
api_key=self.api_key,
|
|
221
|
+
)
|
|
222
|
+
if self.verbose:
|
|
223
|
+
verbose_print("Web search response received successfully", "info")
|
|
224
|
+
return response
|
|
225
|
+
except Exception as e:
|
|
226
|
+
if self.verbose:
|
|
227
|
+
verbose_print(f"Error generating web search response: {str(e)}", "error")
|
|
228
|
+
raise
|
|
229
|
+
|
|
152
230
|
params = self.prepare_params(model_name, temperature, top_p)
|
|
153
231
|
|
|
154
232
|
# Validate inputs
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import SimplerLLM.language.llm_providers.perplexity_llm as perplexity_llm
|
|
2
|
+
import os
|
|
3
|
+
from ..base import LLM
|
|
4
|
+
from SimplerLLM.utils.custom_verbose import verbose_print
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class PerplexityLLM(LLM):
|
|
8
|
+
def __init__(self, provider, model_name, temperature, top_p, api_key, verbose=False):
|
|
9
|
+
super().__init__(provider, model_name, temperature, top_p, api_key, verbose=verbose)
|
|
10
|
+
self.api_key = api_key or os.getenv("PERPLEXITY_API_KEY", "")
|
|
11
|
+
|
|
12
|
+
def append_messages(self, messages: list):
|
|
13
|
+
model_messages = []
|
|
14
|
+
if messages:
|
|
15
|
+
model_messages.extend(messages)
|
|
16
|
+
return model_messages
|
|
17
|
+
|
|
18
|
+
def generate_response(
|
|
19
|
+
self,
|
|
20
|
+
model_name: str = None,
|
|
21
|
+
prompt: str = None,
|
|
22
|
+
messages: list = None,
|
|
23
|
+
system_prompt: str = "You are a helpful AI Assistant",
|
|
24
|
+
temperature: float = 0.7,
|
|
25
|
+
max_tokens: int = 300,
|
|
26
|
+
top_p: float = 1.0,
|
|
27
|
+
full_response: bool = False,
|
|
28
|
+
json_mode: bool = False,
|
|
29
|
+
search_domain_filter: list = None,
|
|
30
|
+
search_recency_filter: str = None,
|
|
31
|
+
return_images: bool = False,
|
|
32
|
+
return_related_questions: bool = False,
|
|
33
|
+
images: list = None,
|
|
34
|
+
detail: str = "auto",
|
|
35
|
+
web_search: bool = False,
|
|
36
|
+
):
|
|
37
|
+
"""
|
|
38
|
+
Generate a response using the Perplexity LLM.
|
|
39
|
+
|
|
40
|
+
Perplexity has built-in web search by default - every request performs a web search.
|
|
41
|
+
Citations are returned in web_sources when full_response=True.
|
|
42
|
+
|
|
43
|
+
Args:
|
|
44
|
+
model_name (str, optional): The model to use (e.g., 'sonar', 'sonar-pro'). Defaults to instance's model_name.
|
|
45
|
+
prompt (str, optional): A single prompt string to generate a response for.
|
|
46
|
+
messages (list, optional): A list of message dictionaries for chat-based interactions.
|
|
47
|
+
system_prompt (str, optional): The system prompt. Defaults to "You are a helpful AI Assistant".
|
|
48
|
+
temperature (float, optional): Controls randomness (0-2). Defaults to 0.7.
|
|
49
|
+
max_tokens (int, optional): Maximum tokens to generate. Defaults to 300.
|
|
50
|
+
top_p (float, optional): Nucleus sampling threshold. Defaults to 1.0.
|
|
51
|
+
full_response (bool, optional): If True, returns LLMFullResponse with web_sources. Defaults to False.
|
|
52
|
+
json_mode (bool, optional): If True, enables JSON mode. Defaults to False.
|
|
53
|
+
search_domain_filter (list, optional): Domains to include/exclude (prefix with "-" to exclude).
|
|
54
|
+
search_recency_filter (str, optional): Filter by time ("day", "week", "month").
|
|
55
|
+
return_images (bool, optional): Include images in results. Defaults to False.
|
|
56
|
+
return_related_questions (bool, optional): Return related queries. Defaults to False.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
str or LLMFullResponse: Generated text or full response with web sources.
|
|
60
|
+
|
|
61
|
+
Raises:
|
|
62
|
+
ValueError: If both prompt and messages are provided, or if neither is provided.
|
|
63
|
+
"""
|
|
64
|
+
params = self.prepare_params(model_name, temperature, top_p)
|
|
65
|
+
|
|
66
|
+
# Validate inputs
|
|
67
|
+
if prompt and messages:
|
|
68
|
+
if self.verbose:
|
|
69
|
+
verbose_print("Error: Both prompt and messages provided", "error")
|
|
70
|
+
raise ValueError("Only one of 'prompt' or 'messages' should be provided.")
|
|
71
|
+
if not prompt and not messages:
|
|
72
|
+
if self.verbose:
|
|
73
|
+
verbose_print("Error: Neither prompt nor messages provided", "error")
|
|
74
|
+
raise ValueError("Either 'prompt' or 'messages' must be provided.")
|
|
75
|
+
|
|
76
|
+
# Prepare messages based on input type
|
|
77
|
+
if prompt:
|
|
78
|
+
if self.verbose:
|
|
79
|
+
verbose_print("Preparing single prompt message", "debug")
|
|
80
|
+
verbose_print(f"User prompt: {prompt}", "debug")
|
|
81
|
+
|
|
82
|
+
model_messages = [
|
|
83
|
+
{"role": "system", "content": system_prompt},
|
|
84
|
+
{"role": "user", "content": prompt},
|
|
85
|
+
]
|
|
86
|
+
else:
|
|
87
|
+
if self.verbose:
|
|
88
|
+
verbose_print("Preparing chat messages", "debug")
|
|
89
|
+
# Prepend system message if not already present
|
|
90
|
+
model_messages = self.append_messages(messages)
|
|
91
|
+
if not any(msg.get("role") == "system" for msg in model_messages):
|
|
92
|
+
model_messages.insert(0, {"role": "system", "content": system_prompt})
|
|
93
|
+
|
|
94
|
+
params.update(
|
|
95
|
+
{
|
|
96
|
+
"api_key": self.api_key,
|
|
97
|
+
"messages": model_messages,
|
|
98
|
+
"max_tokens": max_tokens,
|
|
99
|
+
"full_response": full_response,
|
|
100
|
+
"json_mode": json_mode,
|
|
101
|
+
"search_domain_filter": search_domain_filter,
|
|
102
|
+
"search_recency_filter": search_recency_filter,
|
|
103
|
+
"return_images": return_images,
|
|
104
|
+
"return_related_questions": return_related_questions,
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
if self.verbose:
|
|
109
|
+
verbose_print(f"Generating response with Perplexity using {params['model_name']}...", "info")
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
response = perplexity_llm.generate_response(**params)
|
|
113
|
+
if self.verbose:
|
|
114
|
+
verbose_print("Response received successfully", "info")
|
|
115
|
+
return response
|
|
116
|
+
except Exception as e:
|
|
117
|
+
if self.verbose:
|
|
118
|
+
verbose_print(f"Error generating response: {str(e)}", "error")
|
|
119
|
+
raise
|
|
120
|
+
|
|
121
|
+
async def generate_response_async(
|
|
122
|
+
self,
|
|
123
|
+
model_name: str = None,
|
|
124
|
+
prompt: str = None,
|
|
125
|
+
messages: list = None,
|
|
126
|
+
system_prompt: str = "You are a helpful AI Assistant",
|
|
127
|
+
temperature: float = 0.7,
|
|
128
|
+
max_tokens: int = 300,
|
|
129
|
+
top_p: float = 1.0,
|
|
130
|
+
full_response: bool = False,
|
|
131
|
+
json_mode: bool = False,
|
|
132
|
+
search_domain_filter: list = None,
|
|
133
|
+
search_recency_filter: str = None,
|
|
134
|
+
return_images: bool = False,
|
|
135
|
+
return_related_questions: bool = False,
|
|
136
|
+
images: list = None,
|
|
137
|
+
detail: str = "auto",
|
|
138
|
+
web_search: bool = False,
|
|
139
|
+
):
|
|
140
|
+
"""
|
|
141
|
+
Asynchronously generate a response using the Perplexity LLM.
|
|
142
|
+
|
|
143
|
+
Perplexity has built-in web search by default - every request performs a web search.
|
|
144
|
+
Citations are returned in web_sources when full_response=True.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
model_name (str, optional): The model to use (e.g., 'sonar', 'sonar-pro'). Defaults to instance's model_name.
|
|
148
|
+
prompt (str, optional): A single prompt string to generate a response for.
|
|
149
|
+
messages (list, optional): A list of message dictionaries for chat-based interactions.
|
|
150
|
+
system_prompt (str, optional): The system prompt. Defaults to "You are a helpful AI Assistant".
|
|
151
|
+
temperature (float, optional): Controls randomness (0-2). Defaults to 0.7.
|
|
152
|
+
max_tokens (int, optional): Maximum tokens to generate. Defaults to 300.
|
|
153
|
+
top_p (float, optional): Nucleus sampling threshold. Defaults to 1.0.
|
|
154
|
+
full_response (bool, optional): If True, returns LLMFullResponse with web_sources. Defaults to False.
|
|
155
|
+
json_mode (bool, optional): If True, enables JSON mode. Defaults to False.
|
|
156
|
+
search_domain_filter (list, optional): Domains to include/exclude (prefix with "-" to exclude).
|
|
157
|
+
search_recency_filter (str, optional): Filter by time ("day", "week", "month").
|
|
158
|
+
return_images (bool, optional): Include images in results. Defaults to False.
|
|
159
|
+
return_related_questions (bool, optional): Return related queries. Defaults to False.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
str or LLMFullResponse: Generated text or full response with web sources.
|
|
163
|
+
|
|
164
|
+
Raises:
|
|
165
|
+
ValueError: If both prompt and messages are provided, or if neither is provided.
|
|
166
|
+
"""
|
|
167
|
+
params = self.prepare_params(model_name, temperature, top_p)
|
|
168
|
+
|
|
169
|
+
# Validate inputs
|
|
170
|
+
if prompt and messages:
|
|
171
|
+
if self.verbose:
|
|
172
|
+
verbose_print("Error: Both prompt and messages provided", "error")
|
|
173
|
+
raise ValueError("Only one of 'prompt' or 'messages' should be provided.")
|
|
174
|
+
if not prompt and not messages:
|
|
175
|
+
if self.verbose:
|
|
176
|
+
verbose_print("Error: Neither prompt nor messages provided", "error")
|
|
177
|
+
raise ValueError("Either 'prompt' or 'messages' must be provided.")
|
|
178
|
+
|
|
179
|
+
# Prepare messages based on input type
|
|
180
|
+
if prompt:
|
|
181
|
+
if self.verbose:
|
|
182
|
+
verbose_print("Preparing single prompt message", "debug")
|
|
183
|
+
verbose_print(f"User prompt: {prompt}", "debug")
|
|
184
|
+
|
|
185
|
+
model_messages = [
|
|
186
|
+
{"role": "system", "content": system_prompt},
|
|
187
|
+
{"role": "user", "content": prompt},
|
|
188
|
+
]
|
|
189
|
+
else:
|
|
190
|
+
if self.verbose:
|
|
191
|
+
verbose_print("Preparing chat messages", "debug")
|
|
192
|
+
# Prepend system message if not already present
|
|
193
|
+
model_messages = self.append_messages(messages)
|
|
194
|
+
if not any(msg.get("role") == "system" for msg in model_messages):
|
|
195
|
+
model_messages.insert(0, {"role": "system", "content": system_prompt})
|
|
196
|
+
|
|
197
|
+
params.update(
|
|
198
|
+
{
|
|
199
|
+
"api_key": self.api_key,
|
|
200
|
+
"messages": model_messages,
|
|
201
|
+
"max_tokens": max_tokens,
|
|
202
|
+
"full_response": full_response,
|
|
203
|
+
"json_mode": json_mode,
|
|
204
|
+
"search_domain_filter": search_domain_filter,
|
|
205
|
+
"search_recency_filter": search_recency_filter,
|
|
206
|
+
"return_images": return_images,
|
|
207
|
+
"return_related_questions": return_related_questions,
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
if self.verbose:
|
|
212
|
+
verbose_print(f"Generating response with Perplexity (async) using {params['model_name']}...", "info")
|
|
213
|
+
|
|
214
|
+
try:
|
|
215
|
+
response = await perplexity_llm.generate_response_async(**params)
|
|
216
|
+
if self.verbose:
|
|
217
|
+
verbose_print("Response received successfully", "info")
|
|
218
|
+
return response
|
|
219
|
+
except Exception as e:
|
|
220
|
+
if self.verbose:
|
|
221
|
+
verbose_print(f"Error generating response: {str(e)}", "error")
|
|
222
|
+
raise
|