MCPcopy Create free account
hub / github.com/Azure-Samples/llama-index-python / init_openai

Function init_openai

backend/app/settings.py:47–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45
46
47def init_openai():
48 from llama_index.llms.openai import OpenAI
49 from llama_index.embeddings.openai import OpenAIEmbedding
50 from llama_index.core.constants import DEFAULT_TEMPERATURE
51
52 max_tokens = os.getenv("LLM_MAX_TOKENS")
53 config = {
54 "model": os.getenv("MODEL"),
55 "temperature": float(os.getenv("LLM_TEMPERATURE", DEFAULT_TEMPERATURE)),
56 "max_tokens": int(max_tokens) if max_tokens is not None else None,
57 }
58 Settings.llm = OpenAI(**config)
59
60 dimensions = os.getenv("EMBEDDING_DIM")
61 config = {
62 "model": os.getenv("EMBEDDING_MODEL"),
63 "dimensions": int(dimensions) if dimensions is not None else None,
64 }
65 Settings.embed_model = OpenAIEmbedding(**config)
66
67
68def init_azure_openai():

Callers 1

init_settingsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected