Spaces:
Running
Running
Defaults to gpt-5-mini, Search prompt can be topic q: analysis
Browse files
app.py
CHANGED
@@ -713,6 +713,7 @@ def chat(prompt, user_window, pwd_window, past, response, gptModel, uploaded_ima
|
|
713 |
image_gen_model = 'gpt-4o-2024-08-06'
|
714 |
user_window = user_window.lower().strip()
|
715 |
isBoss = False
|
|
|
716 |
if not response:
|
717 |
response = ''
|
718 |
plot = gr.LinePlot(visible=False)
|
@@ -728,6 +729,8 @@ def chat(prompt, user_window, pwd_window, past, response, gptModel, uploaded_ima
|
|
728 |
if prompt.startswith('gpt4'):
|
729 |
gptModel = 'gpt-4o-2024-08-06'
|
730 |
prompt = prompt[5:]
|
|
|
|
|
731 |
if prompt.startswith("clean"):
|
732 |
user = prompt[6:]
|
733 |
response = f'cleaned all .wav and .b64 files for {user}'
|
@@ -779,6 +782,11 @@ def chat(prompt, user_window, pwd_window, past, response, gptModel, uploaded_ima
|
|
779 |
using_groq = False
|
780 |
reasoning = False
|
781 |
prompt = prompt.strip()
|
|
|
|
|
|
|
|
|
|
|
782 |
augmented_prompt = prompt
|
783 |
finish_reason = 'ok'
|
784 |
if prompt.lower().startswith('dsr1 '):
|
@@ -823,7 +831,9 @@ def chat(prompt, user_window, pwd_window, past, response, gptModel, uploaded_ima
|
|
823 |
augmented_prompt += 'Mention item source and item age for each item used\n'
|
824 |
elif mode == 'Search':
|
825 |
news = get_brave_search_results(prompt)
|
826 |
-
augmented_prompt = f'{news}\
|
|
|
|
|
827 |
past.append({"role":"user", "content":augmented_prompt})
|
828 |
gen_image = (uploaded_image_file != '')
|
829 |
if chatType in special_chat_types:
|
@@ -878,6 +888,8 @@ def chat(prompt, user_window, pwd_window, past, response, gptModel, uploaded_ima
|
|
878 |
tokens_in = completion.usage.prompt_tokens
|
879 |
tokens_out = completion.usage.completion_tokens
|
880 |
tokens = completion.usage.total_tokens
|
|
|
|
|
881 |
response += "\n\n***YOU***: " + prompt + "\n\n***GPT***: " + reply.replace('```','\n\n```\n\n')
|
882 |
if isBoss:
|
883 |
response += md(f"\n\n{reporting_model}: tokens in/out = {tokens_in}/{tokens_out}\n")
|
@@ -1072,7 +1084,8 @@ def show_help():
|
|
1072 |
1.3 Text in the "Dialog" window can be spoken by tapping the "Speak Dialog" button.
|
1073 |
2. Select Mode:
|
1074 |
2.1 Chat mode interacts with the GPT model with info limited to October 2023, when last trained.
|
1075 |
-
2.2 Search mode searches the internet for info using your prompt as search key.
|
|
|
1076 |
2.3 News mode searches the internet for news posted within the period selected in "News Window"
|
1077 |
3. Chat:
|
1078 |
3.1 Enter prompt and tap the "Submit Prompt/Question" button. The responses appear in the Dialog window.
|
@@ -1168,7 +1181,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
1168 |
history = gr.State([])
|
1169 |
password = gr.State("")
|
1170 |
user = gr.State("unknown")
|
1171 |
-
model = gr.State("gpt-4o-mini")
|
1172 |
q = gr.State([])
|
1173 |
qsave = gr.State([])
|
1174 |
uploaded_image_file = gr.State('')
|
|
|
713 |
image_gen_model = 'gpt-4o-2024-08-06'
|
714 |
user_window = user_window.lower().strip()
|
715 |
isBoss = False
|
716 |
+
query = ''
|
717 |
if not response:
|
718 |
response = ''
|
719 |
plot = gr.LinePlot(visible=False)
|
|
|
729 |
if prompt.startswith('gpt4'):
|
730 |
gptModel = 'gpt-4o-2024-08-06'
|
731 |
prompt = prompt[5:]
|
732 |
+
if prompt.startswith('gpt4m'):
|
733 |
+
gptModel = 'gpt-4o-mini'
|
734 |
if prompt.startswith("clean"):
|
735 |
user = prompt[6:]
|
736 |
response = f'cleaned all .wav and .b64 files for {user}'
|
|
|
782 |
using_groq = False
|
783 |
reasoning = False
|
784 |
prompt = prompt.strip()
|
785 |
+
if mode == 'Search':
|
786 |
+
loc = prompt.find('q:')
|
787 |
+
if loc > -1:
|
788 |
+
query = prompt[loc+2:]
|
789 |
+
prompt = prompt[0:loc]
|
790 |
augmented_prompt = prompt
|
791 |
finish_reason = 'ok'
|
792 |
if prompt.lower().startswith('dsr1 '):
|
|
|
831 |
augmented_prompt += 'Mention item source and item age for each item used\n'
|
832 |
elif mode == 'Search':
|
833 |
news = get_brave_search_results(prompt)
|
834 |
+
augmented_prompt = f'{news}\nThe topic is: {prompt}\nGive highest priority to information just provided\n'
|
835 |
+
augmented_prompt += ' \n' + query
|
836 |
+
augmented_prompt += ' \n Do not use Latex for math expressions.'
|
837 |
past.append({"role":"user", "content":augmented_prompt})
|
838 |
gen_image = (uploaded_image_file != '')
|
839 |
if chatType in special_chat_types:
|
|
|
888 |
tokens_in = completion.usage.prompt_tokens
|
889 |
tokens_out = completion.usage.completion_tokens
|
890 |
tokens = completion.usage.total_tokens
|
891 |
+
if len(query) > 0:
|
892 |
+
prompt = 'Search topic = ' + prompt + ', query = ' + query
|
893 |
response += "\n\n***YOU***: " + prompt + "\n\n***GPT***: " + reply.replace('```','\n\n```\n\n')
|
894 |
if isBoss:
|
895 |
response += md(f"\n\n{reporting_model}: tokens in/out = {tokens_in}/{tokens_out}\n")
|
|
|
1084 |
1.3 Text in the "Dialog" window can be spoken by tapping the "Speak Dialog" button.
|
1085 |
2. Select Mode:
|
1086 |
2.1 Chat mode interacts with the GPT model with info limited to October 2023, when last trained.
|
1087 |
+
2.2 Search mode searches the internet for info using your prompt as search key. Optionally you
|
1088 |
+
can enter the prompt in the form \<search topic\> **q:** \<desired analysis/question\>
|
1089 |
2.3 News mode searches the internet for news posted within the period selected in "News Window"
|
1090 |
3. Chat:
|
1091 |
3.1 Enter prompt and tap the "Submit Prompt/Question" button. The responses appear in the Dialog window.
|
|
|
1181 |
history = gr.State([])
|
1182 |
password = gr.State("")
|
1183 |
user = gr.State("unknown")
|
1184 |
+
model = gr.State('gpt-5-mini') #"gpt-4o-mini")
|
1185 |
q = gr.State([])
|
1186 |
qsave = gr.State([])
|
1187 |
uploaded_image_file = gr.State('')
|