Skip to content

Commit

Permalink
0630
Browse files Browse the repository at this point in the history
1
  • Loading branch information
BarryYin committed Jun 30, 2024
1 parent 735cdfd commit c7a41df
Show file tree
Hide file tree
Showing 4,369 changed files with 203 additions and 1,249,314 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion agentscope
Submodule agentscope deleted from ff919e
7 changes: 5 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import os

os.system('pip install -e ./agentscope')

#os.system('pip install -e ./agentscope')
base_path = './internlm2-chat-7b'
os.system(f'git clone https://code.openxlab.org.cn/OpenLMLab/internlm2-chat-7b.git {base_path}')
os.system(f'cd {base_path} && git lfs pull')
os.system(f'lmdeploy serve api_server {base_path} --server-port 23333')
os.system('python app_game_5.py')


150 changes: 68 additions & 82 deletions app_game_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,13 @@
import datetime
import random
import uuid
from agents.text2audio_agent import Text2AudioAgent
from agents.text2image_agent import Text2ImageAgent
#from agents.text2audio_agent import Text2AudioAgent
#from agents.text2image_agent import Text2ImageAgent
import mimetypes


import os
# download internlm2 to the base_path directory using git tool
base_path = './internlm2-chat-7b'
os.system(f'git clone https://code.openxlab.org.cn/OpenLMLab/internlm2-chat-7b.git {base_path}')
os.system(f'cd {base_path} && git lfs pull')
os.system(f'lmdeploy lite auto_awq \
{base_path}\
--calib-dataset 'ptb' \
--calib-samples 128 \
--calib-seqlen 1024 \
--w-bits 4 \
--w-group-size 128 \
--work-dir /root/internlm2-chat-1_8b-4bit')

def generate_uid():
uid = str(uuid.uuid4())
#state[uid] = 0
state[uid] = init_game(uid)
state[uid] = init_game(uuid)
print(f"Generated new UID: {uid}")
for key, value in state.items():
print(f'state["{key}"] = {value}')
Expand Down Expand Up @@ -153,17 +137,17 @@ def handle_request(state):



text2image = Text2ImageAgent(
name="image",
model_config_name="qwen",
sys_prompt="你是一个图片助手",
)
#text2image = Text2ImageAgent(
# name="image",
# model_config_name="qwen",
# sys_prompt="你是一个图片助手",
#)

text2audio = Text2AudioAgent(
name="audio",
model_config_name="qwen",
sys_prompt="你是一个音频助手",
)
#text2audio = Text2AudioAgent(
# name="audio",
# model_config_name="qwen",
# sys_prompt="你是一个音频助手",
#)



