Spaces:
Sleeping
Sleeping
ApnaCricketTeam
commited on
Commit
•
dc2c23f
1
Parent(s):
7583869
Update app.py
Browse files
app.py
CHANGED
@@ -22,10 +22,9 @@ def make_msg_chunk_ai(history,team_dropdown,all_teams_df,batting_team,batting_sc
|
|
22 |
req_params = {'flag':os.environ.get("FLAG")}
|
23 |
url = os.environ["FLASK_AI_PROMPT"]
|
24 |
response = requests.post(url, json=req_params)
|
25 |
-
print(response)
|
26 |
-
print(response.json())
|
27 |
full_data = response.json()
|
28 |
system_message=full_data['ai_data']
|
|
|
29 |
temp_df = all_teams_df[all_teams_df["team_id"]==team_dropdown]
|
30 |
temp_df = temp_df.drop(["team_id","player_code"],axis=1)
|
31 |
cur_tem_selection = temp_df[["player_name","role_type","team"]]
|
@@ -45,8 +44,9 @@ def user(user_message, history):
|
|
45 |
return "", history + [[user_message, None]]
|
46 |
|
47 |
def bot(history,team_dropdown,all_teams_df,batting_team,batting_score,chase):
|
48 |
-
print(history,"====This is history")
|
49 |
bot_templete = make_msg_chunk_ai(history,team_dropdown,all_teams_df,batting_team,batting_score,chase)
|
|
|
50 |
stream = client.chat.completions.create(
|
51 |
model="gpt-4-1106-preview",
|
52 |
messages=bot_templete,
|
@@ -55,6 +55,8 @@ def bot(history,team_dropdown,all_teams_df,batting_team,batting_score,chase):
|
|
55 |
for chunk in stream:
|
56 |
if chunk.choices[0].delta.content is not None:
|
57 |
history[-1][1]+=chunk.choices[0].delta.content
|
|
|
|
|
58 |
yield history
|
59 |
|
60 |
|
@@ -203,7 +205,7 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="amber", secondary_hue="pink"
|
|
203 |
team_dropdown.change(fn=display_selected_df, inputs=[team_dropdown,all_teams_df], outputs=[html_data,basic_status])
|
204 |
|
205 |
|
206 |
-
html_data.change(fn=put_df2use,inputs=html_data,outputs=curr_team_data)
|
207 |
|
208 |
btn.click(fn=activate_chat,inputs=[chat_bot,user_msg,clear_btn],outputs=[chat_bot,user_msg,clear_btn])
|
209 |
|
@@ -215,7 +217,7 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="amber", secondary_hue="pink"
|
|
215 |
team_dropdown.change(lambda: None, None,thread_id)
|
216 |
chat_bot.like(fn=save_like_data)
|
217 |
|
218 |
-
|
219 |
demo.launch(share=False)
|
220 |
|
221 |
|
|
|
22 |
req_params = {'flag':os.environ.get("FLAG")}
|
23 |
url = os.environ["FLASK_AI_PROMPT"]
|
24 |
response = requests.post(url, json=req_params)
|
|
|
|
|
25 |
full_data = response.json()
|
26 |
system_message=full_data['ai_data']
|
27 |
+
print("Got Ai Data : ",system_message,"\n====SYSTEM MESSAGE")
|
28 |
temp_df = all_teams_df[all_teams_df["team_id"]==team_dropdown]
|
29 |
temp_df = temp_df.drop(["team_id","player_code"],axis=1)
|
30 |
cur_tem_selection = temp_df[["player_name","role_type","team"]]
|
|
|
44 |
return "", history + [[user_message, None]]
|
45 |
|
46 |
def bot(history,team_dropdown,all_teams_df,batting_team,batting_score,chase):
|
47 |
+
print(len(history),"====This is history")
|
48 |
bot_templete = make_msg_chunk_ai(history,team_dropdown,all_teams_df,batting_team,batting_score,chase)
|
49 |
+
print("Made bot templete")
|
50 |
stream = client.chat.completions.create(
|
51 |
model="gpt-4-1106-preview",
|
52 |
messages=bot_templete,
|
|
|
55 |
for chunk in stream:
|
56 |
if chunk.choices[0].delta.content is not None:
|
57 |
history[-1][1]+=chunk.choices[0].delta.content
|
58 |
+
time.sleep(0.09)
|
59 |
+
print(history)
|
60 |
yield history
|
61 |
|
62 |
|
|
|
205 |
team_dropdown.change(fn=display_selected_df, inputs=[team_dropdown,all_teams_df], outputs=[html_data,basic_status])
|
206 |
|
207 |
|
208 |
+
# html_data.change(fn=put_df2use,inputs=html_data,outputs=curr_team_data)
|
209 |
|
210 |
btn.click(fn=activate_chat,inputs=[chat_bot,user_msg,clear_btn],outputs=[chat_bot,user_msg,clear_btn])
|
211 |
|
|
|
217 |
team_dropdown.change(lambda: None, None,thread_id)
|
218 |
chat_bot.like(fn=save_like_data)
|
219 |
|
220 |
+
demo.queue(default_concurrency_limit=3)
|
221 |
demo.launch(share=False)
|
222 |
|
223 |
|