aiderd commited on
Commit
c1006a8
·
1 Parent(s): 8cd9931

Upload 4 files

Browse files
Files changed (3) hide show
  1. README.md +4 -7
  2. app.py +31 -0
  3. requirements.txt +1 -0
README.md CHANGED
@@ -1,13 +1,10 @@
1
  ---
2
- title: Chatgpt2
3
- emoji:
4
- colorFrom: yellow
5
  colorTo: blue
6
- sdk: gradio
7
- sdk_version: 3.40.1
8
- app_file: app.py
9
  pinned: false
10
- license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Chatgpt1
3
+ emoji: 🏃
4
+ colorFrom: pink
5
  colorTo: blue
6
+ sdk: docker
 
 
7
  pinned: false
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+
4
+ # 设置OpenAI API凭据
5
+ openai.api_key = "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"
6
+
7
+ # 定义语音助手函数
8
+ def voice_chatgpt(query):
9
+
10
+ # 将用户的问题发送给ChatGPT进行回答
11
+ response = openai.Completion.create(
12
+ engine="text-davinci-003",
13
+ prompt=query,
14
+ max_tokens=1000,
15
+ temperature=0.7,
16
+ n=1,
17
+ stop=None,
18
+
19
+ )
20
+ # 获取ChatGPT的回答
21
+ answer = response.choices[0].text.strip()
22
+
23
+ return answer
24
+
25
+ # Build interface
26
+ interface = gr.Interface(fn=voice_chatgpt,
27
+ inputs="text",
28
+ outputs="text")
29
+
30
+ # Run app
31
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ openai