Spaces:
Runtime error
Runtime error
Fix issues with incorrect API usage
Browse files
app.py
CHANGED
@@ -1,14 +1,11 @@
|
|
1 |
import os
|
2 |
|
3 |
import gradio as gr
|
4 |
-
from
|
5 |
|
6 |
-
SYSTEM_PROMPT = "
|
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="
|
29 |
stream=True,
|
30 |
-
temperature=0.
|
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
|