Stanislas commited on
Commit
8d614a6
1 Parent(s): d9f53af

Fix issues with incorrect API usage

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -1,14 +1,11 @@
1
  import os
2
 
3
  import gradio as gr
4
- from openai import OpenAI
5
 
6
- SYSTEM_PROMPT = "You are an intelligent programming assistant named CodeGeeX. You will answer any questions users have about programming, coding, and computers, and provide code that is formatted correctly, executable, accurate, and secure, and offer detailed explanations when necessary."
7
-
8
- client = OpenAI(
9
- base_url="https://api.chatglm.cn/v1", api_key=os.getenv("CHATGLM_API_KEY")
10
- )
11
 
 
12
 
13
  def respond(message, history: list[tuple[str, str]]):
14
  messages = [{"role": "system", "content": SYSTEM_PROMPT}]
@@ -25,9 +22,9 @@ def respond(message, history: list[tuple[str, str]]):
25
 
26
  for message in client.chat.completions.create(
27
  messages=messages, # type: ignore
28
- model="codegeex4-9b-biz",
29
  stream=True,
30
- temperature=0.7,
31
  max_tokens=1024,
32
  top_p=0.95,
33
  ): # type: ignore
 
1
  import os
2
 
3
  import gradio as gr
4
+ from zhipuai import ZhipuAI
5
 
6
+ SYSTEM_PROMPT = "你是一位智能编程助手,你叫CodeGeeX。你会为用户回答关于编程、代码、计算机方面的任何问题,并提供格式规范、可以执行、准确安全的代码,并在必要时提供详细的解释。"
 
 
 
 
7
 
8
+ client = ZhipuAI(api_key=os.getenv("CODEGEEX_API_KEY"))
9
 
10
  def respond(message, history: list[tuple[str, str]]):
11
  messages = [{"role": "system", "content": SYSTEM_PROMPT}]
 
22
 
23
  for message in client.chat.completions.create(
24
  messages=messages, # type: ignore
25
+ model="codegeex-4",
26
  stream=True,
27
+ temperature=0.2,
28
  max_tokens=1024,
29
  top_p=0.95,
30
  ): # type: ignore