Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
strikoder committed May 24, 2023
0 parents commit 380386e
Show file tree
Hide file tree
Showing 13 changed files with 991 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/ActasGPT.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ActasGPT

Binary file added __pycache__/utils.cpython-310.pyc
Binary file not shown.
61 changes: 61 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import streamlit as st
from streamlit_ace import st_ace
import openai
from utils import input_prompts, get_completion, get_ideal_prompt

# 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

st.title('Act as GPT')

psw_col, sel_col = st.columns([2, 1])

OPENAI_API_KEY = psw_col.text_input("OpenAI API key", type='password')

model = sel_col.selectbox(
'Model',
('gpt-3.5-turbo', 'gpt-4'))

st.write('\n')
st.write('\n')

# initilizing the selectbox with an empty element
input_prompts = [''] + input_prompts.tolist()

user_input = st.selectbox('Select an input prompt', input_prompts)
st.write('Act as:', user_input)
print(user_input)

if user_input != "":
last_sentence = None
sentences_counter = -1
openai.api_key = OPENAI_API_KEY

# Receiving input from the df
modified_input = get_ideal_prompt(user_input)
sentences = modified_input.split(".")

# TODO: Debug all the dataset (gpt prompt generator)

# Find the last sentence containing the word "first"
for sentence in reversed(sentences):
if "first" in sentence.lower().split():
last_sentence = sentence.strip()
break
else:
sentences_counter -= 1

if last_sentence:
input_first_half = ". ".join(sentences[:sentences_counter]) + "."
st.write(input_first_half)
# Create a reactive text area with live update
input_second_half = st.text_area("modified_input", value=last_sentence + ".", key="text_area")
input_text = input_first_half + input_second_half

if st.button("Run"):
write_col1, write_col2, write_col3 = st.columns([1, 1, 1])
output = get_completion(input_text, model)
write_col1.write(output)
output = get_completion(input_text, model)
write_col2.write(output)
output = get_completion(input_text, model)
write_col3.write(output)
164 changes: 164 additions & 0 deletions prompts.csv

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pandas as pd
import openai

prompts_df = pd.read_csv("prompts.csv")
input_prompts = prompts_df["act"] # used in streamlit interface



def get_ideal_prompt(user_prompt):
print(user_prompt)
filtered_rows = prompts_df[prompts_df['act'].isin([user_prompt])]
if not filtered_rows.empty:
ideal_prompt = filtered_rows['prompt'].iloc[0]
return ideal_prompt


get_ideal_prompt("Travel Guide")


def get_completion(prompt, model="gpt-3.5-turbo"):
if not prompt:
return prompt # Return an empty string if the prompt is invalid
# you will be provided with a prompt to act as someone or something, try to give the most ideal output for an unexpierienced user and epxlain everything from scratch
messages = [
{"role": "system",
"content": "You will act as an advanced language model. The user wants you to simulate the experience of interacting with the provided prompt."},
{"role": "user", "content": prompt}
]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0.3,
)
return response.choices[0].message["content"]

0 comments on commit 380386e

Please sign in to comment.