Commit 1768a324 authored by dengjb's avatar dengjb
Browse files

update codes

parent 18493eef
Pipeline #1372 failed with stages
in 0 seconds
"""
coding : utf-8
@Date : 2024/7/10
@Author : Shaobo
@Describe:
"""
from models.codegeex import CodegeexChatModel
model: CodegeexChatModel
def stream_chat_with_codegeex(request):
yield from model.stream_chat(request)
def chat_with_codegeex(request):
return model.chat(request)
def init_model(args):
global model
model = CodegeexChatModel(args)
# The Most Powerful Versatile Code Model Under 10 Billion Parameters
CodeGeeX4-ALL-9B, the open-source version of the latest generation of the CodeGeeX4 series, iterates on the powerful language capabilities of GLM4, significantly enhancing code generation capabilities. Using a single CodeGeeX4-ALL-9B model, it supports comprehensive functionalities such as code completion and generation, code interpreter, online search, tool invocation, repository-level long code Q&A and generation, covering various programming and development scenarios. CodeGeeX4-ALL-9B has achieved highly competitive performance on multiple authoritative code capability evaluation sets, such as NaturalCodeBench and BigCodeBench. It is the most powerful model under 10 billion parameters, even surpassing general models several times its size, achieving the best balance between inference performance and model effectiveness.
## 1. BigCodeBench
BigCodeBench test results show that CodeGeeX4-ALL-9B performs the best at the same size:
![BigCodeBench Test Results](./pics/Bigcodebench.png)
## 2. NaturalCodeBench & HumanEval
NaturalCodeBench test results show that CodeGeeX4-ALL-9B achieves the best results in tasks such as code completion, code interpreter, code Q&A, code translation, and code repair:
![NaturalCodeBench Test Results](./pics/NCB&HUMANEVAL.png)
## 3. Code Needle In A Haystack
CodeGeeX4-ALL-9B's context handling capability has reached 128K, an 8-fold increase compared to the previous generation model!
For code large models under 10B parameters, accurately extracting information from massive amounts of code is a key challenge. CodeGeeX4-ALL-9B's upgraded support for 128K context enables it to process and utilize longer code files, and even information from project code, helping the model to understand complex and detail-rich code more deeply. Based on the longer context, CodeGeeX4-ALL-9B can handle more complex project-level tasks, accurately answering content from different code files and making modifications to the code even when the input length increases significantly.
In the "Needle In A Haystack" (NIAH) evaluation, the CodeGeeX4-ALL-9B model demonstrated its ability to embed and retrieve code within contexts up to 128K, achieving a 100% retrieval accuracy.
![NIAH_PYTHON Evaluation](./pics/NIAH_PYTHON.png)
![NIAH_ALL_FILES Evaluation](./pics/NIAH_ALL.png)
The above figures show the test results in a test set composed entirely of Python code, where an assignment statement such as `zhipu_codemodel = "codegeex"` (Needle) is inserted, and the model is tested on whether it can correctly answer the value of `zhipu_codemodel`. CodeGeeX4-All-9B completed the task 100%.
## 4. Function Call Capabilities
CodeGeeX4-ALL-9B is currently the only code large model that implements Function Call capabilities.
The Berkeley Function Calling Leaderboard is the first test set that can comprehensively evaluate the function calling capabilities of large models. The AST dataset evaluates the model's calling capabilities for Java, JavaScript, and Python programs; the Executable dataset evaluates the model's function calling capabilities for real-world API scenarios.
![Berkeley Function Calling Leaderboard](./pics/FunctionCall.png)
CodeGeeX4-ALL-9B underwent comprehensive testing on the Berkeley Function Calling Leaderboard, including various forms of function calls, different function call scenarios, and function call executability tests, achieving the following results: a call success rate of over 90% in both AST and Exec test sets.
## 5. Cross-File Completion
Cross-File Evaluation is a multilingual benchmark built on diverse real-world repositories in Python, Java, TypeScript, and C#. It uses a static-analysis-based method to strictly require cross-file context for accurate code completion.
| Model | PYTHON EM | PYTHON ES | JAVA EM | JAVA ES | TypeScript EM | TypeScript ES | C# EM | C# ES |
|------------------|------------|------------|----------|----------|----------------|----------------|---------|---------|
| DeepSeekCoder-7B | 29.9 | 62.9 | 39.8 | 74.8 | 39 | 77 | 52.2 | 78.1 |
| StarCoder2-7B | 25.3 | 58 | 31.4 | 67.4 | 33.3 | 73.2 | 43.5 | 69.8 |
| CodeLlama-7B | 23.5 | 53.5 | 33.9 | 68.4 | 11.5 | 71.5 | 50.6 | 75.4 |
| CodeGeeX-9B | 32.3 | 70.3 | 48.6 | 84.4 | 35.3 | 78.0 | 48.0 | 84.8 |
# CodeGeeX4-ALL-9B
## CodeGeeX4-ALL-9B:百亿参数以下性能最强的全能代码模型
CodeGeeX4-ALL-9B作为最新一代CodeGeeX4系列模型的开源版本,在GLM4强大语言能力的基础上继续迭代,大幅增强代码生成能力。使用CodeGeeX4-ALL-9B单一模型,即可支持代码补全和生成、代码解释器、联网搜索、工具调用、仓库级长代码问答及生成等全面功能,覆盖了编程开发的各种场景。CodeGeeX4-ALL-9B在多个权威代码能力评测集,如NaturalCodeBench、BigCodeBench上都取得了极具竞争力的表现,是百亿参数量级以下性能最强的模型,甚至超过数倍规模的通用模型,在推理性能和模型效果上得到最佳平衡。
### 1. 性能表现评测
BigCodeBench测试结果显示,CodeGeeX4-ALL-9B在同等尺寸下效果最好:
![BigCodeBench Test Results](./pics/Bigcodebench.png)
NaturalCodeBench测试结果显示,CodeGeeX4-ALL-9B在代码补全、代码解释器、代码问答、代码翻译、代码修复等任务上均取得了最佳效果:
![NaturalCodeBench测试结果](./pics/NCB&HUMANEVAL.png)
### 2. CodeGeeX4-ALL-9B上下文处理能力
CodeGeeX4-ALL-9B上下文处理能力达到了128K,相较于上一代模型增长8倍!
对于参数量10B以下的代码大模型,从海量的代码中准确提取信息是一个关键性的挑战。CodeGeeX4-ALL-9B升级支持128K上下文,使其能够处理和利用更长代码文件、甚至是项目代码中的信息,有助于模型更深入理解复杂和细节丰富的代码。基于更长的上下文,CodeGeeX4-ALL-9B可以处理更复杂的项目级任务,在输入显著变长的情况下,依然能准确回答不同代码文件中的内容,并对代码作出修改。
在“大海捞针”(Needle In A Haystack, NIAH)评估中,CodeGeeX4-ALL-9B模型展示了其在处理长达128K的上下文中进行代码的嵌入和检索能力,实现了100%的检索准确度。
![NIAH_PYTHON评估](./pics/NIAH_PYTHON.png)
![NIAH_ALL_FILES评估](./pics/NIAH_ALL.png)
上图展示的是在一个全部由Python代码组成的测试集中,插入一个赋值语句如:`zhipu_codemodel = "codegeex"`(Needle),测试模型是否可以正确回答出`zhipu_codemodel`的值,CodeGeeX4-ALL-9B 100%完成任务。
### 3. CodeGeeX4-ALL-9B 支持 Function Call 能力
CodeGeeX4-ALL-9B是目前唯一一个实现Function Call的代码大模型。
Berkeley Function Calling Leaderboard是第一个可全面评估大模型函数调用能力的测试集。其中AST数据集是评估模型对Java、JavaScript、Python程序的调用能力;Executable数据集是评估模型对真实场景API的函数调用能力。
![Berkeley Function Calling Leaderboard](./pics/FunctionCall.png)
CodeGeeX4-ALL-9B在Berkeley Function Calling Leaderboard上进行了全面的测试,包括各种形式的函数调用、不同的函数调用场景以及函数调用可执行性的测试,得到了以下结果:在AST和Exec测试集中调用成功率超过90%。
### 4. CodeGeeX4-ALL-9B 跨文件补全
Cross-File Evaluation是一个多语言的基准,建立在Python、Java、TypeScript和C#的多样化真实仓库之上。它使用基于静态分析的方法,严格要求跨文件上下文以实现准确的代码补全。
| Model | PYTHON EM | PYTHON ES | JAVA EM | JAVA ES | TypeScript EM | TypeScript ES | C# EM | C# ES |
|------------------|------------|------------|----------|----------|----------------|----------------|---------|---------|
| DeepSeekCoder-7B | 29.9 | 62.9 | 39.8 | 74.8 | 39 | 77 | 52.2 | 78.1 |
| StarCoder2-7B | 25.3 | 58 | 31.4 | 67.4 | 33.3 | 73.2 | 43.5 | 69.8 |
| CodeLlama-7B | 23.5 | 53.5 | 33.9 | 68.4 | 11.5 | 71.5 | 50.6 | 75.4 |
| CodeGeeX-9B | 32.3 | 70.3 | 48.6 | 84.4 | 35.3 | 78.0 | 48.0 | 84.8 |
\ No newline at end of file
# 模型唯一标识
modelCode=793
# 模型名称
modelName=codegeex4_pytorch
# 模型描述
modelDescription=codegeex4是一个在GLM-4-9B上持续训练的多语言代码生成模型,显著增强了其代码生成能力
# 应用场景
appScenario=推理,训练,代码生成,制造,能源,教育
# 框架类型
frameType=pytorch
[project]
# Whether to enable telemetry (default: true). No personal data is collected.
enable_telemetry = false
# List of environment variables to be provided by each user to use the app.
user_env = []
# Duration (in seconds) during which the session is saved when the connection is lost
session_timeout = 3600
# Enable third parties caching (e.g LangChain cache)
cache = false
# Authorized origins
allow_origins = ["*"]
# Follow symlink for asset mount (see https://github.com/Chainlit/chainlit/issues/317)
# follow_symlink = false
[features]
# Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
unsafe_allow_html = false
# Process and display mathematical expressions. This can clash with "$" characters in messages.
latex = false
# Automatically tag threads with the current chat profile (if a chat profile is used)
auto_tag_thread = true
# Authorize users to spontaneously upload files with messages
[features.spontaneous_file_upload]
enabled = false
accept = ["*/*"]
max_files = 20
max_size_mb = 500
[features.audio]
# Threshold for audio recording
min_decibels = -45
# Delay for the user to start speaking in MS
initial_silence_timeout = 3000
# Delay for the user to continue speaking in MS. If the user stops speaking for this duration, the recording will stop.
silence_timeout = 1500
# Above this duration (MS), the recording will forcefully stop.
max_duration = 15000
# Duration of the audio chunks in MS
chunk_duration = 1000
# Sample rate of the audio
sample_rate = 44100
[UI]
# Name of the assistant.
name = "CodeGeeX4 RepoDemo"
# Description of the assistant. This is used for HTML tags.
description = "CodeGeeX4项目级能力展示"
# Large size content are by default collapsed for a cleaner ui
default_collapse_content = true
# Hide the chain of thought details from the user in the UI.
hide_cot = false
# Link to your github repo. This will add a github button in the UI's header.
github = "https://github.com/CodeGeeX"
# Specify a CSS file that can be used to customize the user interface.
# The CSS file can be served from the public directory or via an external link.
# custom_css = "/public/test.css"
# Specify a Javascript file that can be used to customize the user interface.
# The Javascript file can be served from the public directory.
# custom_js = "/public/test.js"
# Specify a custom font url.
# custom_font = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"
# Specify a custom meta image url.
custom_meta_image_url = "/public/logo_dark.png"
# Specify a custom build directory for the frontend.
# This can be used to customize the frontend code.
# Be careful: If this is a relative path, it should not start with a slash.
# custom_build = "./public/build"
[UI.theme]
default = "dark"
layout = "wide"
#font_family = "Inter, sans-serif"
# Override default MUI light theme. (Check theme.ts)
[UI.theme.light]
#background = "#FAFAFA"
#paper = "#FFFFFF"
[UI.theme.light.primary]
#main = "#F80061"
#dark = "#980039"
#light = "#FFE7EB"
[UI.theme.light.text]
#primary = "#212121"
#secondary = "#616161"
# Override default MUI dark theme. (Check theme.ts)
[UI.theme.dark]
#background = "#FAFAFA"
#paper = "#FFFFFF"
[UI.theme.dark.primary]
#main = "#F80061"
#dark = "#980039"
#light = "#FFE7EB"
[UI.theme.dark.text]
#primary = "#EEEEEE"
#secondary = "#BDBDBD"
[meta]
generated_by = "1.1.305"
{
"components": {
"atoms": {
"buttons": {
"userButton": {
"menu": {
"settings": "Settings",
"settingsKey": "S",
"APIKeys": "API Keys",
"logout": "Logout"
}
}
}
},
"molecules": {
"newChatButton": {
"newChat": "New Chat"
},
"tasklist": {
"TaskList": {
"title": "\ud83d\uddd2\ufe0f Task List",
"loading": "Loading...",
"error": "An error occurred"
}
},
"attachments": {
"cancelUpload": "Cancel upload",
"removeAttachment": "Remove attachment"
},
"newChatDialog": {
"createNewChat": "Create new chat?",
"clearChat": "This will clear the current messages and start a new chat.",
"cancel": "Cancel",
"confirm": "Confirm"
},
"settingsModal": {
"settings": "Settings",
"expandMessages": "Expand Messages",
"hideChainOfThought": "Hide Chain of Thought",
"darkMode": "Dark Mode"
},
"detailsButton": {
"using": "Using",
"used": "Used"
},
"auth": {
"authLogin": {
"title": "Login to access the app.",
"form": {
"email": "Email address",
"password": "Password",
"noAccount": "Don't have an account?",
"alreadyHaveAccount": "Already have an account?",
"signup": "Sign Up",
"signin": "Sign In",
"or": "OR",
"continue": "Continue",
"forgotPassword": "Forgot password?",
"passwordMustContain": "Your password must contain:",
"emailRequired": "email is a required field",
"passwordRequired": "password is a required field"
},
"error": {
"default": "Unable to sign in.",
"signin": "Try signing in with a different account.",
"oauthsignin": "Try signing in with a different account.",
"redirect_uri_mismatch": "The redirect URI is not matching the oauth app configuration.",
"oauthcallbackerror": "Try signing in with a different account.",
"oauthcreateaccount": "Try signing in with a different account.",
"emailcreateaccount": "Try signing in with a different account.",
"callback": "Try signing in with a different account.",
"oauthaccountnotlinked": "To confirm your identity, sign in with the same account you used originally.",
"emailsignin": "The e-mail could not be sent.",
"emailverify": "Please verify your email, a new email has been sent.",
"credentialssignin": "Sign in failed. Check the details you provided are correct.",
"sessionrequired": "Please sign in to access this page."
}
},
"authVerifyEmail": {
"almostThere": "You're almost there! We've sent an email to ",
"verifyEmailLink": "Please click on the link in that email to complete your signup.",
"didNotReceive": "Can't find the email?",
"resendEmail": "Resend email",
"goBack": "Go Back",
"emailSent": "Email sent successfully.",
"verifyEmail": "Verify your email address"
},
"providerButton": {
"continue": "Continue with {{provider}}",
"signup": "Sign up with {{provider}}"
},
"authResetPassword": {
"newPasswordRequired": "New password is a required field",
"passwordsMustMatch": "Passwords must match",
"confirmPasswordRequired": "Confirm password is a required field",
"newPassword": "New password",
"confirmPassword": "Confirm password",
"resetPassword": "Reset Password"
},
"authForgotPassword": {
"email": "Email address",
"emailRequired": "email is a required field",
"emailSent": "Please check the email address {{email}} for instructions to reset your password.",
"enterEmail": "Enter your email address and we will send you instructions to reset your password.",
"resendEmail": "Resend email",
"continue": "Continue",
"goBack": "Go Back"
}
}
},
"organisms": {
"chat": {
"history": {
"index": {
"showHistory": "Show history",
"lastInputs": "Last Inputs",
"noInputs": "Such empty...",
"loading": "Loading..."
}
},
"inputBox": {
"input": {
"placeholder": "Type your message here..."
},
"speechButton": {
"start": "Start recording",
"stop": "Stop recording"
},
"SubmitButton": {
"sendMessage": "Send message",
"stopTask": "Stop Task"
},
"UploadButton": {
"attachFiles": "Attach files"
},
"waterMark": {
"text": "Built with"
}
},
"Messages": {
"index": {
"running": "Running",
"executedSuccessfully": "executed successfully",
"failed": "failed",
"feedbackUpdated": "Feedback updated",
"updating": "Updating"
}
},
"dropScreen": {
"dropYourFilesHere": "Drop your files here"
},
"index": {
"failedToUpload": "Failed to upload",
"cancelledUploadOf": "Cancelled upload of",
"couldNotReachServer": "Could not reach the server",
"continuingChat": "Continuing previous chat"
},
"settings": {
"settingsPanel": "Settings panel",
"reset": "Reset",
"cancel": "Cancel",
"confirm": "Confirm"
}
},
"threadHistory": {
"sidebar": {
"filters": {
"FeedbackSelect": {
"feedbackAll": "Feedback: All",
"feedbackPositive": "Feedback: Positive",
"feedbackNegative": "Feedback: Negative"
},
"SearchBar": {
"search": "Search"
}
},
"DeleteThreadButton": {
"confirmMessage": "This will delete the thread as well as it's messages and elements.",
"cancel": "Cancel",
"confirm": "Confirm",
"deletingChat": "Deleting chat",
"chatDeleted": "Chat deleted"
},
"index": {
"pastChats": "Past Chats"
},
"ThreadList": {
"empty": "Empty...",
"today": "Today",
"yesterday": "Yesterday",
"previous7days": "Previous 7 days",
"previous30days": "Previous 30 days"
},
"TriggerButton": {
"closeSidebar": "Close sidebar",
"openSidebar": "Open sidebar"
}
},
"Thread": {
"backToChat": "Go back to chat",
"chatCreatedOn": "This chat was created on"
}
},
"header": {
"chat": "Chat",
"readme": "Readme"
}
}
},
"hooks": {
"useLLMProviders": {
"failedToFetchProviders": "Failed to fetch providers:"
}
},
"pages": {
"Design": {},
"Env": {
"savedSuccessfully": "Saved successfully",
"requiredApiKeys": "Required API Keys",
"requiredApiKeysInfo": "To use this app, the following API keys are required. The keys are stored on your device's local storage."
},
"Page": {
"notPartOfProject": "You are not part of this project."
},
"ResumeButton": {
"resumeChat": "Resume Chat"
}
}
}
\ No newline at end of file
{
"components": {
"atoms": {
"buttons": {
"userButton": {
"menu": {
"settings": "设置",
"settingsKey": "S",
"APIKeys": "API 密钥",
"logout": "登出"
}
}
}
},
"molecules": {
"newChatButton": {
"newChat": "新聊天"
},
"tasklist": {
"TaskList": {
"title": "🗒️ 任务列表",
"loading": "加载中...",
"error": "发生错误"
}
},
"attachments": {
"cancelUpload": "取消上传",
"removeAttachment": "移除附件"
},
"newChatDialog": {
"createNewChat": "创建新聊天?",
"clearChat": "这将清除当前消息并开始新聊天。",
"cancel": "取消",
"confirm": "确认"
},
"settingsModal": {
"settings": "设置",
"expandMessages": "展开消息",
"hideChainOfThought": "隐藏思路",
"darkMode": "深色模式"
},
"detailsButton": {
"using": "正在使用",
"used": "已使用"
},
"auth": {
"authLogin": {
"title": "登录以访问应用程序。",
"form": {
"email": "电子邮件地址",
"password": "密码",
"noAccount": "没有账户?",
"alreadyHaveAccount": "已有账户?",
"signup": "注册",
"signin": "登录",
"or": "或",
"continue": "继续",
"forgotPassword": "忘记密码?",
"passwordMustContain": "您的密码必须包含:",
"emailRequired": "电子邮件是必填字段",
"passwordRequired": "密码是必填字段"
},
"error": {
"default": "无法登录。",
"signin": "尝试使用其他账户登录。",
"oauthsignin": "尝试使用其他账户登录。",
"redirect_uri_mismatch": "重定向 URI 与 OAuth 应用程序配置不匹配。",
"oauthcallbackerror": "尝试使用其他账户登录。",
"oauthcreateaccount": "尝试使用其他账户登录。",
"emailcreateaccount": "尝试使用其他账户登录。",
"callback": "尝试使用其他账户登录。",
"oauthaccountnotlinked": "要确认您的身份,请使用您最初使用的同一账户登录。",
"emailsignin": "无法发送电子邮件。",
"emailverify": "请验证您的电子邮件,新邮件已发送。",
"credentialssignin": "登录失败。请检查您提供的详细信息是否正确。",
"sessionrequired": "请登录以访问此页面。"
}
},
"authVerifyEmail": {
"almostThere": "您快完成了!我们已发送电子邮件至",
"verifyEmailLink": "请点击该电子邮件中的链接以完成注册。",
"didNotReceive": "找不到电子邮件?",
"resendEmail": "重新发送电子邮件",
"goBack": "返回",
"emailSent": "电子邮件发送成功。",
"verifyEmail": "验证您的电子邮件地址"
},
"providerButton": {
"continue": "继续使用{{provider}}",
"signup": "使用{{provider}}注册"
},
"authResetPassword": {
"newPasswordRequired": "新密码是必填字段",
"passwordsMustMatch": "密码必须匹配",
"confirmPasswordRequired": "确认密码是必填字段",
"newPassword": "新密码",
"confirmPassword": "确认密码",
"resetPassword": "重置密码"
},
"authForgotPassword": {
"email": "电子邮件地址",
"emailRequired": "电子邮件是必填字段",
"emailSent": "请检查电子邮件地址 {{email}} 以获取重置密码的说明。",
"enterEmail": "输入您的电子邮件地址,我们将发送重置密码的说明。",
"resendEmail": "重新发送电子邮件",
"continue": "继续",
"goBack": "返回"
}
}
},
"organisms": {
"chat": {
"history": {
"index": {
"showHistory": "显示历史记录",
"lastInputs": "上次输入",
"noInputs": "空空如也...",
"loading": "加载中..."
}
},
"inputBox": {
"input": {
"placeholder": "在此输入您的消息..."
},
"speechButton": {
"start": "开始录音",
"stop": "停止录音"
},
"SubmitButton": {
"sendMessage": "发送消息",
"stopTask": "停止任务"
},
"UploadButton": {
"attachFiles": "附件文件"
},
"waterMark": {
"text": "由codegeex团队提供支持"
}
},
"Messages": {
"index": {
"running": "运行中",
"executedSuccessfully": "执行成功",
"failed": "失败",
"feedbackUpdated": "反馈已更新",
"updating": "更新中"
}
},
"dropScreen": {
"dropYourFilesHere": "将文件拖放到此处"
},
"index": {
"failedToUpload": "上传失败",
"cancelledUploadOf": "取消上传",
"couldNotReachServer": "无法连接服务器",
"continuingChat": "继续先前的聊天"
},
"settings": {
"settingsPanel": "设置面板",
"reset": "重置",
"cancel": "取消",
"confirm": "确认"
}
},
"threadHistory": {
"sidebar": {
"filters": {
"FeedbackSelect": {
"feedbackAll": "反馈:全部",
"feedbackPositive": "反馈:正面",
"feedbackNegative": "反馈:负面"
},
"SearchBar": {
"search": "搜索"
}
},
"DeleteThreadButton": {
"confirmMessage": "这将删除线程及其消息和元素。",
"cancel": "取消",
"confirm": "确认",
"deletingChat": "删除聊天中",
"chatDeleted": "聊天已删除"
},
"index": {
"pastChats": "过去的聊天"
},
"ThreadList": {
"empty": "空的...",
"today": "今天",
"yesterday": "昨天",
"previous7days": "前7天",
"previous30days": "前30天"
},
"TriggerButton": {
"closeSidebar": "关闭侧边栏",
"openSidebar": "打开侧边栏"
}
},
"Thread": {
"backToChat": "返回聊天",
"chatCreatedOn": "此聊天创建于"
}
},
"header": {
"chat": "聊天",
"readme": "自述文件"
}
}
},
"hooks": {
"useLLMProviders": {
"failedToFetchProviders": "无法获取提供者:"
}
},
"pages": {
"Design": {},
"Env": {
"savedSuccessfully": "保存成功",
"requiredApiKeys": "所需 API 密钥",
"requiredApiKeysInfo": "要使用此应用程序,需要以下 API 密钥。这些密钥存储在您设备的本地存储中。"
},
"Page": {
"notPartOfProject": "您不属于此项目。"
},
"ResumeButton": {
"resumeChat": "继续聊天"
}
}
}
\ No newline at end of file
openai_api_key = ""
openai_api_base = "https://open.bigmodel.cn/api/paas/v4/"
model_name = "codegeex-4"
bing_api_key = ""
\ No newline at end of file
# CodeGeeX
# Welcome to My Chat Demo Application
This is a simple demonstration application.
## Instructions
1. Enter your question.
2. Wait for a response.
3. Enjoy the conversation!
## Features
- Supports multi-turn conversations.
- Supports online Q&A.
- Supports uploading local zip packages for project Q&A and modifications.
- Supports inputting GitHub project links for project Q&A and modifications.
## Installation
1. Clone the repository locally.
2. Start the model. You can deploy the model using vllm or ollama, provide the OpenAI request format, and set the deployed `api_base` and `api_key`. Alternatively, visit [CodeGeeX API](https://open.bigmodel.cn/dev/api#codegeex-4) to get the API key.
```shell
#use open.bigmodel.cn api
openai_api_key = "<|apikey|>"
openai_api_base = "https://open.bigmodel.cn/api/paas/v4/"
model_name = "codegeex-4"
#use vllm
openai_api_key = "EMPTY"
openai_api_base = "http://xxxx:xxxx/v1"
model_name = "codegeex4-all-9b"
```
3. Fill in the corresponding model information and `bing_search_api` (if you want to experience online search) in the `.env` file.
4. Install dependencies: `pip install -r requirements.txt`.
5. Run the application: `chainlit run run.py --port 8899`.
## Note
Please ensure your network environment can access the CodeGeeX API.
## Disclaimer
This application is for educational and research purposes only and should not be used for any commercial purposes. The developer is not responsible for any loss or damage caused by the use of this application.
## Acknowledgements
Thank you for using our application. If you have any questions or suggestions, please feel free to contact us. We look forward to your feedback and are committed to providing you with better service.
\ No newline at end of file
# CodeGeeX
# 欢迎使用我的chat demo应用
这是一个简单的演示应用程序。
## 使用说明
1. 输入您的问题
2. 等待回复
3. 享受对话!
## 功能
- 支持多轮对话
- 支持联网问答
- 支持上传本地zip压缩包项目,可以进行项目问答和对项目进行修改
- 支持输入GitHub链接项目,可以进行项目问答和对项目进行修改。
## 安装
1. 克隆仓库到本地
2. 启动模型,可以通过vllm或者ollama部署模型,提供openai的请求格式,设置部署的api_base和api_key,或者访问[CodeGeeX API](https://open.bigmodel.cn/dev/api#codegeex-4)获取apikey.
```shell
#use open.bigmodel.cn api
openai_api_key = "<|apikey|>"
openai_api_base = "https://open.bigmodel.cn/api/paas/v4/"
model_name = "codegeex-4"
#use vllm
openai_api_key = "EMPTY"
openai_api_base = "http://xxxx:xxxx/v1"
model_name = "codegeex4-all-9b"
```
3. 到.env文件里填写对应模型信息和bing_search_api(如果需要体验联网查询)
4. 安装依赖:`pip install -r requirements.txt`
5. 运行应用:`chainlit run run.py --port 8899`
## 注意
请确保您的网络环境可以访问CodeGeeX的API。
## 免责声明
本应用仅供学习和研究使用,不得用于任何商业用途。开发者不对因使用本应用而导致的任何损失或损害负责。
## 感谢
感谢您使用我们的应用。如果您有任何问题或建议,请随时联系我们。我们期待您的反馈,并致力于为您提供更好的服务。
import json
from openai import OpenAI
import requests
import os
def codegeex4(messages_list, temperature=0.2, top_p=0.95):
openai_api_key = os.getenv("openai_api_key")
openai_api_base = os.getenv("openai_api_base")
model_name = os.getenv("model_name")
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
chat_response = client.chat.completions.create(
model=model_name,
messages=messages_list,
temperature=temperature,
top_p=top_p
)
return chat_response.choices[0].message.content
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment