Diego ROJAS commited on
Commit
d9f53af
β€’
1 Parent(s): 57d3d9b

Fix Github link

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -1,10 +1,13 @@
1
  import os
 
2
  import gradio as gr
3
  from openai import OpenAI
4
 
5
  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."
6
 
7
- client = OpenAI(base_url="https://api.chatglm.cn/v1", api_key=os.getenv("CHATGLM_API_KEY"))
 
 
8
 
9
 
10
  def respond(message, history: list[tuple[str, str]]):
@@ -21,37 +24,41 @@ def respond(message, history: list[tuple[str, str]]):
21
  response = ""
22
 
23
  for message in client.chat.completions.create(
24
- messages=messages, # type: ignore
25
  model="codegeex4-9b-biz",
26
  stream=True,
27
  temperature=0.7,
28
  max_tokens=1024,
29
  top_p=0.95,
30
- ): # type: ignore
31
  token = message.choices[0].delta.content
32
 
33
  response += token
34
  yield response
35
 
 
36
  with gr.Blocks(fill_height=True) as demo:
37
  gr.Markdown(
38
- """
39
  <p align="center" style="margin: 32px 32px 0 0;">
40
  <img src="https://gist.githubusercontent.com/rojas-diego/0c1b444aff2c6b6420ff635bfd206869/raw/16566317fabce71d35ab3cf8c71adf3b5dc11d87/codegeex.svg" style="width: 30%">
41
  </p>
42
- """)
 
43
  gr.Markdown(
44
  """
45
  <p align="center">
46
  🏠 <a href="https://codegeex.cn" target="_blank">Homepage</a> | πŸ“– <a href="http://keg.cs.tsinghua.edu.cn/codegeex/" target="_blank">Blog</a> | πŸ›  <a href="https://marketplace.visualstudio.com/items?itemName=aminer.codegeex" target="_blank">VS Code</a> or <a href="https://plugins.jetbrains.com/plugin/20587-codegeex" target="_blank">Jetbrains</a> Extensions | πŸ’» <a href="https://github.com/THUDM/CodeGeeX4" target="_blank">Github</a> | πŸ€– <a href="https://huggingface.co/THUDM/codegeex-4-9b" target="_blank">HuggingFace</a>
47
  </p>
48
- """)
 
49
  gr.Markdown(
50
  """
51
  <p align="center">
52
- We introduce CodeGeeX4 9B, a large-scale multilingual code generation model with 9 billion parameters, pre-trained on a large code corpus of more than 300 programming languages. CodeGeeX4 9B is open source, please refer to our <a href="https://github.com/THUDM/codegeex-4-9b" target="_blank">GitHub</a> for more details. We also offer free <a href="https://marketplace.visualstudio.com/items?itemName=aminer.codegeex" target="_blank">VS Code</a> and <a href="https://plugins.jetbrains.com/plugin/20587-codegeex" target="_blank">Jetbrains</a> extensions for full functionality.
53
  </p>
54
- """)
 
55
 
56
  gr.ChatInterface(respond, fill_height=True)
57
 
 
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]]):
 
24
  response = ""
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
34
  token = message.choices[0].delta.content
35
 
36
  response += token
37
  yield response
38
 
39
+
40
  with gr.Blocks(fill_height=True) as demo:
41
  gr.Markdown(
42
+ """
43
  <p align="center" style="margin: 32px 32px 0 0;">
44
  <img src="https://gist.githubusercontent.com/rojas-diego/0c1b444aff2c6b6420ff635bfd206869/raw/16566317fabce71d35ab3cf8c71adf3b5dc11d87/codegeex.svg" style="width: 30%">
45
  </p>
46
+ """
47
+ )
48
  gr.Markdown(
49
  """
50
  <p align="center">
51
  🏠 <a href="https://codegeex.cn" target="_blank">Homepage</a> | πŸ“– <a href="http://keg.cs.tsinghua.edu.cn/codegeex/" target="_blank">Blog</a> | πŸ›  <a href="https://marketplace.visualstudio.com/items?itemName=aminer.codegeex" target="_blank">VS Code</a> or <a href="https://plugins.jetbrains.com/plugin/20587-codegeex" target="_blank">Jetbrains</a> Extensions | πŸ’» <a href="https://github.com/THUDM/CodeGeeX4" target="_blank">Github</a> | πŸ€– <a href="https://huggingface.co/THUDM/codegeex-4-9b" target="_blank">HuggingFace</a>
52
  </p>
53
+ """
54
+ )
55
  gr.Markdown(
56
  """
57
  <p align="center">
58
+ We introduce CodeGeeX4 9B, a large-scale multilingual code generation model with 9 billion parameters, pre-trained on a large code corpus of more than 300 programming languages. CodeGeeX4 9B is open source, please refer to our <a href="https://github.com/THUDM/CodeGeeX4" target="_blank">GitHub</a> for more details. We also offer free <a href="https://marketplace.visualstudio.com/items?itemName=aminer.codegeex" target="_blank">VS Code</a> and <a href="https://plugins.jetbrains.com/plugin/20587-codegeex" target="_blank">Jetbrains</a> extensions for full functionality.
59
  </p>
60
+ """
61
+ )
62
 
63
  gr.ChatInterface(respond, fill_height=True)
64