Spaces:
Sleeping
Sleeping
changed way of prompting
Browse files
app.py
CHANGED
|
@@ -12,18 +12,25 @@ import re
|
|
| 12 |
from starlette.middleware.base import BaseHTTPMiddleware
|
| 13 |
from starlette.requests import Request
|
| 14 |
from starlette.responses import Response
|
| 15 |
-
|
| 16 |
|
| 17 |
# Load environment variables from .env file
|
| 18 |
load_dotenv()
|
| 19 |
|
| 20 |
-
# Configure OpenAI for Azure
|
| 21 |
-
openai.api_type = "azure"
|
| 22 |
-
openai.api_base = "https://amplifai-openai.openai.azure.com/"
|
| 23 |
-
# openai.api_version = "2023-07-01-preview"
|
| 24 |
-
openai.api_version = "2024-08-01-preview"
|
| 25 |
-
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
|
|
|
| 27 |
|
| 28 |
DEEPGRAM_API_KEY = os.getenv("DEEPGRAM_API_KEY")
|
| 29 |
if not DEEPGRAM_API_KEY:
|
|
@@ -45,8 +52,8 @@ class GenerateResponse4(BaseModel):
|
|
| 45 |
|
| 46 |
#Summarize function
|
| 47 |
def summarize_text(text: str):
|
| 48 |
-
|
| 49 |
-
engine="AmplifAI-Chat",
|
| 50 |
prompt="The data is a pre-recorded conversation between a call center agent and a customer. Identify the following: keywords/metrics about the conversation, a summary of the conversation including details. Output should be in the format Keywords/Metrics: ,\n Summary:. \n Data: " + text,
|
| 51 |
temperature=0.7,
|
| 52 |
max_tokens=750,
|
|
|
|
| 12 |
from starlette.middleware.base import BaseHTTPMiddleware
|
| 13 |
from starlette.requests import Request
|
| 14 |
from starlette.responses import Response
|
| 15 |
+
from openai import AzureOpenAI
|
| 16 |
|
| 17 |
# Load environment variables from .env file
|
| 18 |
load_dotenv()
|
| 19 |
|
| 20 |
+
# # Configure OpenAI for Azure
|
| 21 |
+
# openai.api_type = "azure"
|
| 22 |
+
# openai.api_base = "https://amplifai-openai.openai.azure.com/"
|
| 23 |
+
# # openai.api_version = "2023-07-01-preview"
|
| 24 |
+
# openai.api_version = "2024-08-01-preview"
|
| 25 |
+
# openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 26 |
+
|
| 27 |
+
client = AzureOpenAI(
|
| 28 |
+
api_key=os.getenv("OPENAI_API_KEY"),
|
| 29 |
+
api_version="2024-08-01-preview",
|
| 30 |
+
azure_endpoint = os.getenv("https://amplifai-openai.openai.azure.com/")
|
| 31 |
+
)
|
| 32 |
|
| 33 |
+
deployment_name='AmplifAI-Chat'
|
| 34 |
|
| 35 |
DEEPGRAM_API_KEY = os.getenv("DEEPGRAM_API_KEY")
|
| 36 |
if not DEEPGRAM_API_KEY:
|
|
|
|
| 52 |
|
| 53 |
#Summarize function
|
| 54 |
def summarize_text(text: str):
|
| 55 |
+
response = client.completions.create(model = deployment_name,
|
| 56 |
+
#engine="AmplifAI-Chat",
|
| 57 |
prompt="The data is a pre-recorded conversation between a call center agent and a customer. Identify the following: keywords/metrics about the conversation, a summary of the conversation including details. Output should be in the format Keywords/Metrics: ,\n Summary:. \n Data: " + text,
|
| 58 |
temperature=0.7,
|
| 59 |
max_tokens=750,
|