Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

header fix? #31

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import os
import Paginator
from model import main

from dotenv import load_dotenv
load_dotenv()
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
Expand Down Expand Up @@ -32,4 +33,4 @@ async def peer(ctx, arg):
new_embed = discord.Embed(title="Not The Right Channel!", description=output, color=3447003)
return await ctx.send(embed=new_embed)

bot.run(os.environ['BOT_TOKEN'])
bot.run(os.getenv('product_spec_bot'))
8 changes: 5 additions & 3 deletions model.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from dotenv import load_dotenv
from notion_extraction import extract_product_spec_text, parse_product_spec_text, extract_id_from_url
from prompts import happy_path, milestones, problem, schedule, solution, success_criteria, target_users, tech_stack
import requests
import os
import openai

openai.api_key = os.environ['OPENAI_API_KEY1']
from dotenv import load_dotenv
load_dotenv()
openai.api_key = os.getenv('OPENAI_API_KEY1')

def main(url):

Expand Down Expand Up @@ -56,4 +58,4 @@ def main(url):

return feedback_summary["choices"][0]["text"]
"""
return feedbacks
return feedbacks
39 changes: 34 additions & 5 deletions notion_extraction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import requests
import os
from dotenv import load_dotenv
import openai
import time

notion_token = os.environ['NOTION_TOKEN1']

load_dotenv()
notion_token = os.getenv('NOTION_TOKEN')

def extract_id_from_url(url):
return url.split('-')[-1]
Expand Down Expand Up @@ -69,15 +74,39 @@ def match_name_to_label(name): # Matches a name to a product spec label
highest_similarity_score = 0
most_similar = None

for label in labels: # Finds the label with the highest similarity score
openai.api_key = os.getenv("OPENAI_API_KEY1")

labels = ['Problem Statement', 'Solution Statement', 'Who Has This Problem?', 'Success Criteria', 'Success Metrics', 'Milestones', 'Schedule of Deliverables', 'Tech Stack', 'Happy Path']

questionable_header = name
response = openai.Completion.create(
model="text-curie-001",
prompt=f"prompt: answer the following question only using the header_list, then say where they are in the list\n\nheader_list: 'Problem Statement', 'Solution Statement', 'Who Has This Problem?', 'Success Criteria', 'Success Metrics', 'Milestones', 'Schedule of Deliverables', 'Tech Stack', 'Happy Path'\n\nquestion: out of the header_list which one is most similar to the header \"Other Ideas Further areas of improvement:\"?\n\noutput: \"Other Ideas Further areas of improvement\" is most similar to the header \"Milestones\". milestones is the sixth in header_list\n\nquestion: out of the header_list which one is most similar to the header \"Success Criteria\"?\n\noutput: \"Success Criteria\" is most similar to the header \"Success Criteria\" Success Criteria is the fourth in header_list.\n\nquestion: out of the header_list which one is most similar to the header \"What The Product Will Not Do\"?\n\noutput: \"What The Product Will Not Do\" is most similar to the header \"Success Criteria\" Success Criteria is the fourth in header_list.\n\nquestion: out of the header_list which one is most similar to the header \"{questionable_header}\"?\n\noutput: \"{questionable_header}\" is most similar to the header ",
temperature=1,
max_tokens=75,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
corrected_header = response["choices"][0]["text"]
redone_lables = corrected_header.replace('"',"")
for x in labels:
if x in redone_lables:
print('ai generated labels worked', x)
return x


for y in range(2): print('jacard runnging as backup for[gtp3 failure]')
print(f"'{redone_lables}' is the out come of '{questionable_header}' delete this line of code later")
for label in labels: # Finds the label with the highest similarity score

similarity_score = jaccard_similarity(label.split(), name.split())

if similarity_score > highest_similarity_score:

most_similar = label
highest_similarity_score = similarity_score

return most_similar


Expand Down