cmagganas commited on
Commit
dd00b61
1 Parent(s): 421716e

Upload folder using huggingface_hub

Browse files
app/.streamlit/secrets.toml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # OpenAI API Key
2
+ OPENAI_API_KEY = "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"
app/__pycache__/dataclean_hf.cpython-310.pyc CHANGED
Binary files a/app/__pycache__/dataclean_hf.cpython-310.pyc and b/app/__pycache__/dataclean_hf.cpython-310.pyc differ
 
app/__pycache__/openai_chat_completion.cpython-310.pyc CHANGED
Binary files a/app/__pycache__/openai_chat_completion.cpython-310.pyc and b/app/__pycache__/openai_chat_completion.cpython-310.pyc differ
 
app/openai_chat_completion.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import pandas as pd
3
  from dotenv import load_dotenv
4
  load_dotenv()
@@ -6,7 +7,7 @@ import openai
6
  import streamlit as st
7
 
8
  # # set OPENAI_API_KEY environment variable from .streamlit/secrets.toml file
9
- openai.api_key = st.secrets("OPENAI_API_KEY")
10
 
11
  # # set OPENAI_API_KEY environment variable from .env file
12
  # openai.api_key = os.getenv("OPENAI_API_KEY")
@@ -48,8 +49,8 @@ class OpenAIChatCompletions:
48
  # function to use test data to predict completions
49
  def predict_jsonl(
50
  self,
51
- # path_or_buf='../data/cookies_train.jsonl',
52
- path_or_buf='~/data/cookies_train.jsonl',
53
  n_samples=None,
54
  n_shot=None
55
  ):
@@ -83,10 +84,15 @@ class OpenAIChatCompletions:
83
  # a method that samples n rows from a jsonl file, returning a pandas dataframe
84
  @staticmethod
85
  def _sample_jsonl(
86
- # path_or_buf='../data/cookies_train.jsonl',
87
- path_or_buf='~/data/cookies_train.jsonl',
88
  n_samples=5
89
  ):
90
 
91
- jsonObj = pd.read_json(path_or_buf=path_or_buf, lines=True)
 
 
 
 
 
92
  return jsonObj.sample(n_samples, random_state=42)
 
1
  import os
2
+ from io import BytesIO
3
  import pandas as pd
4
  from dotenv import load_dotenv
5
  load_dotenv()
 
7
  import streamlit as st
8
 
9
  # # set OPENAI_API_KEY environment variable from .streamlit/secrets.toml file
10
+ openai.api_key = st.secrets["OPENAI_API_KEY"]
11
 
12
  # # set OPENAI_API_KEY environment variable from .env file
13
  # openai.api_key = os.getenv("OPENAI_API_KEY")
 
49
  # function to use test data to predict completions
50
  def predict_jsonl(
51
  self,
52
+ path_or_buf='../data/cookies_train.jsonl',
53
+ # path_or_buf='~/data/cookies_train.jsonl',
54
  n_samples=None,
55
  n_shot=None
56
  ):
 
84
  # a method that samples n rows from a jsonl file, returning a pandas dataframe
85
  @staticmethod
86
  def _sample_jsonl(
87
+ path_or_buf='../data/cookies_train.jsonl',
88
+ # path_or_buf='~/data/cookies_train.jsonl',
89
  n_samples=5
90
  ):
91
 
92
+ # jsonObj = pd.read_json(path_or_buf=path_or_buf, lines=True)
93
+ file_path = os.path.join(os.getcwd(), "../data/cookies_train.jsonl")
94
+ print(file_path)
95
+ with open(file_path, "r") as file:
96
+ jsonl_str = file.read()
97
+ jsonObj = pd.read_json(BytesIO(jsonl_str.encode()), lines=True, engine="pyarrow")
98
  return jsonObj.sample(n_samples, random_state=42)
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  datasets==2.13.0
2
  numpy==1.24.3
3
  openai==0.27.8
4
- pandas==2.0.2
5
  python-dotenv==1.0.0
6
  scikit_learn==1.2.2
7
  SQLAlchemy==2.0.18
 
1
  datasets==2.13.0
2
  numpy==1.24.3
3
  openai==0.27.8
4
+ pandas==2.0.3
5
  python-dotenv==1.0.0
6
  scikit_learn==1.2.2
7
  SQLAlchemy==2.0.18