Expand All @@ -186,13 +170,13 @@ def handle_request(state):
this format is forbitten, don't show 'json'
"""

imgmaker = DictDialogAgent(
name="imgmaker1",
model_config_name="qwen",
#model_config_name="qwen",
use_memory=True,
sys_prompt=sys_img_prompt,
)
# imgmaker = DictDialogAgent(
# name="imgmaker1",
# model_config_name="qwen",
# #model_config_name="qwen",
# use_memory=True,
# sys_prompt=sys_img_prompt,
# )


haiguitang_user = UserAgent()
Expand Down Expand Up @@ -691,7 +675,8 @@ def init_game(uid1):
state[uid]['piece_white'] = NAME_TO_PIECE[NAME_WHITE]
state[uid]['black'] = GomokuAgent(
NAME_BLACK,
model_config_name=YOUR_MODEL_CONFIGURATION_NAME,
#model_config_name=YOUR_MODEL_CONFIGURATION_NAME,
model_config_name= "InternLM2",
sys_prompt=SYS_PROMPT_TEMPLATE.format(state[uid]['piece_black'], state[uid]['piece_white']),
)
state[uid]['white'] = GomokuAgent(
Expand Down Expand Up @@ -1098,20 +1083,20 @@ def reply(self, x: Optional[dict] = None) -> dict:
# Prepare the model configuration


YOUR_MODEL_CONFIGURATION_NAME = "qwen"
YOUR_MODEL_CONFIGURATION = {
"model_type": "dashscope_chat",
"config_name": YOUR_MODEL_CONFIGURATION_NAME,
"model_name": "qwen-max",
"api_key": model_configs[0]["api_key"],
"generate_args": {
"temperature": 0.1
}
}
# YOUR_MODEL_CONFIGURATION_NAME = "qwen"
# YOUR_MODEL_CONFIGURATION = {
# "model_type": "dashscope_chat",
# "config_name": YOUR_MODEL_CONFIGURATION_NAME,
# "model_name": "qwen-max",
# "api_key": model_configs[0]["api_key"],
# "generate_args": {
# "temperature": 0.1
# }
# }


# Initialize the agents
agentscope.init(model_configs=YOUR_MODEL_CONFIGURATION)
#agentscope.init(model_configs=YOUR_MODEL_CONFIGURATION)



Expand Down Expand Up @@ -1457,38 +1442,8 @@ def updateimg(uid):

game_tabs = gr.Tabs(visible=True)
with game_tabs:
main_tab = gr.Tab('海龟汤游戏', id=0)
with main_tab:
gr.Markdown(value=title_text_haiguitang)
#state = gr.State(value=initstate())
# 开始游戏按钮
with gr.Row():
start_btn_haituitang = gr.Button(value="开始游戏")
with gr.Row():

with gr.Column():
haiguitang_user_chatbot = gr.Chatbot(
height=500,
value=[[None,'您好,欢迎来到海龟汤游戏,如果你准备好了,请点击上方「开始」按钮']],
elem_classes="app-chatbot",
avatar_images=[host_avatar, user_avatar, parti_avatar,judge_avatar],
label="游戏进程观察区",
show_label=True,
bubble_full_width=False,
)

with gr.Row():
with gr.Column(scale=12):
haiguitang_chat_input = gr.Textbox(
label='user_chat_input',
show_label=False,
placeholder='在这里参与游戏')
with gr.Column(min_width=70, scale=1):
haiguitang_send_button = gr.Button('📣发送', variant='primary')

with gr.Row():
return_welcome_button_haiguitang = gr.Button(value="↩️返回首页")
main_tab1 = gr.Tab('谁是卧底', id=1)

main_tab1 = gr.Tab('谁是卧底', id=0)
with main_tab1:
gr.Markdown(value=title_text)
#state = gr.State(value=initstate())
Expand Down Expand Up @@ -1533,7 +1488,38 @@ def updateimg(uid):
player4_vote = gr.Textbox(label="Player 4 指认框", interactive=False,visible=False)
vote_btn = gr.Button(value="确认投票(即使你被淘汰了,你可以继续观战,看看自己一方到底赢了没)")
with gr.Row():
return_welcome_button_wodi = gr.Button(value="↩️返回首页")
return_welcome_button_wodi = gr.Button(value="↩️返回首页")
main_tab = gr.Tab('海龟汤游戏', id=1)
with main_tab:
gr.Markdown(value=title_text_haiguitang)
#state = gr.State(value=initstate())
# 开始游戏按钮
with gr.Row():
start_btn_haituitang = gr.Button(value="开始游戏")
with gr.Row():

with gr.Column():
haiguitang_user_chatbot = gr.Chatbot(
height=500,
value=[[None,'您好,欢迎来到海龟汤游戏,如果你准备好了,请点击上方「开始」按钮']],
elem_classes="app-chatbot",
avatar_images=[host_avatar, user_avatar, parti_avatar,judge_avatar],
label="游戏进程观察区",
show_label=True,
bubble_full_width=False,
)

with gr.Row():
with gr.Column(scale=12):
haiguitang_chat_input = gr.Textbox(
label='user_chat_input',
show_label=False,
placeholder='在这里参与游戏')
with gr.Column(min_width=70, scale=1):
haiguitang_send_button = gr.Button('📣发送', variant='primary')

with gr.Row():
return_welcome_button_haiguitang = gr.Button(value="↩️返回首页")
main_tab2 = gr.Tab('猜谜语', id=2)
with main_tab2:
gr.Markdown('# <center> \N{fire} 和AI猜谜语</center>')
Expand Down Expand Up @@ -1660,7 +1646,7 @@ def updateimg(uid):
demo.load(fn=generate_uid, inputs=[], outputs=[uidinput])

demo.queue(default_concurrency_limit=None)
demo.launch(max_threads=400,share=False)
demo.launch(max_threads=400,share=False,debug=True)

#if __name__ == '__main__':
#demo.launch()
Expand Down
Loading

0 comments on commit c7a41df

Please sign in to comment.