Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translate comments in Chinese to English for broader users #123

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions XAgentServer/database/dbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_user(self, user_id: str | None = None, email: str | None = None) -> XAge
user = self.db.query(User).filter(User.email == email, User.deleted == False).first()
else:
user = self.db.query(User).filter(User.user_id == user_id, User.deleted == False).first()

return XAgentUser.from_db(user) if user else None

def user_is_exist(self, user_id: str | None = None, email: str | None = None):
Expand Down Expand Up @@ -119,7 +119,7 @@ def init(self):
not use
"""
raise NotImplementedError


def get_interaction_dict_list(self):
raise NotImplementedError
Expand All @@ -134,7 +134,7 @@ def get_interaction(self, interaction_id: str) -> InteractionBase | None:

def create_interaction(self, base: InteractionBase) -> InteractionBase:
"""
创建一个对话
create an interaction
"""
try:
self.db.add(Interaction(**base.to_dict()))
Expand All @@ -143,10 +143,10 @@ def create_interaction(self, base: InteractionBase) -> InteractionBase:
self.db.rollback()
print(traceback.print_exec())
return None

def add_parameter(self, parameter: InteractionParameter):
"""
创建一个对话
add a parameter
"""
try:
self.db.add(Parameter(**parameter.to_dict()))
Expand All @@ -159,7 +159,7 @@ def add_parameter(self, parameter: InteractionParameter):

def get_interaction_by_user_id(self, user_id: str, page_size: int = 20, page_num: int = 1) -> list[dict]:
"""
查看对话历史
check if the user has an interaction
"""
total = self.db.query(func.count(Interaction.id)).filter(Interaction.user_id == user_id, Interaction.is_deleted == False).scalar()
interaction_list = self.db.query(Interaction).filter(Interaction.user_id == user_id, Interaction.is_deleted == False).limit(page_size).offset((page_num - 1) * page_size).all()
Expand All @@ -173,11 +173,11 @@ def get_interaction_by_user_id(self, user_id: str, page_size: int = 20, page_num
"total": total,
"rows": data
}


def get_shared_interactions(self, page_size: int = 20, page_num: int = 1) -> list[dict]:
"""
获取社区分享的数据
get shared interactions
"""
total = self.db.query(func.count(SharedInteraction.id)).filter(SharedInteraction.is_deleted == False).scalar()
interaction_list = self.db.query(SharedInteraction).filter(SharedInteraction.is_deleted == False).order_by(SharedInteraction.star.desc()).limit(page_size).offset((page_num - 1) * page_size).all()
Expand All @@ -191,7 +191,7 @@ def get_shared_interactions(self, page_size: int = 20, page_num: int = 1) -> lis
"total": total,
"rows": data
}

def get_shared_interaction(self, interaction_id: str) -> SharedInteractionBase | None:
interaction = self.db.query(SharedInteraction).filter(SharedInteraction.interaction_id == interaction_id, SharedInteraction.is_deleted == False).first()
return SharedInteractionBase.from_db(interaction) if interaction else None
Expand All @@ -200,7 +200,7 @@ def get_shared_interaction(self, interaction_id: str) -> SharedInteractionBase |
def interaction_is_exist(self, interaction_id: str) -> bool:
interaction = self.db.query(Interaction).filter(Interaction.interaction_id == interaction_id, Interaction.is_deleted == False).first()
return interaction is not None


def update_interaction(self, base_data: dict):
try:
Expand Down Expand Up @@ -244,11 +244,11 @@ def update_interaction_parameter(self, interaction_id: str, parameter: Interacti
def is_running(self, user_id: str):
interaction = self.db.query(Interaction).filter(Interaction.user_id == user_id, Interaction.status.in_(("running", "waiting"))).first()
return interaction is not None

def get_parameter(self, interaction_id: str):
parameters = self.db.query(Parameter).filter(Parameter.interaction_id == interaction_id).all()
return [InteractionParameter.from_db(param) for param in parameters]

def delete_interaction(self, interaction_id: str):
try:
interaction = self.db.query(Interaction).filter(Interaction.interaction_id == interaction_id).first()
Expand All @@ -266,4 +266,4 @@ def add_share(self, shared: SharedInteractionBase):
self.db.commit()
except Exception as e:
self.db.rollback()
print(traceback.print_exec())
print(traceback.print_exec())
4 changes: 2 additions & 2 deletions XAgentServer/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ http {
server {
listen 5173;
server_name 127.0.0.1;
#此处是前端的请求
# This is frontend request
location / {
root /app/dist;
index index.html;
try_files $uri $uri/ /index.html;
}
#动态请求 这个是后端的请求
# Dynamic request. This is Backend request
location /api {
proxy_pass http://127.0.0.1:8090;
proxy_set_header Host $host;
Expand Down
2 changes: 1 addition & 1 deletion XAgentWeb/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const start = async () => {
}
// setupClickOutsideDirective(app)

// 当路由准备好时再执行挂载( https://next.router.vuejs.org/api/#isready)
// Load when the router is ready( https://next.router.vuejs.org/api/#isready)
await router.isReady()

app.mount('#app', true)
Expand Down
2 changes: 1 addition & 1 deletion XAgentWeb/src/router/guard/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const createPermissionGuard = (router: Router) => {
// return
const isMobile = /Mobi|Android|iPhone/i.test(navigator.userAgent)
if (isMobile && to.path !== '/mobile') {
// 当前设备是移动设备
// current device is mobile
next('/mobile')
return
}
Expand Down
1 change: 0 additions & 1 deletion XAgentWeb/src/store/modules/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface UserState {
export const useUserStore = defineStore('user', {
state: (): UserState => {
return {
// 用户信息
userInfo: null,
roleList: [],
lastUpdateTime: 0,
Expand Down
4 changes: 2 additions & 2 deletions XAgentWeb/src/utils/throttle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// }, delay);
// };
// }
// 基于计时器的节流
// Throttle based on timer

const throttle = (fn: Function, delay: number) => {
let prev = Date.now();
Expand All @@ -24,6 +24,6 @@ const throttle = (fn: Function, delay: number) => {
}
};
}
// 基于时间的节流
// Throttle based on time

export default throttle;
2 changes: 1 addition & 1 deletion XAgentWeb/src/views/exception/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
<span>API Open Platform</span>

<!-- 请在PC端进行访问试用 -->
<!-- Try out on desktop -->
<p class="tip">Please visit and try out on PC</p>
</div>
</template>
Expand Down
8 changes: 4 additions & 4 deletions XAgentWeb/src/views/login/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<span class="link-btn" @click="freeTrial">Registration-Free Trial</span>
</div> -->

<!-- TODO: 微信登录 -->
<!-- TODO: Login with Wechat -->
<div class="tip" v-show="false">
Your applying for registration constitutes your acceptance of our
<a target="_blank" href="javascript:void(0)">
Expand Down Expand Up @@ -162,7 +162,7 @@ const changePhone = async () => {
// loginFormStatus.code.isFormatError = false
// loginFormStatus.code.isRequired = false
// if (loginForm.email.length === 11) {
// // TODO: 检验电话号码是否存在
// // TODO: Check if phone number exists
// const res: any = await useCheckPhoneRequest({ mobile: loginForm.email })

// if (res?.code !== 0) {
Expand Down Expand Up @@ -208,7 +208,7 @@ const getVerifyCode = async () => {
// codeTime.smsCode--
// if (codeTime.smsCode === 0) clearInterval(timer)
// }, 1000)
// // TODO: 获取验证码
// // TODO: Obtain verification code
const res: any = await useMobileCodeRequest({ mobile: loginForm.email, scene: 2 })
if (res?.code === 0) {
ElMessage({ type: 'success', message: 'Send successfully' })
Expand Down Expand Up @@ -267,7 +267,7 @@ const submit = async () => {

const res: any = await useLoginRequest(param);
isSubmitLoading.value = false

if (res?.success || res?.message === 'success') {
userStore.setUserInfo(res?.data)
authStore.setLoginState(true)
Expand Down
26 changes: 13 additions & 13 deletions XAgentWeb/src/views/playground/chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
@disconnect="disConnectWebsocket"
@runSubtask="RunNextSubtask"
@runInner="RunNextinnerNode"
:isLatest = "isLatest"
:pageMode = "pageMode"
:isLatest="isLatest"
:pageMode="pageMode"
/>
</div>
<div class="feedback-wrapper flex-row">
Expand Down Expand Up @@ -64,7 +64,7 @@
</el-button>
</div> -->
<div class="warning flex-row"><a href="" target="_blank">
Disclaimer: The content is probabilistically generated by the model,
Disclaimer: The content is probabilistically generated by the model,
and does NOT represent the developer's viewpoint
</a></div>
</div>
Expand Down Expand Up @@ -92,7 +92,7 @@ const { proxy: global_instance } = getCurrentInstance() as any
const route = useRoute()
const router = useRouter()

// 根据conversionId查询历史对话
// Query historical conversation by conversionId

const chatMsgInfo = ref<ChatMsgInfoInf[]>([])

Expand All @@ -109,13 +109,13 @@ let ws: WebSocket | null = null;

let pageMode = computed(() => {
if(!route.query || !route.query.mode) {
if(route.params && route.params.mode)
if(route.params && route.params.mode)
{
return route.params.mode as string;
}
}
return route.query.mode as string || '';
}); // 从其他页面跳转进来,是回放模式 还是浏览模式 还是开启一个新对话
}); // Redirected from other page, playback, review, or start a new conversation


if(pageMode.value === "recorder") {
Expand Down Expand Up @@ -222,7 +222,7 @@ const {
const {
subtasks: subTasks
} = storeToRefs(taskStore);


const stateMap = new Map([
[WebSocket.CONNECTING, 'CONNECTING'],
Expand Down Expand Up @@ -382,7 +382,7 @@ const wsMessageHandler = (data: any) => {
taskStore.addInner(data);
tabchild.gotNewInnerNode();
break;

case 'subtask_submit':
taskStore.addLastInner(data);
tabchild.gotNewInnerNode();
Expand Down Expand Up @@ -444,7 +444,7 @@ const newTalkConnection = () => {
}
}

// 输入回答
// Input answer
const sendMessage = async (val: string) => {
currentInput.value = val
chatMsgInfo.value = [
Expand Down Expand Up @@ -743,7 +743,7 @@ const queryChatInfo = async (id: string) => {
if (!id) return
const {data: res} = await getDataApi({ convId: id })

// 此APi在正式环境不可用
// NOTE: Don't use this API in production
// return RequestData


Expand Down Expand Up @@ -812,7 +812,7 @@ const wormText = (params: IChatRequest, {tasks, costTime, msgId }: {tasks: any;
costTimeMilli: costTime,
subTasks: [],
isLatest: true
// 当前的inenr是不是最新的那条信息
// Is the current inner the latest message
}
chatMsgInfo.value.forEach((item) => {
item.isLatest = false
Expand All @@ -832,7 +832,7 @@ const wormText = (params: IChatRequest, {tasks, costTime, msgId }: {tasks: any;
}


// 执行重新生成操作
// Regenerate the message
const regenerate = () => {
const input = currentInput.value
sendMessage(input)
Expand Down Expand Up @@ -1098,7 +1098,7 @@ const regenerate = () => {
}
}
}

}

.watermark {
Expand Down
2 changes: 1 addition & 1 deletion XAgentWeb/types/talk-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ChatMsgInfoInf {
content_html?: string
childrenIds?: string[]
subTasks?: Array<SubTaskInter>
isLatest?: boolean // 是不是AI最新生成的那条?
isLatest?: boolean // Is this the latest message generated by AI
}

export interface HistoryListInf {
Expand Down
8 changes: 4 additions & 4 deletions XAgentWeb/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export interface UserInfo {
mobile: number | string
smsCode: string
name: string
corporation: string //公司or学校
industry: string //行业
position: string //职位
email: string //邮箱
corporation: string // Company or School
industry: string
position: string
email: string
emailCode: string
avatar?: string
desc?: string
Expand Down
3 changes: 2 additions & 1 deletion XAgentWeb/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const config: UserConfigExport = {
inject: { data: { title: 'X-Agent' } },
}),
],
// 定义全局常量替换方式。其中每项在开发环境下会被定义在全局,而在构建时被静态替换。

// Define global constants replacement method. Each item will be defined globally in the development environment and statically replaced during building.
define: {
BASE_URL: JSON.stringify(VITE_PUBLIC_PATH),
},
Expand Down