File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,5 +21,7 @@ AUTH_PORT=8081
2121
2222# AI Service
2323AI_SERVICE_PORT = 5000
24- OPENAI_API_KEY = " <key>"
25- AI_MODEL = gpt-4o-mini
24+ AZURE_ENDPOINT = https://your-azure-endpoint.openai.azure.com/
25+ AZURE_DEPLOYMENT_NAME = your-deployment-name
26+ AZURE_API_VERSION = 2024-06-01-preview
27+ AZURE_API_KEY = your-azure-api-key
Original file line number Diff line number Diff line change 1- from langchain_openai import AzureOpenAI
1+ from langchain_openai import AzureChatOpenAI
22from langchain .chat_models .base import BaseChatModel
33from app .settings import settings
44
55class LLMService :
66 model : BaseChatModel
77
88 def __init__ (self ):
9- self .model = AzureOpenAI (
9+ self .model = AzureChatOpenAI (
1010 temperature = 0.7 ,
11- model_name = "gpt-5-mini" ,
12- api_key = settings .OPENAI_API_KEY
11+ api_key = settings .AZURE_API_KEY ,
12+ azure_endpoint = settings .AZURE_ENDPOINT ,
13+ azure_deployment = settings .AZURE_DEPLOYMENT_NAME ,
14+ api_version = settings .AZURE_API_VERSION ,
1315 )
1416
1517 async def generate_content (self , prompt : str ) -> str :
1618 response = await self .model .ainvoke (prompt )
1719 return response .content
1820
19- llm_service = LLMService ()
21+ llm_service = LLMService ()
Original file line number Diff line number Diff line change 1- from pydantic_settings import BaseSettings
1+ from pydantic_settings import BaseSettings , SettingsConfigDict
2+
23
34class Settings (BaseSettings ):
4- OPENAI_API_KEY : str = ""
5-
6- class Config :
7- env_file = ".env"
5+ AZURE_API_KEY : str = ""
6+ AZURE_ENDPOINT : str = ""
7+ AZURE_DEPLOYMENT_NAME : str = ""
8+ AZURE_API_VERSION : str = ""
9+
10+ model_config = SettingsConfigDict (env_file = ".env" , env_file_encoding = "utf-8" )
11+
812
9- settings = Settings ()
13+ settings = Settings ()
Original file line number Diff line number Diff line change @@ -22,8 +22,10 @@ services:
2222 volumes :
2323 - overlap_data:/code/data
2424 environment :
25- OPENAI_API_KEY : ${OPENAI_API_KEY}
26- AI_MODEL : ${AI_MODEL}
25+ AZURE_API_KEY : ${AZURE_API_KEY}
26+ AZURE_ENDPOINT : ${AZURE_ENDPOINT}
27+ AZURE_DEPLOYMENT_NAME : ${AZURE_DEPLOYMENT_NAME}
28+ AZURE_API_VERSION : ${AZURE_API_VERSION}
2729 ports :
2830 - " ${AI_SERVICE_PORT}:5000"
2931 networks :
Original file line number Diff line number Diff line change @@ -37,8 +37,10 @@ services:
3737 volumes :
3838 - overlap_data:/code/data
3939 environment :
40- OPENAI_API_KEY : ${OPENAI_API_KEY}
41- AI_MODEL : ${AI_MODEL}
40+ AZURE_API_KEY : ${AZURE_API_KEY}
41+ AZURE_ENDPOINT : ${AZURE_ENDPOINT}
42+ AZURE_DEPLOYMENT_NAME : ${AZURE_DEPLOYMENT_NAME}
43+ AZURE_API_VERSION : ${AZURE_API_VERSION}
4244 ports :
4345 - " ${AI_SERVICE_PORT}:5000"
4446 networks :
You can’t perform that action at this time.
0 commit comments