Spaces:
Runtime error
Runtime error
Dmitry Kirsanov commited on
Commit ·
c1789c7
1
Parent(s): 0b4b0ed
fixes, privatize key
Browse files
.env
CHANGED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
# Once you add your API key below, make sure to not share it with anyone! The API key should remain private.
|
| 2 |
-
OPENAI_API_KEY=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
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -2,6 +2,13 @@ import gradio as gr
|
|
| 2 |
|
| 3 |
import parse
|
| 4 |
import understand
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def process(filename, model):
|
|
|
|
| 2 |
|
| 3 |
import parse
|
| 4 |
import understand
|
| 5 |
+
import llm
|
| 6 |
+
|
| 7 |
+
from dotenv import load_dotenv
|
| 8 |
+
load_dotenv()
|
| 9 |
+
|
| 10 |
+
from transformers.utils import logging
|
| 11 |
+
logger = logging.get_logger("transformers")
|
| 12 |
|
| 13 |
|
| 14 |
def process(filename, model):
|
llm.py
CHANGED
|
@@ -5,9 +5,6 @@ import google.generativeai as palm
|
|
| 5 |
import openai
|
| 6 |
import tiktoken
|
| 7 |
|
| 8 |
-
from dotenv import load_dotenv
|
| 9 |
-
load_dotenv()
|
| 10 |
-
|
| 11 |
class LLM:
|
| 12 |
def __init__(self, context_length, api_endpoint, max_output_tokens):
|
| 13 |
self.context_length = context_length
|
|
@@ -67,7 +64,9 @@ class Gemini15(LLM):
|
|
| 67 |
class GPT4Turbo(LLM):
|
| 68 |
def __init__(self):
|
| 69 |
super().__init__(context_length=128000, api_endpoint="https://api.openai.com/v1/chat/completions", max_output_tokens=4096)
|
| 70 |
-
|
|
|
|
|
|
|
| 71 |
|
| 72 |
def send_question(self, question):
|
| 73 |
num_tokens = self.count_tokens(question)
|
|
|
|
| 5 |
import openai
|
| 6 |
import tiktoken
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
class LLM:
|
| 9 |
def __init__(self, context_length, api_endpoint, max_output_tokens):
|
| 10 |
self.context_length = context_length
|
|
|
|
| 64 |
class GPT4Turbo(LLM):
|
| 65 |
def __init__(self):
|
| 66 |
super().__init__(context_length=128000, api_endpoint="https://api.openai.com/v1/chat/completions", max_output_tokens=4096)
|
| 67 |
+
api_key = os.environ.get("OPENAI_API_KEY")
|
| 68 |
+
self.client = openai.OpenAI(api_key)
|
| 69 |
+
logger.info(f"Created OpenAI client with key {api_key[-4:]}")
|
| 70 |
|
| 71 |
def send_question(self, question):
|
| 72 |
num_tokens = self.count_tokens(question)
|
parse.py
CHANGED
|
@@ -1,9 +1,5 @@
|
|
| 1 |
from bs4 import BeautifulSoup, Comment
|
| 2 |
|
| 3 |
-
from transformers.utils import logging
|
| 4 |
-
|
| 5 |
-
logger = logging.get_logger("transformers")
|
| 6 |
-
|
| 7 |
def cleanup(soup):
|
| 8 |
|
| 9 |
# Remove all HTML comments
|
|
@@ -39,7 +35,7 @@ def cleanup(soup):
|
|
| 39 |
|
| 40 |
def parse(filepath):
|
| 41 |
soup = cleanup(BeautifulSoup(open(filepath).read(), 'html.parser'))
|
| 42 |
-
logger.
|
| 43 |
return soup
|
| 44 |
|
| 45 |
|
|
|
|
| 1 |
from bs4 import BeautifulSoup, Comment
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def cleanup(soup):
|
| 4 |
|
| 5 |
# Remove all HTML comments
|
|
|
|
| 35 |
|
| 36 |
def parse(filepath):
|
| 37 |
soup = cleanup(BeautifulSoup(open(filepath).read(), 'html.parser'))
|
| 38 |
+
logger.info(f"Parsed {filepath}")
|
| 39 |
return soup
|
| 40 |
|
| 41 |
|