# -*- coding:utf-8 -*- import gradio as gr import os title = """

ChatGPT-dteam 🚀

""" API_HOST = "api.openai.com" BALANCE_API_URL="https://api.openai.com/dashboard/billing/credit_grants" USAGE_API_URL="https://api.openai.com/dashboard/billing/usage" COMPLETION_URL = "https://api.openai.com/v1/chat/completions" Kelpy_Codos_Path = r"bin_public/config/Kelpy-Codos.js" customJS_Path = r"bin_public/config/custom.js" CSS_path = r"bin_public/config/CustomCSS.css" HISTORY_DIR = "history" TEMPLATES_DIR = "templates" description = """
""" SIM_K = 5 INDEX_QUERY_TEMPERATURE = 1.0 initial_prompt = "You are a helpful assistant." summarize_prompt = "你是谁?我们刚才聊了什么?" # 总结对话时的 prompt # MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-0301", "gpt-4","gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314"] # 可选的模型 MODELS = ["gpt-3.5-turbo", "gpt-3.5-turbo-0301", "gpt-4", "gpt-4-0314"] REPLY_LANGUAGES = [ "中文", "English", "日本語", "Español", "Français", "Deutsch", "跟随问题语言(不稳定)" ] # 错误信息 standard_error_msg = "☹️发生了错误:" # 错误信息的标准前缀 error_retrieve_prompt = "请检查网络连接,或者API-Key是否有效。" # 获取对话时发生错误 connection_timeout_prompt = "连接超时,无法获取对话。" # 连接超时 read_timeout_prompt = "读取超时,无法获取对话。" # 读取超时 proxy_error_prompt = "代理错误,无法获取对话。" # 代理错误 ssl_error_prompt = "SSL错误,无法获取对话。" # SSL 错误 no_apikey_msg = "API key长度不是51位,请检查是否输入正确。" # API key 长度不足 51 位 no_invite_code_msg = "输入的invite code不存在" no_useful_invite_code_msg = "输入的invite code状态不可用" max_token_streaming = 3500 # 流式对话时的最大 token 数 timeout_streaming = 30 # 流式对话时的超时时间 max_token_all = 3500 # 非流式对话时的最大 token 数 timeout_all = 200 # 非流式对话时的超时时间 enable_streaming_option = True # 是否启用选择选择是否实时显示回答的勾选框 HIDE_MY_KEY = False # 如果你想在UI中隐藏你的 API 密钥,将此值设置为 True ALREADY_CONVERTED_MARK = "" WEBSEARCH_PTOMPT_TEMPLATE = """\ Web search results: {web_results} Current date: {current_date} Instructions: Using the provided web search results, write a comprehensive reply to the given query. Make sure to cite results using [[number](URL)] notation after the reference. If the provided search results refer to multiple subjects with the same name, write separate answers for each subject. Query: {query} Reply in 中文""" PROMPT_TEMPLATE = """\ Context information is below. --------------------- {context_str} --------------------- Current date: {current_date}. Using the provided context information, write a comprehensive reply to the given query. Make sure to cite results using [number] notation after the reference. If the provided context information refer to multiple subjects with the same name, write separate answers for each subject. Use prior knowledge only if the given context didn't provide enough information. Answer the question: {query_str} Reply in 中文 """ REFINE_TEMPLATE = """\ The original question is as follows: {query_str} We have provided an existing answer: {existing_answer} We have the opportunity to refine the existing answer (only if needed) with some more context below. ------------ {context_msg} ------------ Given the new context, refine the original answer to better Answer in the same language as the question, such as English, 中文, 日本語, Español, Français, or Deutsch. If the context isn't useful, return the original answer. """ function = { '英语学术润色': "Below is a paragraph from an academic paper. Polish the writing to meet the academic style, improve the spelling, grammar, clarity, concision and overall readability. When necessary, rewrite the whole sentence. Furthermore, list all modification and explain the reasons to do so in markdown table.\n\n", '中文学术润色': "作为一名中文学术论文写作改进助理,你的任务是改进所提供文本的拼写、语法、清晰、简洁和整体可读性,同时分解长句,减少重复,并提供改进建议。请只提供文本的更正版本,避免包括解释。请编辑以下文本:\n\n", '查找英文语法错误': "Below is a paragraph from an academic paper. Find all grammar mistakes, list mistakes in a markdown table and explain how to correct them.\n\n", '学术中译英': "Please translate following sentence to English with academic writing, and provide some related authoritative examples: \n\n", '中译英': "Please translate following sentence to English: \n\n", '英译中': "请翻译成中文:\n\n" } INTERVIEWER_PROMPT = "我想让你担任面试官。我将成为候选人,您将先向我询问“您好,请问您想进行什么职位的面试”,再根据我的回复询问相应职位的面试问题。我希望你只作为面试官回答。不要一次写出所有的问题。我希望你只对我进行采访。问我问题,等待我的回答。基于我的回答,调整你的问题。像面试官一样一个一个问我,等我回答。我的第一个问题是‘面试官你好’" MIGRAINE_PROMPT = "我想让你扮演在偏头痛相关的治疗上有着丰富经验的老中医的角色,想出创造性的治疗方法来治疗疾病。您应该能够推荐常规药物、草药和其他天然替代品。在提供建议时,您还需要考虑患者的年龄、生活方式和病史。你也需要根据我给的相关资料来调整你的回答。我的第一个问题是‘医生您好’" PINECONE_API_KEY = os.environ['PINECONE_API_KEY'] PINECONE_API_ENV = os.environ['PINECONE_API_ENV'] PINECONE_INDEX_NAME = os.environ['PINECONE_INDEX_NAME'] q1 = '医生您好,从昨天晚上开始 肚子一直疼, 该吃什么药呢' q2 = '腹泻应该用什么药' q3 = '我四肢冰凉,应该用什么药' q4 = '藿香正气口服液有什么功效' q5 = '藿香正气口服液都适合什么时候服用' q6 = '夏天到了,我吃火锅的时候,可以服用藿香正气口服液么' q7 = '我吃火锅上火,喝藿香正气口服液有用么' qs = [q1, q2, q3, q4, q5, q6, q7]