Spaces:
Runtime error
Runtime error
Commit
·
dd1d609
1
Parent(s):
12e8ac9
Fix switching between Azure/OpenAI; add port option
Browse files
app.py
CHANGED
|
@@ -46,12 +46,6 @@ Use this output format:
|
|
| 46 |
----
|
| 47 |
- [textual evidence 1] - book
|
| 48 |
- [textual evidence 2] - outside source"""
|
| 49 |
-
# 7. Make a section for each key point. In each section, make a bullet list of textual evidence from task 3 that relate to that key point.
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
class AzurePromptLayerChatOpenAI(AzureChatOpenAI, PromptLayerChatOpenAI):
|
| 53 |
-
pass
|
| 54 |
-
|
| 55 |
|
| 56 |
|
| 57 |
def load_chain(api_key, api_type):
|
|
@@ -68,16 +62,17 @@ def load_chain(api_key, api_type):
|
|
| 68 |
shared_args = {
|
| 69 |
"temperature": 0,
|
| 70 |
"model_name": "gpt-3.5-turbo",
|
| 71 |
-
"
|
| 72 |
"pl_tags": ["grammar"],
|
| 73 |
}
|
| 74 |
if api_type == "OpenAI":
|
| 75 |
llm = PromptLayerChatOpenAI(**shared_args)
|
| 76 |
elif api_type == "Azure OpenAI":
|
| 77 |
-
llm =
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
| 81 |
**shared_args
|
| 82 |
)
|
| 83 |
|
|
@@ -365,4 +360,4 @@ with demo:
|
|
| 365 |
|
| 366 |
demo.load(load_chain, [api_key, api_type], [chain, llm, chain_intro, chain_body1])
|
| 367 |
|
| 368 |
-
demo.launch(debug=True)
|
|
|
|
| 46 |
----
|
| 47 |
- [textual evidence 1] - book
|
| 48 |
- [textual evidence 2] - outside source"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
def load_chain(api_key, api_type):
|
|
|
|
| 62 |
shared_args = {
|
| 63 |
"temperature": 0,
|
| 64 |
"model_name": "gpt-3.5-turbo",
|
| 65 |
+
"api_key": api_key, # deliberately not use "openai_api_key" and other openai args since those apply globally
|
| 66 |
"pl_tags": ["grammar"],
|
| 67 |
}
|
| 68 |
if api_type == "OpenAI":
|
| 69 |
llm = PromptLayerChatOpenAI(**shared_args)
|
| 70 |
elif api_type == "Azure OpenAI":
|
| 71 |
+
llm = PromptLayerChatOpenAI(
|
| 72 |
+
api_type = "azure",
|
| 73 |
+
api_base = os.environ.get("AZURE_OPENAI_API_BASE", None),
|
| 74 |
+
api_version = os.environ.get("AZURE_OPENAI_API_VERSION", "2023-03-15-preview"),
|
| 75 |
+
engine = os.environ.get("AZURE_OPENAI_DEPLOYMENT_NAME", None),
|
| 76 |
**shared_args
|
| 77 |
)
|
| 78 |
|
|
|
|
| 360 |
|
| 361 |
demo.load(load_chain, [api_key, api_type], [chain, llm, chain_intro, chain_body1])
|
| 362 |
|
| 363 |
+
demo.launch(debug=True, server_port=int(os.environ.get("SERVER_PORT", None)))
|