Update app.py
Browse files
app.py
CHANGED
|
@@ -164,8 +164,8 @@ class TextEditor:
|
|
| 164 |
class OpenAIApi:
|
| 165 |
def __init__(self, preprompt="", endpoint="https://T-App-GPT4o.openai.azure.com/", model="gpt-4o", api_key=None):
|
| 166 |
# Validate endpoint format
|
| 167 |
-
if not re.match(r"^https://[a-zA-Z0-9-]+\.openai\.com/?$", endpoint):
|
| 168 |
-
logger.warning(f"Endpoint format may be incorrect: {endpoint}. Expected format: https://<resource>.openai.azure.com/")
|
| 169 |
|
| 170 |
# Use a minimal httpx.Client to avoid proxies parameter
|
| 171 |
http_client = httpx.Client()
|
|
@@ -180,10 +180,10 @@ class OpenAIApi:
|
|
| 180 |
logger.error(f"Failed to initialize AzureOpenAI client: {str(e)}")
|
| 181 |
raise
|
| 182 |
self.model = model
|
| 183 |
-
self.preprompt =
|
| 184 |
self.memory = ConversationMemory()
|
| 185 |
self.editor = TextEditor(self.memory)
|
| 186 |
-
logger.info(f"Initialized OpenAIApi with
|
| 187 |
self.functions = [
|
| 188 |
{
|
| 189 |
"type": "function",
|
|
|
|
| 164 |
class OpenAIApi:
|
| 165 |
def __init__(self, preprompt="", endpoint="https://T-App-GPT4o.openai.azure.com/", model="gpt-4o", api_key=None):
|
| 166 |
# Validate endpoint format
|
| 167 |
+
if not re.match(r"^https://[a-zA-Z0-9-]+\.openai\.azure\.com/?$", endpoint):
|
| 168 |
+
logger.warning(f"Endpoint format may be incorrect: {endpoint}. Expected format: https://<resource-name>.openai.azure.com/")
|
| 169 |
|
| 170 |
# Use a minimal httpx.Client to avoid proxies parameter
|
| 171 |
http_client = httpx.Client()
|
|
|
|
| 180 |
logger.error(f"Failed to initialize AzureOpenAI client: {str(e)}")
|
| 181 |
raise
|
| 182 |
self.model = model
|
| 183 |
+
self.preprompt = preprompt
|
| 184 |
self.memory = ConversationMemory()
|
| 185 |
self.editor = TextEditor(self.memory)
|
| 186 |
+
logger.info(f"Initialized OpenAIApi with endpoint: {endpoint}, model: {model}, api_version: 2024-02-15-preview")
|
| 187 |
self.functions = [
|
| 188 |
{
|
| 189 |
"type": "function",
|