Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- .env +1 -0
- README.md +3 -9
- __pycache__/app.cpython-38.pyc +0 -0
- app.py +44 -0
- flagged/log.csv +2 -0
.env
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
OPENAI_API_KEY = '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'
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji: 🚀
|
4 |
-
colorFrom: gray
|
5 |
-
colorTo: green
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.38.0
|
8 |
app_file: app.py
|
9 |
-
|
|
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: miniChatBot
|
|
|
|
|
|
|
|
|
|
|
3 |
app_file: app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 3.37.0
|
6 |
---
|
|
|
|
__pycache__/app.cpython-38.pyc
ADDED
Binary file (346 Bytes). View file
|
|
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import openai
|
3 |
+
import gradio as gr
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
openai.api_key = os.environ['OPENAI_API_KEY']
|
8 |
+
|
9 |
+
messages = [
|
10 |
+
{"role": "system",
|
11 |
+
"content": "你是算塔罗牌的专家,帮助人们算塔罗牌."},
|
12 |
+
]
|
13 |
+
|
14 |
+
def chat(message, history):
|
15 |
+
if message:
|
16 |
+
messages.append({"role": "user", "content": message})
|
17 |
+
response = openai.ChatCompletion.create(
|
18 |
+
model="gpt-3.5-turbo", messages=messages
|
19 |
+
)
|
20 |
+
reply = response.choices[0].message.content
|
21 |
+
# messages.append({"role": "assistant", "content": reply})
|
22 |
+
return reply
|
23 |
+
|
24 |
+
# def chat(user_input):
|
25 |
+
# if user_input:
|
26 |
+
# messages.append({"role": "user", "content": user_input})
|
27 |
+
# response = openai.ChatCompletion.create(
|
28 |
+
# model="gpt-3.5-turbo", messages=messages
|
29 |
+
# )
|
30 |
+
# reply = response.choices[0].message.content
|
31 |
+
# messages.append({"role": "assistant", "content": reply})
|
32 |
+
# return reply
|
33 |
+
|
34 |
+
inputs = gr.inputs.Textbox(label="User input")
|
35 |
+
outputs = gr.outputs.Textbox(label="Response")
|
36 |
+
|
37 |
+
chatInterface = gr.ChatInterface(
|
38 |
+
fn=chat,
|
39 |
+
# inputs=inputs,
|
40 |
+
# outputs=outputs,
|
41 |
+
title="AI 塔罗",
|
42 |
+
)
|
43 |
+
|
44 |
+
chatInterface.launch(share=True)
|
flagged/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
name,output,flag,username,timestamp
|
2 |
+
joey,Hello joey!,,,2023-07-19 22:37:33.742753
|