MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / _call_llm_via_azure

Function _call_llm_via_azure

codewiki/src/be/llm_services.py:261–290  ·  view source on GitHub ↗

Call LLM via Azure OpenAI. Uses the AzureOpenAI client from the openai package with azure_endpoint, api_version, and deployment name.

(
    prompt: str,
    config: Config,
    model: str,
    temperature: float = 0.0
)

Source from the content-addressed store, hash-verified

259
260
261def _call_llm_via_azure(
262 prompt: str,
263 config: Config,
264 model: str,
265 temperature: float = 0.0
266) -> str:
267 """
268 Call LLM via Azure OpenAI.
269
270 Uses the AzureOpenAI client from the openai package with
271 azure_endpoint, api_version, and deployment name.
272 """
273 from openai import AzureOpenAI
274
275 client = AzureOpenAI(
276 api_key=config.llm_api_key,
277 api_version=config.api_version,
278 azure_endpoint=config.llm_base_url,
279 )
280
281 deployment = config.azure_deployment or model
282 logger.debug("Calling Azure OpenAI deployment %s (api_version=%s)", deployment, config.api_version)
283
284 response = client.chat.completions.create(
285 model=deployment,
286 messages=[{"role": "user", "content": prompt}],
287 temperature=temperature,
288 max_tokens=config.max_tokens,
289 )
290 return response.choices[0].message.content

Callers 1

call_llmFunction · 0.85

Calls 2

debugMethod · 0.80
createMethod · 0.80

Tested by

no test coverage detected