Upload 5 files
Browse files- Dockerfile +14 -0
- app.py +28 -0
- requirements.txt +1 -0
Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.9
|
5 |
+
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
+
|
12 |
+
COPY . .
|
13 |
+
|
14 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import openai
|
3 |
+
|
4 |
+
# 定义语音助手函数
|
5 |
+
def voice_chatgpt(query):
|
6 |
+
|
7 |
+
# 将用户的问题发送给ChatGPT进行回答
|
8 |
+
response = openai.Completion.create(
|
9 |
+
engine="text-davinci-003",
|
10 |
+
prompt=query,
|
11 |
+
max_tokens=1000,
|
12 |
+
temperature=0.7,
|
13 |
+
n=1,
|
14 |
+
stop=None,
|
15 |
+
|
16 |
+
)
|
17 |
+
# 获取ChatGPT的回答
|
18 |
+
answer = response.choices[0].text.strip()
|
19 |
+
|
20 |
+
return answer
|
21 |
+
|
22 |
+
# Build interface
|
23 |
+
interface = gr.Interface(fn=voice_chatgpt,
|
24 |
+
inputs="text",
|
25 |
+
outputs="text")
|
26 |
+
|
27 |
+
# Run app
|
28 |
+
interface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
openai
|