MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / load_provider_config

Function load_provider_config

paperflow/providers/config.py:99–142  ·  view source on GitHub ↗

Read provider settings from the environment. The function is pure with respect to the current environment — it is fine to call repeatedly, and tests can monkeypatch ``os.environ``.

()

Source from the content-addressed store, hash-verified

97
98
99def load_provider_config() -> ProviderConfig:
100 """Read provider settings from the environment.
101
102 The function is pure with respect to the current environment — it is
103 fine to call repeatedly, and tests can monkeypatch ``os.environ``.
104 """
105
106 llm_provider = _normalize_llm_provider(
107 _first_env("PAPERFLOW_LLM_PROVIDER", "LLM_PARSER_PROVIDER")
108 )
109 llm_model = (
110 _first_env(
111 "PAPERFLOW_LLM_MODEL",
112 "LLM_PARSER_OPENAI_MODEL",
113 "DASHSCOPE_LLM_MODEL",
114 "HF_LLM_MODEL",
115 )
116 or _DEFAULT_LLM_MODEL[llm_provider]
117 )
118
119 embed_provider = _normalize_embed_provider(
120 _first_env("PAPERFLOW_EMBED_PROVIDER", "EMBEDDING_PROVIDER")
121 )
122 embed_model = (
123 _first_env("PAPERFLOW_EMBED_MODEL", "EMBEDDING_MODEL")
124 or _DEFAULT_EMBED_MODEL[embed_provider]
125 )
126
127 raw_dim = os.environ.get("PAPERFLOW_EMBED_DIMENSIONS", "").strip()
128 if raw_dim:
129 try:
130 embed_dimensions = int(raw_dim)
131 except ValueError:
132 embed_dimensions = _DEFAULT_EMBED_DIM[embed_provider]
133 else:
134 embed_dimensions = _DEFAULT_EMBED_DIM[embed_provider]
135
136 return ProviderConfig(
137 llm_provider=llm_provider,
138 llm_model=llm_model,
139 embed_provider=embed_provider,
140 embed_model=embed_model,
141 embed_dimensions=embed_dimensions,
142 )

Calls 5

_normalize_llm_providerFunction · 0.85
_first_envFunction · 0.85
ProviderConfigClass · 0.85
getMethod · 0.80