fast-agent-mcp 0.2.57__py3-none-any.whl → 0.3.0__py3-none-any.whl
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.
Potentially problematic release.
This version of fast-agent-mcp might be problematic. Click here for more details.
- fast_agent/__init__.py +127 -0
- fast_agent/agents/__init__.py +36 -0
- {mcp_agent/core → fast_agent/agents}/agent_types.py +2 -1
- fast_agent/agents/llm_agent.py +217 -0
- fast_agent/agents/llm_decorator.py +486 -0
- mcp_agent/agents/base_agent.py → fast_agent/agents/mcp_agent.py +377 -385
- fast_agent/agents/tool_agent.py +168 -0
- {mcp_agent → fast_agent}/agents/workflow/chain_agent.py +43 -33
- {mcp_agent → fast_agent}/agents/workflow/evaluator_optimizer.py +31 -35
- {mcp_agent → fast_agent}/agents/workflow/iterative_planner.py +56 -47
- {mcp_agent → fast_agent}/agents/workflow/orchestrator_models.py +4 -4
- {mcp_agent → fast_agent}/agents/workflow/parallel_agent.py +34 -41
- {mcp_agent → fast_agent}/agents/workflow/router_agent.py +54 -39
- {mcp_agent → fast_agent}/cli/__main__.py +5 -3
- {mcp_agent → fast_agent}/cli/commands/check_config.py +95 -66
- {mcp_agent → fast_agent}/cli/commands/go.py +20 -11
- {mcp_agent → fast_agent}/cli/commands/quickstart.py +4 -4
- {mcp_agent → fast_agent}/cli/commands/server_helpers.py +1 -1
- {mcp_agent → fast_agent}/cli/commands/setup.py +64 -134
- {mcp_agent → fast_agent}/cli/commands/url_parser.py +9 -8
- {mcp_agent → fast_agent}/cli/main.py +36 -16
- {mcp_agent → fast_agent}/cli/terminal.py +2 -2
- {mcp_agent → fast_agent}/config.py +13 -2
- fast_agent/constants.py +8 -0
- {mcp_agent → fast_agent}/context.py +24 -19
- {mcp_agent → fast_agent}/context_dependent.py +9 -5
- fast_agent/core/__init__.py +17 -0
- {mcp_agent → fast_agent}/core/agent_app.py +39 -36
- fast_agent/core/core_app.py +135 -0
- {mcp_agent → fast_agent}/core/direct_decorators.py +12 -26
- {mcp_agent → fast_agent}/core/direct_factory.py +95 -73
- {mcp_agent → fast_agent/core}/executor/executor.py +4 -5
- {mcp_agent → fast_agent}/core/fastagent.py +32 -32
- fast_agent/core/logging/__init__.py +5 -0
- {mcp_agent → fast_agent/core}/logging/events.py +3 -3
- {mcp_agent → fast_agent/core}/logging/json_serializer.py +1 -1
- {mcp_agent → fast_agent/core}/logging/listeners.py +85 -7
- {mcp_agent → fast_agent/core}/logging/logger.py +7 -7
- {mcp_agent → fast_agent/core}/logging/transport.py +10 -11
- fast_agent/core/prompt.py +9 -0
- {mcp_agent → fast_agent}/core/validation.py +4 -4
- fast_agent/event_progress.py +61 -0
- fast_agent/history/history_exporter.py +44 -0
- {mcp_agent → fast_agent}/human_input/__init__.py +9 -12
- {mcp_agent → fast_agent}/human_input/elicitation_handler.py +26 -8
- {mcp_agent → fast_agent}/human_input/elicitation_state.py +7 -7
- {mcp_agent → fast_agent}/human_input/simple_form.py +6 -4
- {mcp_agent → fast_agent}/human_input/types.py +1 -18
- fast_agent/interfaces.py +228 -0
- fast_agent/llm/__init__.py +9 -0
- mcp_agent/llm/augmented_llm.py → fast_agent/llm/fastagent_llm.py +128 -218
- fast_agent/llm/internal/passthrough.py +137 -0
- mcp_agent/llm/augmented_llm_playback.py → fast_agent/llm/internal/playback.py +29 -25
- mcp_agent/llm/augmented_llm_silent.py → fast_agent/llm/internal/silent.py +10 -17
- fast_agent/llm/internal/slow.py +38 -0
- {mcp_agent → fast_agent}/llm/memory.py +40 -30
- {mcp_agent → fast_agent}/llm/model_database.py +35 -2
- {mcp_agent → fast_agent}/llm/model_factory.py +103 -77
- fast_agent/llm/model_info.py +126 -0
- {mcp_agent/llm/providers → fast_agent/llm/provider/anthropic}/anthropic_utils.py +7 -7
- fast_agent/llm/provider/anthropic/llm_anthropic.py +603 -0
- {mcp_agent/llm/providers → fast_agent/llm/provider/anthropic}/multipart_converter_anthropic.py +79 -86
- fast_agent/llm/provider/bedrock/bedrock_utils.py +218 -0
- fast_agent/llm/provider/bedrock/llm_bedrock.py +2192 -0
- {mcp_agent/llm/providers → fast_agent/llm/provider/google}/google_converter.py +66 -14
- fast_agent/llm/provider/google/llm_google_native.py +431 -0
- mcp_agent/llm/providers/augmented_llm_aliyun.py → fast_agent/llm/provider/openai/llm_aliyun.py +6 -7
- mcp_agent/llm/providers/augmented_llm_azure.py → fast_agent/llm/provider/openai/llm_azure.py +4 -4
- mcp_agent/llm/providers/augmented_llm_deepseek.py → fast_agent/llm/provider/openai/llm_deepseek.py +10 -11
- mcp_agent/llm/providers/augmented_llm_generic.py → fast_agent/llm/provider/openai/llm_generic.py +4 -4
- mcp_agent/llm/providers/augmented_llm_google_oai.py → fast_agent/llm/provider/openai/llm_google_oai.py +4 -4
- mcp_agent/llm/providers/augmented_llm_groq.py → fast_agent/llm/provider/openai/llm_groq.py +14 -16
- mcp_agent/llm/providers/augmented_llm_openai.py → fast_agent/llm/provider/openai/llm_openai.py +133 -206
- mcp_agent/llm/providers/augmented_llm_openrouter.py → fast_agent/llm/provider/openai/llm_openrouter.py +6 -6
- mcp_agent/llm/providers/augmented_llm_tensorzero_openai.py → fast_agent/llm/provider/openai/llm_tensorzero_openai.py +17 -16
- mcp_agent/llm/providers/augmented_llm_xai.py → fast_agent/llm/provider/openai/llm_xai.py +6 -6
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/multipart_converter_openai.py +125 -63
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/openai_multipart.py +12 -12
- {mcp_agent/llm/providers → fast_agent/llm/provider/openai}/openai_utils.py +18 -16
- {mcp_agent → fast_agent}/llm/provider_key_manager.py +2 -2
- {mcp_agent → fast_agent}/llm/provider_types.py +2 -0
- {mcp_agent → fast_agent}/llm/sampling_converter.py +15 -12
- {mcp_agent → fast_agent}/llm/usage_tracking.py +23 -5
- fast_agent/mcp/__init__.py +43 -0
- {mcp_agent → fast_agent}/mcp/elicitation_factory.py +3 -3
- {mcp_agent → fast_agent}/mcp/elicitation_handlers.py +19 -10
- {mcp_agent → fast_agent}/mcp/gen_client.py +3 -3
- fast_agent/mcp/helpers/__init__.py +36 -0
- fast_agent/mcp/helpers/content_helpers.py +183 -0
- {mcp_agent → fast_agent}/mcp/helpers/server_config_helpers.py +8 -8
- {mcp_agent → fast_agent}/mcp/hf_auth.py +25 -23
- fast_agent/mcp/interfaces.py +93 -0
- {mcp_agent → fast_agent}/mcp/logger_textio.py +4 -4
- {mcp_agent → fast_agent}/mcp/mcp_agent_client_session.py +49 -44
- {mcp_agent → fast_agent}/mcp/mcp_aggregator.py +66 -115
- {mcp_agent → fast_agent}/mcp/mcp_connection_manager.py +16 -23
- {mcp_agent/core → fast_agent/mcp}/mcp_content.py +23 -15
- {mcp_agent → fast_agent}/mcp/mime_utils.py +39 -0
- fast_agent/mcp/prompt.py +159 -0
- mcp_agent/mcp/prompt_message_multipart.py → fast_agent/mcp/prompt_message_extended.py +27 -20
- {mcp_agent → fast_agent}/mcp/prompt_render.py +21 -19
- {mcp_agent → fast_agent}/mcp/prompt_serialization.py +46 -46
- fast_agent/mcp/prompts/__main__.py +7 -0
- {mcp_agent → fast_agent}/mcp/prompts/prompt_helpers.py +31 -30
- {mcp_agent → fast_agent}/mcp/prompts/prompt_load.py +8 -8
- {mcp_agent → fast_agent}/mcp/prompts/prompt_server.py +11 -19
- {mcp_agent → fast_agent}/mcp/prompts/prompt_template.py +18 -18
- {mcp_agent → fast_agent}/mcp/resource_utils.py +1 -1
- {mcp_agent → fast_agent}/mcp/sampling.py +31 -26
- {mcp_agent/mcp_server → fast_agent/mcp/server}/__init__.py +1 -1
- {mcp_agent/mcp_server → fast_agent/mcp/server}/agent_server.py +5 -6
- fast_agent/mcp/ui_agent.py +48 -0
- fast_agent/mcp/ui_mixin.py +209 -0
- fast_agent/mcp_server_registry.py +90 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/analysis-campaign.py +5 -4
- {mcp_agent → fast_agent}/resources/examples/data-analysis/analysis.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_forms_server.py +25 -3
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/forms_demo.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/game_character.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/game_character_handler.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/tool_call.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/agent_one.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/agent_two.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher-eval.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher-imp.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/researcher/researcher.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/tensorzero/agent.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/tensorzero/image_demo.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/tensorzero/simple_agent.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/chaining.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/evaluator.py +3 -3
- {mcp_agent → fast_agent}/resources/examples/workflows/human_input.py +5 -3
- {mcp_agent → fast_agent}/resources/examples/workflows/orchestrator.py +1 -1
- {mcp_agent → fast_agent}/resources/examples/workflows/parallel.py +2 -2
- {mcp_agent → fast_agent}/resources/examples/workflows/router.py +5 -2
- fast_agent/resources/setup/.gitignore +24 -0
- fast_agent/resources/setup/agent.py +18 -0
- fast_agent/resources/setup/fastagent.config.yaml +44 -0
- fast_agent/resources/setup/fastagent.secrets.yaml.example +38 -0
- fast_agent/tools/elicitation.py +369 -0
- fast_agent/types/__init__.py +32 -0
- fast_agent/types/llm_stop_reason.py +77 -0
- fast_agent/ui/__init__.py +38 -0
- fast_agent/ui/console_display.py +1005 -0
- {mcp_agent/human_input → fast_agent/ui}/elicitation_form.py +56 -39
- mcp_agent/human_input/elicitation_forms.py → fast_agent/ui/elicitation_style.py +1 -1
- {mcp_agent/core → fast_agent/ui}/enhanced_prompt.py +96 -25
- {mcp_agent/core → fast_agent/ui}/interactive_prompt.py +330 -125
- fast_agent/ui/mcp_ui_utils.py +224 -0
- {mcp_agent → fast_agent/ui}/progress_display.py +2 -2
- {mcp_agent/logging → fast_agent/ui}/rich_progress.py +4 -4
- {mcp_agent/core → fast_agent/ui}/usage_display.py +3 -8
- {fast_agent_mcp-0.2.57.dist-info → fast_agent_mcp-0.3.0.dist-info}/METADATA +7 -7
- fast_agent_mcp-0.3.0.dist-info/RECORD +202 -0
- fast_agent_mcp-0.3.0.dist-info/entry_points.txt +5 -0
- fast_agent_mcp-0.2.57.dist-info/RECORD +0 -192
- fast_agent_mcp-0.2.57.dist-info/entry_points.txt +0 -6
- mcp_agent/__init__.py +0 -114
- mcp_agent/agents/agent.py +0 -92
- mcp_agent/agents/workflow/__init__.py +0 -1
- mcp_agent/agents/workflow/orchestrator_agent.py +0 -597
- mcp_agent/app.py +0 -175
- mcp_agent/core/__init__.py +0 -26
- mcp_agent/core/prompt.py +0 -191
- mcp_agent/event_progress.py +0 -134
- mcp_agent/human_input/handler.py +0 -81
- mcp_agent/llm/__init__.py +0 -2
- mcp_agent/llm/augmented_llm_passthrough.py +0 -232
- mcp_agent/llm/augmented_llm_slow.py +0 -53
- mcp_agent/llm/providers/__init__.py +0 -8
- mcp_agent/llm/providers/augmented_llm_anthropic.py +0 -717
- mcp_agent/llm/providers/augmented_llm_bedrock.py +0 -1788
- mcp_agent/llm/providers/augmented_llm_google_native.py +0 -495
- mcp_agent/llm/providers/sampling_converter_anthropic.py +0 -57
- mcp_agent/llm/providers/sampling_converter_openai.py +0 -26
- mcp_agent/llm/sampling_format_converter.py +0 -37
- mcp_agent/logging/__init__.py +0 -0
- mcp_agent/mcp/__init__.py +0 -50
- mcp_agent/mcp/helpers/__init__.py +0 -25
- mcp_agent/mcp/helpers/content_helpers.py +0 -187
- mcp_agent/mcp/interfaces.py +0 -266
- mcp_agent/mcp/prompts/__init__.py +0 -0
- mcp_agent/mcp/prompts/__main__.py +0 -10
- mcp_agent/mcp_server_registry.py +0 -343
- mcp_agent/tools/tool_definition.py +0 -14
- mcp_agent/ui/console_display.py +0 -790
- mcp_agent/ui/console_display_legacy.py +0 -401
- {mcp_agent → fast_agent}/agents/workflow/orchestrator_prompts.py +0 -0
- {mcp_agent/agents → fast_agent/cli}/__init__.py +0 -0
- {mcp_agent → fast_agent}/cli/constants.py +0 -0
- {mcp_agent → fast_agent}/core/error_handling.py +0 -0
- {mcp_agent → fast_agent}/core/exceptions.py +0 -0
- {mcp_agent/cli → fast_agent/core/executor}/__init__.py +0 -0
- {mcp_agent → fast_agent/core}/executor/task_registry.py +0 -0
- {mcp_agent → fast_agent/core}/executor/workflow_signal.py +0 -0
- {mcp_agent → fast_agent}/human_input/form_fields.py +0 -0
- {mcp_agent → fast_agent}/llm/prompt_utils.py +0 -0
- {mcp_agent/core → fast_agent/llm}/request_params.py +0 -0
- {mcp_agent → fast_agent}/mcp/common.py +0 -0
- {mcp_agent/executor → fast_agent/mcp/prompts}/__init__.py +0 -0
- {mcp_agent → fast_agent}/mcp/prompts/prompt_constants.py +0 -0
- {mcp_agent → fast_agent}/py.typed +0 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_account_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/elicitation_game_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/elicitations/fastagent.secrets.yaml.example +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/mcp/state-transfer/fastagent.secrets.yaml.example +0 -0
- {mcp_agent → fast_agent}/resources/examples/researcher/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/.env.sample +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/Makefile +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/README.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/clam.jpg +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/crab.png +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/demo_images/shrimp.png +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/docker-compose.yml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/Dockerfile +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/entrypoint.sh +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/mcp_server.py +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/mcp_server/pyproject.toml +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/system_schema.json +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/system_template.minijinja +0 -0
- {mcp_agent → fast_agent}/resources/examples/tensorzero/tensorzero_config/tensorzero.toml +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/fastagent.config.yaml +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/graded_report.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/short_story.md +0 -0
- {mcp_agent → fast_agent}/resources/examples/workflows/short_story.txt +0 -0
- {mcp_agent → fast_agent/ui}/console.py +0 -0
- {mcp_agent/core → fast_agent/ui}/mermaid_utils.py +0 -0
- {fast_agent_mcp-0.2.57.dist-info → fast_agent_mcp-0.3.0.dist-info}/WHEEL +0 -0
- {fast_agent_mcp-0.2.57.dist-info → fast_agent_mcp-0.3.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,51 +1,22 @@
|
|
|
1
1
|
from enum import Enum
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Dict, Optional, Type, Union
|
|
3
3
|
|
|
4
4
|
from pydantic import BaseModel
|
|
5
5
|
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
|
|
15
|
-
from
|
|
16
|
-
from mcp_agent.llm.providers.augmented_llm_azure import AzureOpenAIAugmentedLLM
|
|
17
|
-
from mcp_agent.llm.providers.augmented_llm_bedrock import BedrockAugmentedLLM
|
|
18
|
-
from mcp_agent.llm.providers.augmented_llm_deepseek import DeepSeekAugmentedLLM
|
|
19
|
-
from mcp_agent.llm.providers.augmented_llm_generic import GenericAugmentedLLM
|
|
20
|
-
from mcp_agent.llm.providers.augmented_llm_google_native import GoogleNativeAugmentedLLM
|
|
21
|
-
from mcp_agent.llm.providers.augmented_llm_google_oai import GoogleOaiAugmentedLLM
|
|
22
|
-
from mcp_agent.llm.providers.augmented_llm_groq import GroqAugmentedLLM
|
|
23
|
-
from mcp_agent.llm.providers.augmented_llm_openai import OpenAIAugmentedLLM
|
|
24
|
-
from mcp_agent.llm.providers.augmented_llm_openrouter import OpenRouterAugmentedLLM
|
|
25
|
-
from mcp_agent.llm.providers.augmented_llm_tensorzero_openai import TensorZeroOpenAIAugmentedLLM
|
|
26
|
-
from mcp_agent.llm.providers.augmented_llm_xai import XAIAugmentedLLM
|
|
27
|
-
from mcp_agent.mcp.interfaces import AugmentedLLMProtocol
|
|
28
|
-
|
|
29
|
-
# from mcp_agent.workflows.llm.augmented_llm_deepseek import DeekSeekAugmentedLLM
|
|
6
|
+
from fast_agent.core.exceptions import ModelConfigError
|
|
7
|
+
from fast_agent.interfaces import AgentProtocol, FastAgentLLMProtocol, LLMFactoryProtocol
|
|
8
|
+
from fast_agent.llm.internal.passthrough import PassthroughLLM
|
|
9
|
+
from fast_agent.llm.internal.playback import PlaybackLLM
|
|
10
|
+
from fast_agent.llm.internal.silent import SilentLLM
|
|
11
|
+
from fast_agent.llm.internal.slow import SlowLLM
|
|
12
|
+
from fast_agent.llm.provider_types import Provider
|
|
13
|
+
from fast_agent.types import RequestParams
|
|
14
|
+
|
|
15
|
+
# from fast_agent.workflows.llm.augmented_llm_deepseek import DeekSeekAugmentedLLM
|
|
30
16
|
|
|
31
17
|
|
|
32
18
|
# Type alias for LLM classes
|
|
33
|
-
LLMClass = Union[
|
|
34
|
-
Type[AnthropicAugmentedLLM],
|
|
35
|
-
Type[OpenAIAugmentedLLM],
|
|
36
|
-
Type[PassthroughLLM],
|
|
37
|
-
Type[PlaybackLLM],
|
|
38
|
-
Type[SilentLLM],
|
|
39
|
-
Type[SlowLLM],
|
|
40
|
-
Type[DeepSeekAugmentedLLM],
|
|
41
|
-
Type[OpenRouterAugmentedLLM],
|
|
42
|
-
Type[TensorZeroOpenAIAugmentedLLM],
|
|
43
|
-
Type[GoogleNativeAugmentedLLM],
|
|
44
|
-
Type[GenericAugmentedLLM],
|
|
45
|
-
Type[AzureOpenAIAugmentedLLM],
|
|
46
|
-
Type[BedrockAugmentedLLM],
|
|
47
|
-
Type[GroqAugmentedLLM],
|
|
48
|
-
]
|
|
19
|
+
LLMClass = Union[Type[PassthroughLLM], Type[PlaybackLLM], Type[SilentLLM], Type[SlowLLM], type]
|
|
49
20
|
|
|
50
21
|
|
|
51
22
|
class ReasoningEffort(Enum):
|
|
@@ -78,7 +49,6 @@ class ModelFactory:
|
|
|
78
49
|
}
|
|
79
50
|
|
|
80
51
|
"""
|
|
81
|
-
TODO -- add context window size information for display/management
|
|
82
52
|
TODO -- add audio supporting got-4o-audio-preview
|
|
83
53
|
TODO -- bring model parameter configuration here
|
|
84
54
|
Mapping of model names to their default providers
|
|
@@ -150,28 +120,26 @@ class ModelFactory:
|
|
|
150
120
|
"gemini2": "gemini-2.0-flash",
|
|
151
121
|
"gemini25": "gemini-2.5-flash-preview-05-20",
|
|
152
122
|
"gemini25pro": "gemini-2.5-pro-preview-05-06",
|
|
153
|
-
"kimi": "groq.moonshotai/kimi-k2-instruct",
|
|
123
|
+
"kimi": "groq.moonshotai/kimi-k2-instruct-0905",
|
|
154
124
|
"gpt-oss": "groq.openai/gpt-oss-120b",
|
|
155
125
|
"gpt-oss-20b": "groq.openai/gpt-oss-20b",
|
|
156
126
|
}
|
|
157
127
|
|
|
128
|
+
@staticmethod
|
|
129
|
+
def _bedrock_pattern_matches(model_name: str) -> bool:
|
|
130
|
+
"""Return True if model_name matches Bedrock's expected pattern, else False.
|
|
131
|
+
|
|
132
|
+
Uses provider's helper if available; otherwise, returns False.
|
|
133
|
+
"""
|
|
134
|
+
try:
|
|
135
|
+
from fast_agent.llm.provider.bedrock.llm_bedrock import BedrockLLM # type: ignore
|
|
136
|
+
|
|
137
|
+
return BedrockLLM.matches_model_pattern(model_name)
|
|
138
|
+
except Exception:
|
|
139
|
+
return False
|
|
140
|
+
|
|
158
141
|
# Mapping of providers to their LLM classes
|
|
159
|
-
PROVIDER_CLASSES: Dict[Provider, LLMClass] = {
|
|
160
|
-
Provider.ANTHROPIC: AnthropicAugmentedLLM,
|
|
161
|
-
Provider.OPENAI: OpenAIAugmentedLLM,
|
|
162
|
-
Provider.FAST_AGENT: PassthroughLLM,
|
|
163
|
-
Provider.DEEPSEEK: DeepSeekAugmentedLLM,
|
|
164
|
-
Provider.GENERIC: GenericAugmentedLLM,
|
|
165
|
-
Provider.GOOGLE_OAI: GoogleOaiAugmentedLLM,
|
|
166
|
-
Provider.GOOGLE: GoogleNativeAugmentedLLM,
|
|
167
|
-
Provider.XAI: XAIAugmentedLLM,
|
|
168
|
-
Provider.OPENROUTER: OpenRouterAugmentedLLM,
|
|
169
|
-
Provider.TENSORZERO: TensorZeroOpenAIAugmentedLLM,
|
|
170
|
-
Provider.AZURE: AzureOpenAIAugmentedLLM,
|
|
171
|
-
Provider.ALIYUN: AliyunAugmentedLLM,
|
|
172
|
-
Provider.BEDROCK: BedrockAugmentedLLM,
|
|
173
|
-
Provider.GROQ: GroqAugmentedLLM,
|
|
174
|
-
}
|
|
142
|
+
PROVIDER_CLASSES: Dict[Provider, LLMClass] = {}
|
|
175
143
|
|
|
176
144
|
# Mapping of special model names to their specific LLM classes
|
|
177
145
|
# This overrides the provider-based class selection
|
|
@@ -227,7 +195,7 @@ class ModelFactory:
|
|
|
227
195
|
provider = cls.DEFAULT_PROVIDERS.get(model_name_str)
|
|
228
196
|
|
|
229
197
|
# If still None, try pattern matching for Bedrock models
|
|
230
|
-
if provider is None and
|
|
198
|
+
if provider is None and cls._bedrock_pattern_matches(model_name_str):
|
|
231
199
|
provider = Provider.BEDROCK
|
|
232
200
|
|
|
233
201
|
if provider is None:
|
|
@@ -246,15 +214,12 @@ class ModelFactory:
|
|
|
246
214
|
)
|
|
247
215
|
|
|
248
216
|
@classmethod
|
|
249
|
-
def create_factory(
|
|
250
|
-
cls, model_string: str, request_params: Optional[RequestParams] = None
|
|
251
|
-
) -> Callable[..., AugmentedLLMProtocol]:
|
|
217
|
+
def create_factory(cls, model_string: str) -> LLMFactoryProtocol:
|
|
252
218
|
"""
|
|
253
219
|
Creates a factory function that follows the attach_llm protocol.
|
|
254
220
|
|
|
255
221
|
Args:
|
|
256
222
|
model_string: The model specification string (e.g. "gpt-4.1")
|
|
257
|
-
request_params: Optional parameters to configure LLM behavior
|
|
258
223
|
|
|
259
224
|
Returns:
|
|
260
225
|
A callable that takes an agent parameter and returns an LLM instance
|
|
@@ -262,35 +227,96 @@ class ModelFactory:
|
|
|
262
227
|
config = cls.parse_model_string(model_string)
|
|
263
228
|
|
|
264
229
|
# Ensure provider is valid before trying to access PROVIDER_CLASSES with it
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
raise ModelConfigError(
|
|
271
|
-
f"Provider '{config.provider}' not configured in PROVIDER_CLASSES and model '{config.model_name}' not in MODEL_SPECIFIC_CLASSES."
|
|
272
|
-
)
|
|
230
|
+
# Lazily ensure provider class map is populated and supports this provider
|
|
231
|
+
if config.model_name not in cls.MODEL_SPECIFIC_CLASSES:
|
|
232
|
+
llm_class = cls._load_provider_class(config.provider)
|
|
233
|
+
# Stash for next time
|
|
234
|
+
cls.PROVIDER_CLASSES[config.provider] = llm_class
|
|
273
235
|
|
|
274
236
|
if config.model_name in cls.MODEL_SPECIFIC_CLASSES:
|
|
275
237
|
llm_class = cls.MODEL_SPECIFIC_CLASSES[config.model_name]
|
|
276
238
|
else:
|
|
277
|
-
# This line is now safer due to the check above
|
|
278
239
|
llm_class = cls.PROVIDER_CLASSES[config.provider]
|
|
279
240
|
|
|
280
241
|
def factory(
|
|
281
|
-
agent:
|
|
282
|
-
) ->
|
|
242
|
+
agent: AgentProtocol, request_params: Optional[RequestParams] = None, **kwargs
|
|
243
|
+
) -> FastAgentLLMProtocol:
|
|
283
244
|
base_params = RequestParams()
|
|
284
245
|
base_params.model = config.model_name
|
|
285
246
|
if config.reasoning_effort:
|
|
286
247
|
kwargs["reasoning_effort"] = config.reasoning_effort.value
|
|
287
248
|
llm_args = {
|
|
288
|
-
"agent": agent,
|
|
289
249
|
"model": config.model_name,
|
|
290
250
|
"request_params": request_params,
|
|
251
|
+
"name": agent.name,
|
|
252
|
+
"instructions": agent.instruction,
|
|
291
253
|
**kwargs,
|
|
292
254
|
}
|
|
293
|
-
llm:
|
|
255
|
+
llm: FastAgentLLMProtocol = llm_class(**llm_args)
|
|
294
256
|
return llm
|
|
295
257
|
|
|
296
258
|
return factory
|
|
259
|
+
|
|
260
|
+
@classmethod
|
|
261
|
+
def _load_provider_class(cls, provider: Provider) -> type:
|
|
262
|
+
"""Import provider-specific LLM classes lazily to avoid heavy deps at import time."""
|
|
263
|
+
try:
|
|
264
|
+
if provider == Provider.FAST_AGENT:
|
|
265
|
+
return PassthroughLLM
|
|
266
|
+
if provider == Provider.ANTHROPIC:
|
|
267
|
+
from fast_agent.llm.provider.anthropic.llm_anthropic import AnthropicLLM
|
|
268
|
+
|
|
269
|
+
return AnthropicLLM
|
|
270
|
+
if provider == Provider.OPENAI:
|
|
271
|
+
from fast_agent.llm.provider.openai.llm_openai import OpenAILLM
|
|
272
|
+
|
|
273
|
+
return OpenAILLM
|
|
274
|
+
if provider == Provider.DEEPSEEK:
|
|
275
|
+
from fast_agent.llm.provider.openai.llm_deepseek import DeepSeekLLM
|
|
276
|
+
|
|
277
|
+
return DeepSeekLLM
|
|
278
|
+
if provider == Provider.GENERIC:
|
|
279
|
+
from fast_agent.llm.provider.openai.llm_generic import GenericLLM
|
|
280
|
+
|
|
281
|
+
return GenericLLM
|
|
282
|
+
if provider == Provider.GOOGLE_OAI:
|
|
283
|
+
from fast_agent.llm.provider.openai.llm_google_oai import GoogleOaiLLM
|
|
284
|
+
|
|
285
|
+
return GoogleOaiLLM
|
|
286
|
+
if provider == Provider.GOOGLE:
|
|
287
|
+
from fast_agent.llm.provider.google.llm_google_native import GoogleNativeLLM
|
|
288
|
+
|
|
289
|
+
return GoogleNativeLLM
|
|
290
|
+
if provider == Provider.XAI:
|
|
291
|
+
from fast_agent.llm.provider.openai.llm_xai import XAILLM
|
|
292
|
+
|
|
293
|
+
return XAILLM
|
|
294
|
+
if provider == Provider.OPENROUTER:
|
|
295
|
+
from fast_agent.llm.provider.openai.llm_openrouter import OpenRouterLLM
|
|
296
|
+
|
|
297
|
+
return OpenRouterLLM
|
|
298
|
+
if provider == Provider.TENSORZERO:
|
|
299
|
+
from fast_agent.llm.provider.openai.llm_tensorzero_openai import TensorZeroOpenAILLM
|
|
300
|
+
|
|
301
|
+
return TensorZeroOpenAILLM
|
|
302
|
+
if provider == Provider.AZURE:
|
|
303
|
+
from fast_agent.llm.provider.openai.llm_azure import AzureOpenAILLM
|
|
304
|
+
|
|
305
|
+
return AzureOpenAILLM
|
|
306
|
+
if provider == Provider.ALIYUN:
|
|
307
|
+
from fast_agent.llm.provider.openai.llm_aliyun import AliyunLLM
|
|
308
|
+
|
|
309
|
+
return AliyunLLM
|
|
310
|
+
if provider == Provider.BEDROCK:
|
|
311
|
+
from fast_agent.llm.provider.bedrock.llm_bedrock import BedrockLLM
|
|
312
|
+
|
|
313
|
+
return BedrockLLM
|
|
314
|
+
if provider == Provider.GROQ:
|
|
315
|
+
from fast_agent.llm.provider.openai.llm_groq import GroqLLM
|
|
316
|
+
|
|
317
|
+
return GroqLLM
|
|
318
|
+
except Exception as e:
|
|
319
|
+
raise ModelConfigError(
|
|
320
|
+
f"Provider '{provider.value}' is unavailable or missing dependencies: {e}"
|
|
321
|
+
)
|
|
322
|
+
raise ModelConfigError(f"Unsupported provider: {provider}")
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Typed model information helpers.
|
|
3
|
+
|
|
4
|
+
Provides a small, pythonic interface to query model/provider and
|
|
5
|
+
capabilities (Text/Document/Vision), backed by the model database.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from typing import TYPE_CHECKING, List, Optional, Union
|
|
12
|
+
|
|
13
|
+
from fast_agent.llm.model_database import ModelDatabase
|
|
14
|
+
from fast_agent.llm.provider_types import Provider
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
# Import behind TYPE_CHECKING to avoid import cycles at runtime
|
|
18
|
+
from fast_agent.interfaces import AgentProtocol, FastAgentLLMProtocol
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(frozen=True)
|
|
22
|
+
class ModelInfo:
|
|
23
|
+
"""Resolved model information with convenient capability accessors."""
|
|
24
|
+
|
|
25
|
+
name: str
|
|
26
|
+
provider: Provider
|
|
27
|
+
context_window: Optional[int]
|
|
28
|
+
max_output_tokens: Optional[int]
|
|
29
|
+
tokenizes: List[str]
|
|
30
|
+
json_mode: Optional[str]
|
|
31
|
+
reasoning: Optional[str]
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def supports_text(self) -> bool:
|
|
35
|
+
return ModelDatabase.supports_mime(self.name, "text/plain")
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def supports_document(self) -> bool:
|
|
39
|
+
# Document support currently keyed off PDF support
|
|
40
|
+
return ModelDatabase.supports_mime(self.name, "pdf")
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def supports_vision(self) -> bool:
|
|
44
|
+
# Any common image format indicates vision support
|
|
45
|
+
return any(
|
|
46
|
+
ModelDatabase.supports_mime(self.name, mt)
|
|
47
|
+
for mt in ("image/jpeg", "image/png", "image/webp")
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def tdv_flags(self) -> tuple[bool, bool, bool]:
|
|
52
|
+
"""Convenience tuple: (text, document, vision)."""
|
|
53
|
+
return (self.supports_text, self.supports_document, self.supports_vision)
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def from_llm(cls, llm: "FastAgentLLMProtocol") -> Optional["ModelInfo"]:
|
|
57
|
+
name = getattr(llm, "model_name", None)
|
|
58
|
+
provider = getattr(llm, "provider", None)
|
|
59
|
+
if not name or not provider:
|
|
60
|
+
return None
|
|
61
|
+
return cls.from_name(name, provider)
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def from_name(cls, name: str, provider: Provider | None = None) -> Optional["ModelInfo"]:
|
|
65
|
+
params = ModelDatabase.get_model_params(name)
|
|
66
|
+
if not params:
|
|
67
|
+
# Unknown model: return a conservative default that supports text only.
|
|
68
|
+
# This matches the desired behavior for TDV display fallbacks.
|
|
69
|
+
if provider is None:
|
|
70
|
+
provider = Provider.GENERIC
|
|
71
|
+
return ModelInfo(
|
|
72
|
+
name=name,
|
|
73
|
+
provider=provider,
|
|
74
|
+
context_window=None,
|
|
75
|
+
max_output_tokens=None,
|
|
76
|
+
tokenizes=["text/plain"],
|
|
77
|
+
json_mode=None,
|
|
78
|
+
reasoning=None,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
return ModelInfo(
|
|
82
|
+
name=name,
|
|
83
|
+
provider=provider or Provider.GENERIC,
|
|
84
|
+
context_window=params.context_window,
|
|
85
|
+
max_output_tokens=params.max_output_tokens,
|
|
86
|
+
tokenizes=params.tokenizes,
|
|
87
|
+
json_mode=params.json_mode,
|
|
88
|
+
reasoning=params.reasoning,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def get_model_info(
|
|
93
|
+
subject: Union["AgentProtocol", "FastAgentLLMProtocol", str, None],
|
|
94
|
+
provider: Provider | None = None,
|
|
95
|
+
) -> Optional[ModelInfo]:
|
|
96
|
+
"""Resolve a ModelInfo from an Agent, LLM, or model name.
|
|
97
|
+
|
|
98
|
+
Keeps the public API small while enabling type-safe access to model
|
|
99
|
+
capabilities across the codebase.
|
|
100
|
+
"""
|
|
101
|
+
if subject is None:
|
|
102
|
+
return None
|
|
103
|
+
|
|
104
|
+
# Agent → LLM
|
|
105
|
+
try:
|
|
106
|
+
from fast_agent.interfaces import AgentProtocol as _AgentProtocol
|
|
107
|
+
except Exception:
|
|
108
|
+
_AgentProtocol = None # type: ignore
|
|
109
|
+
|
|
110
|
+
if _AgentProtocol and isinstance(subject, _AgentProtocol): # type: ignore[arg-type]
|
|
111
|
+
return ModelInfo.from_llm(subject.llm)
|
|
112
|
+
|
|
113
|
+
# LLM → ModelInfo
|
|
114
|
+
try:
|
|
115
|
+
from fast_agent.interfaces import FastAgentLLMProtocol as _LLMProtocol
|
|
116
|
+
except Exception:
|
|
117
|
+
_LLMProtocol = None # type: ignore
|
|
118
|
+
|
|
119
|
+
if _LLMProtocol and isinstance(subject, _LLMProtocol): # type: ignore[arg-type]
|
|
120
|
+
return ModelInfo.from_llm(subject)
|
|
121
|
+
|
|
122
|
+
# String model name
|
|
123
|
+
if isinstance(subject, str):
|
|
124
|
+
return ModelInfo.from_name(subject, provider)
|
|
125
|
+
|
|
126
|
+
return None
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Utility functions for Anthropic integration with MCP.
|
|
3
3
|
|
|
4
|
-
Provides conversion between Anthropic message formats and
|
|
4
|
+
Provides conversion between Anthropic message formats and PromptMessageExtended,
|
|
5
5
|
leveraging existing code for resource handling and delimited formats.
|
|
6
6
|
"""
|
|
7
7
|
|
|
@@ -15,28 +15,28 @@ from mcp.types import (
|
|
|
15
15
|
TextResourceContents,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
from
|
|
18
|
+
from fast_agent.types import PromptMessageExtended
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
# TODO -- only used for saving, but this will be driven directly from PromptMessages
|
|
22
22
|
def anthropic_message_param_to_prompt_message_multipart(
|
|
23
23
|
message_param: MessageParam,
|
|
24
|
-
) ->
|
|
24
|
+
) -> PromptMessageExtended:
|
|
25
25
|
"""
|
|
26
|
-
Convert an Anthropic MessageParam to a
|
|
26
|
+
Convert an Anthropic MessageParam to a PromptMessageExtended.
|
|
27
27
|
|
|
28
28
|
Args:
|
|
29
29
|
message_param: The Anthropic MessageParam to convert
|
|
30
30
|
|
|
31
31
|
Returns:
|
|
32
|
-
A
|
|
32
|
+
A PromptMessageExtended representation
|
|
33
33
|
"""
|
|
34
34
|
role = message_param["role"]
|
|
35
35
|
content = message_param["content"]
|
|
36
36
|
|
|
37
37
|
# Handle string content (user messages can be simple strings)
|
|
38
38
|
if isinstance(content, str):
|
|
39
|
-
return
|
|
39
|
+
return PromptMessageExtended(role=role, content=[TextContent(type="text", text=content)])
|
|
40
40
|
|
|
41
41
|
# Convert content blocks to MCP content types
|
|
42
42
|
mcp_contents = []
|
|
@@ -81,4 +81,4 @@ def anthropic_message_param_to_prompt_message_multipart(
|
|
|
81
81
|
data = source.get("data", "")
|
|
82
82
|
mcp_contents.append(ImageContent(type="image", data=data, mimeType=media_type))
|
|
83
83
|
|
|
84
|
-
return
|
|
84
|
+
return PromptMessageExtended(role=role, content=mcp_contents)
|