Spaces:
Runtime error
Runtime error
Commit ·
fb76f26
0
Parent(s):
Duplicate from vkscmu/DCO-General-GPT4-Bot
Browse files- .gitattributes +35 -0
- README.md +7 -0
- Speech_GPT4_prompt_chatbot.code-workspace +8 -0
- __pycache__/prompts.cpython-310.pyc +0 -0
- blocks_chatbot.py +71 -0
- flagged_data_points/component 0/tmp6il90xw8.json +1 -0
- flagged_data_points/log.csv +6 -0
- prompts.py +3 -0
- requirements.txt +2 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: DCO-General-GPT4-Bot
|
| 3 |
+
app_file: blocks_chatbot.py
|
| 4 |
+
sdk: gradio
|
| 5 |
+
sdk_version: 3.40.1
|
| 6 |
+
duplicated_from: vkscmu/DCO-General-GPT4-Bot
|
| 7 |
+
---
|
Speech_GPT4_prompt_chatbot.code-workspace
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"folders": [
|
| 3 |
+
{
|
| 4 |
+
"path": "."
|
| 5 |
+
}
|
| 6 |
+
],
|
| 7 |
+
"settings": {}
|
| 8 |
+
}
|
__pycache__/prompts.cpython-310.pyc
ADDED
|
Binary file (1.31 kB). View file
|
|
|
blocks_chatbot.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#Developer: Gabriel Sha - Information Systems - Carnegie Mellon University
|
| 2 |
+
|
| 3 |
+
import openai
|
| 4 |
+
import os
|
| 5 |
+
import gradio
|
| 6 |
+
from datetime import date
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
import _thread
|
| 9 |
+
|
| 10 |
+
from prompts import debate_prompt_1
|
| 11 |
+
|
| 12 |
+
#openai.api_key = os.environ.get('OPEN_API_KEY', 'API key not found')
|
| 13 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 14 |
+
|
| 15 |
+
# hf_writer = gradio.HuggingFaceDatasetSaver(os.getenv('HUGGINGFACE_KEY'), "FreeSpeech-GPT4-Chatbot")
|
| 16 |
+
|
| 17 |
+
print("OPENAI_API_KEY Working...\n")
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
users = {(os.getenv("diss1"), os.getenv("PASSWORD")),(os.getenv("diss2"), os.getenv("PASSWORD1")),
|
| 21 |
+
(os.getenv("diss3"), os.getenv("PASSWORD")),(os.getenv("diss4"), os.getenv("PASSWORD")),
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
currentUser = []
|
| 25 |
+
|
| 26 |
+
def authorization(username, password):
|
| 27 |
+
if (username, password) in users:
|
| 28 |
+
currentUser.append(username)
|
| 29 |
+
return True
|
| 30 |
+
else:
|
| 31 |
+
return False
|
| 32 |
+
|
| 33 |
+
messages = [{"role": "system", "content": debate_prompt_1}]
|
| 34 |
+
|
| 35 |
+
callback = gradio.CSVLogger()
|
| 36 |
+
|
| 37 |
+
with gradio.Blocks() as demo:
|
| 38 |
+
gradio.Markdown("""
|
| 39 |
+
This is a general use bot for accessing GPT4. The temperature setting is 0.8 making it is moderately generative.
|
| 40 |
+
""")
|
| 41 |
+
|
| 42 |
+
chatbot = gradio.Chatbot()
|
| 43 |
+
msg = gradio.Textbox()
|
| 44 |
+
clear = gradio.ClearButton([msg, chatbot])
|
| 45 |
+
# btn = gradio.Button("Save Chat")
|
| 46 |
+
|
| 47 |
+
def CustomChatGPT(user_input, chat_history):
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
messages.append({"role": "user", "content": user_input})
|
| 51 |
+
response = openai.ChatCompletion.create(
|
| 52 |
+
model = "gpt-4",
|
| 53 |
+
messages = messages,
|
| 54 |
+
temperature=0.8,
|
| 55 |
+
max_tokens=512,
|
| 56 |
+
top_p=1
|
| 57 |
+
)
|
| 58 |
+
ChatGPT_reply = response["choices"][0]["message"]["content"]
|
| 59 |
+
messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 60 |
+
chat_history.append((user_input, ChatGPT_reply))
|
| 61 |
+
return "", chat_history
|
| 62 |
+
|
| 63 |
+
# callback.setup([chatbot, msg], "flagged_data_points")
|
| 64 |
+
# # We can choose which components to flag -- in this case, we'll flag all of them
|
| 65 |
+
# btn.click(lambda *args: callback.flag(args),
|
| 66 |
+
# [chatbot, msg], None, preprocess=False)
|
| 67 |
+
msg.submit(CustomChatGPT, [msg, chatbot], [msg, chatbot])
|
| 68 |
+
|
| 69 |
+
demo.launch(auth = authorization)
|
| 70 |
+
|
| 71 |
+
print("Activity has been logged in the activity folder. Have a nice day!")
|
flagged_data_points/component 0/tmp6il90xw8.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[["hey\\", "Hello, today we're discussing Benjamin Libet's \"Do we have free will?\" Would you like me to defend or oppose the paper's argument?"], ["defend", "Very well, we'll defend Libet's argument that our conscious decisions may not be the origin of our actions, but we consciously have the power to veto actions initiated by our subconscious.\n\nLet's start. What's your first counter-argument to Libet's claims?"], ["i think he is dumb", "While you may have reservations about Libet's work due to its unconventional nature, it's more constructive to address specific points of disagreement. For instance, do you disagree with his methodology or his interpretations of the study's findings? Let's focus on the content of his argument."]]
|
flagged_data_points/log.csv
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
component 0,component 1,flag,username,timestamp
|
| 2 |
+
/mnt/c/Users/gsha/Documents/CMU/80-101 ChatBot Project/prompt_debate_chatbot/flagged_data_points/component 0/tmpgbu77phb.json,,,,2023-08-25 01:37:13.367998
|
| 3 |
+
/mnt/c/Users/gsha/Documents/CMU/80-101 ChatBot Project/prompt_debate_chatbot/flagged_data_points/component 0/tmpvb0d8tnl.json,,,,2023-08-25 01:37:15.575766
|
| 4 |
+
/mnt/c/Users/gsha/Documents/CMU/80-101 ChatBot Project/prompt_debate_chatbot/flagged_data_points/component 0/tmp6il90xw8.json,,,,2023-08-25 01:37:16.345648
|
| 5 |
+
/mnt/c/Users/gsha/Documents/CMU/80-101 ChatBot Project/prompt_debate_chatbot/flagged_data_points/component 0/tmpeaeycgpc.json,,,,2023-08-25 01:40:06.933321
|
| 6 |
+
/mnt/c/Users/gsha/Documents/CMU/80-101 ChatBot Project/prompt_debate_chatbot/flagged_data_points/component 0/tmpw4xi9ss7.json,,,,2023-08-25 01:40:30.332171
|
prompts.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
debate_prompt_1 = """
|
| 2 |
+
You are a helpful AI, you always try to err on the side of accuracy. If you don't know something, then tell the user and don't make us answers.
|
| 3 |
+
"""
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
openai
|