Skip to content

Commit 111b9bc

Browse files
Reverted app & function app codes done by psl
1 parent 0e4acec commit 111b9bc

File tree

2 files changed

+12
-45
lines changed

2 files changed

+12
-45
lines changed

ClientAdvisor/App/app.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@ async def stream_chat_request(request_body, request_headers):
970970
if client_id is None:
971971
return jsonify({"error": "No client ID provided"}), 400
972972
query = request_body.get("messages")[-1].get("content")
973-
query = query.strip()
974973

975974
async def generate():
976975
deltaText = ''
@@ -1550,24 +1549,24 @@ def get_users():
15501549
ClientSummary,
15511550
CAST(LastMeeting AS DATE) AS LastMeetingDate,
15521551
FORMAT(CAST(LastMeeting AS DATE), 'dddd MMMM d, yyyy') AS LastMeetingDateFormatted,
1553-
      FORMAT(LastMeeting, 'HH:mm ') AS LastMeetingStartTime,
1554-
FORMAT(LastMeetingEnd, 'HH:mm') AS LastMeetingEndTime,
1552+
      FORMAT(LastMeeting, 'hh:mm tt') AS LastMeetingStartTime,
1553+
FORMAT(LastMeetingEnd, 'hh:mm tt') AS LastMeetingEndTime,
15551554
CAST(NextMeeting AS DATE) AS NextMeetingDate,
15561555
FORMAT(CAST(NextMeeting AS DATE), 'dddd MMMM d, yyyy') AS NextMeetingFormatted,
1557-
FORMAT(NextMeeting, 'HH:mm') AS NextMeetingStartTime,
1558-
FORMAT(NextMeetingEnd, 'HH:mm') AS NextMeetingEndTime
1556+
FORMAT(NextMeeting, 'hh:mm tt') AS NextMeetingStartTime,
1557+
FORMAT(NextMeetingEnd, 'hh:mm tt') AS NextMeetingEndTime
15591558
FROM (
15601559
SELECT ca.ClientId, Client, Email, AssetValue, ClientSummary, LastMeeting, LastMeetingEnd, NextMeeting, NextMeetingEnd
15611560
FROM (
15621561
SELECT c.ClientId, c.Client, c.Email, a.AssetValue, cs.ClientSummary
15631562
FROM Clients c
1564-
JOIN (
1565-
SELECT a.ClientId, a.Investment AS AssetValue
1563+
JOIN (
1564+
SELECT a.ClientId, a.Investment AS AssetValue
15661565
FROM (
15671566
SELECT ClientId, sum(Investment) as Investment,
15681567
ROW_NUMBER() OVER (PARTITION BY ClientId ORDER BY AssetDate DESC) AS RowNum
15691568
FROM Assets
1570-
group by ClientId,AssetDate
1569+
        group by ClientId,AssetDate
15711570
) a
15721571
WHERE a.RowNum = 1
15731572
) a ON c.ClientId = a.ClientId
@@ -1642,4 +1641,4 @@ def get_users():
16421641
if conn:
16431642
conn.close()
16441643

1645-
app = create_app()
1644+
app = create_app()

ClientAdvisor/AzureFunction/function_app.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def greeting(self, input: Annotated[str, "the question"]) -> Annotated[str, "The
4040
client = openai.AzureOpenAI(
4141
azure_endpoint=endpoint,
4242
api_key=api_key,
43-
api_version=api_version
43+
api_version="2023-09-01-preview"
4444
)
4545
deployment = os.environ.get("AZURE_OPEN_AI_DEPLOYMENT_MODEL")
4646
try:
@@ -75,7 +75,7 @@ def get_SQL_Response(
7575
client = openai.AzureOpenAI(
7676
azure_endpoint=endpoint,
7777
api_key=api_key,
78-
api_version=api_version
78+
api_version="2023-09-01-preview"
7979
)
8080
deployment = os.environ.get("AZURE_OPEN_AI_DEPLOYMENT_MODEL")
8181

@@ -100,18 +100,6 @@ def get_SQL_Response(
100100
Do not include assets values unless asked for.
101101
Always use ClientId = {clientid} in the query filter.
102102
Always return client name in the query.
103-
If a question involves date and time, always use FORMAT(YourDateTimeColumn, 'yyyy-MM-dd HH:mm:ss') in the query.
104-
If asked, provide information about client meetings according to the requested timeframe: give details about upcoming meetings if asked for "next" or "upcoming" meetings, and provide details about past meetings if asked for "previous" or "last" meetings including the scheduled time and don't filter with "LIMIT 1" in the query.
105-
If asked about the number of past meetings with this client, provide the count of records where the ConversationId is neither null nor an empty string and the EndTime is before the current date in the query.
106-
If asked, provide a summary of the most recent meeting with the client from past dates in the query.
107-
If asked, provide information on the client's investment risk tolerance level in the query.
108-
If asked, provide information on the client's portfolio performance in the query.
109-
If asked, provide information about the client's top-performing investments in the query.
110-
If asked, provide information about any recent changes in the client's investment allocations in the query.
111-
If asked about the client's portfolio performance over the last quarter, calculate the total investment by summing the investment amounts where AssetDate is greater than or equal to the date from one quarter ago using DATEADD(QUARTER, -1, GETDATE()) in the query.
112-
If asked about upcoming important dates or deadlines for the client, always ensure that StartTime is greater than the current date. Do not convert the formats of StartTime and EndTime and consistently provide the upcoming dates along with the scheduled times in the query.
113-
To determine the asset value, sum the investment values for the most recent available date. If asked for the asset types in the portfolio and the present of each, provide a list of each asset type with its most recent investment value.
114-
If the user inquires about asset on a specific date ,sum the investment values for the specific date avoid summing values from all dates prior to the requested date.If asked for the asset types in the portfolio and the value of each for specific date , provide a list of each asset type with specific date investment value avoid summing values from all dates prior to the requested date.
115103
Only return the generated sql query. do not return anything else'''
116104
try:
117105

@@ -164,16 +152,12 @@ def get_answers_from_calltranscripts(
164152
client = openai.AzureOpenAI(
165153
azure_endpoint= endpoint, #f"{endpoint}/openai/deployments/{deployment}/extensions",
166154
api_key=apikey,
167-
api_version=api_version
155+
api_version="2024-02-01"
168156
)
169157

170158
query = question
171159
system_message = '''You are an assistant who provides wealth advisors with helpful information to prepare for client meetings.
172160
You have access to the client’s meeting call transcripts.
173-
When asked about action items from previous meetings with the client, **ALWAYS provide information only for the most recent dates**.
174-
If asked, consistently provide the summary of the last meeting with the client only for past dates.
175-
If asked to summarize each transcript, consistently provide a summary with Date and time for all available transcripts and ensure all call transcript's summary should returned with date and time. (i.e "First Call summary Date Time", "Second Call Summary Date Time" and so on.)
176-
Always return time in "HH:mm" format for the client in response.
177161
You can use this information to answer questions about the clients'''
178162

179163
completion = client.chat.completions.create(
@@ -232,7 +216,7 @@ def get_answers_from_calltranscripts(
232216

233217
answer = completion.choices[0].message.content
234218
return answer
235-
219+
236220
# Get data from Azure Open AI
237221
async def stream_processor(response):
238222
async for message in response:
@@ -277,25 +261,9 @@ async def stream_openai_text(req: Request) -> StreamingResponse:
277261

278262
system_message = '''you are a helpful assistant to a wealth advisor.
279263
Do not answer any questions not related to wealth advisors queries.
280-
If asked, provide information about client meetings according to the requested timeframe: give details about upcoming meetings if asked for "next" or "upcoming" meetings, and provide details about past meetings if asked for "previous" or "last" meetings including the scheduled time.
281-
If asked about the number of past meetings with this client, provide the count of records where the ConversationId is neither null nor an empty string and the EndTime is before the current date.
282-
If asked, provide a summary of the most recent meeting with the client from past dates.
283-
If asked, provide information on the client's investment risk tolerance level.
284-
If asked, provide information on the client's portfolio performance.
285-
If asked, provide the action items from the last or previous client meeting for past dates.
286-
If asked, provide information about the client's top-performing investments.
287-
If asked, provide information about any recent changes in the client's investment allocations.
288-
If asked about the client's portfolio performance over the last quarter, calculate the total investment by summing the investment amounts where AssetDate is greater than or equal to the date from one quarter ago using DATEADD(QUARTER, -1, GETDATE()).
289-
If asked about upcoming important dates or deadlines for the client, always ensure that StartTime is greater than the current date. Do not convert the formats of StartTime and EndTime and consistently provide the upcoming dates along with the scheduled times.
290-
If asked to summarize each transcript, provide a summary for all available transcripts and ensure all call transcript's summary should returned.
291-
Always recognize and respond to the selected client by their full name or common variations.
292-
Ensure responses are consistent and up-to-date, clearly stating the date of the data to avoid confusion
293-
If asked to summarize each transcript, provide a summary for all available transcripts and ensure all call transcript's summary should returned.
294264
If the client name and client id do not match, only return - Please only ask questions about the selected client or select another client to inquire about their details. do not return any other information.
295265
Only use the client name returned from database in the response.
296-
Always consider to give selected client full name only in response and do not use other example names also consider my client means currently selected client.
297266
If you cannot answer the question, always return - I cannot answer this question from the data available. Please rephrase or add more details.
298-
Do not include or specify any client IDs in the responses.
299267
** Remove any client identifiers or ids or numbers or ClientId in the final response.
300268
'''
301269

0 commit comments

Comments
 (0)