diff options
author | Nate Buttke <nate-web@riseup.net> | 2023-08-13 01:21:03 -0700 |
---|---|---|
committer | Nate Buttke <nate-web@riseup.net> | 2023-08-13 01:21:03 -0700 |
commit | d02ee2b2d10769e184781879adc3b43aac8fe9bd (patch) | |
tree | 75d71815a29e1709f51310951160dec36ac7a5b8 | |
parent | e6d7296cfe1a9b87c128a0b5c51f97408a876cfc (diff) |
further clean server.py
-rw-r--r-- | server.py | 11 |
1 files changed, 3 insertions, 8 deletions
@@ -9,6 +9,8 @@ openai.api_key = os.getenv('OPENAI_KEY') import numpy as np from pathlib import PurePosixPath +FILETYPES = ['.sh', '.c', '.h', '.cpp', '.cxx', '.hxx', '.hpp', '.go', '.hs', '.js', '.py', '.rs'] + app = Flask(__name__, template_folder="./frontend", static_folder="./frontend", static_url_path="") def search_code(df, query, n=4): @@ -16,9 +18,7 @@ def search_code(df, query, n=4): query, engine="text-embedding-ada-002" ) - #df["similarity"] = df.summary_embeddings.apply(lambda x: cosine_similarity(x, query_embedding)) df["similarity"] = df.embedding_summary.apply(lambda x: cosine_similarity(x, query_embedding)) - # df["similarity"] = df.embeddings.apply(lambda x: cosine_similarity(x, query_embedding)) results = ( df.sort_values("similarity", ascending=False) ) @@ -71,15 +71,11 @@ def create_directory_tree(df): # My line df=pd.read_csv("./frontend/data/test_with_summary_and_embeddings.csv", converters={'embedding_summary': pd.eval}) -#df=pd.read_csv("./frontend/data/rs.csv", converters={'embedding_summary': pd.eval}) # need to do funny stuff to read in the data frame correctly from csv. that's # why the eval() is below. and pd.eval is above. +# df['embeddings'] = df['embeddings'].apply(lambda x: eval(x)) -#df['summary_embeddings'] = df['summary_embeddings'].apply(lambda x: eval(x)) -#df['embeddings'] = df['embeddings'].apply(lambda x: eval(x)) - -filetypes = ['.sh', '.c', '.h', '.cpp', '.cxx', '.hxx', '.hpp', '.go', '.hs', '.js', '.py', '.rs'] def check_path(path, dirstructure): children = None components = PurePosixPath(path).parts @@ -139,4 +135,3 @@ def explain(): if __name__ == '__main__': app.run(port=8080, debug=True) - #app.run(host="0.0.0.0", port=5001, debug=True) |