Spaces:
Runtime error
Runtime error
Dmitry Kirsanov commited on
Commit ·
d465175
1
Parent(s): f8fed3a
redo logging
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import gradio as gr
|
|
| 3 |
import parse
|
| 4 |
import understand
|
| 5 |
import llm
|
|
|
|
| 6 |
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
load_dotenv()
|
|
@@ -22,5 +23,6 @@ gradio_app = gr.Interface(
|
|
| 22 |
outputs=[gr.Textbox(label="Parsed", lines=8)])
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
|
|
|
| 25 |
gradio_app.launch()
|
| 26 |
#test()
|
|
|
|
| 3 |
import parse
|
| 4 |
import understand
|
| 5 |
import llm
|
| 6 |
+
import logger
|
| 7 |
|
| 8 |
from dotenv import load_dotenv
|
| 9 |
load_dotenv()
|
|
|
|
| 23 |
outputs=[gr.Textbox(label="Parsed", lines=8)])
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|
| 26 |
+
logger.info("DU starts!")
|
| 27 |
gradio_app.launch()
|
| 28 |
#test()
|
llm.py
CHANGED
|
@@ -5,6 +5,8 @@ import google.generativeai as palm
|
|
| 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
|
|
@@ -65,8 +67,9 @@ 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 = api_key)
|
| 69 |
-
|
| 70 |
|
| 71 |
def send_question(self, question):
|
| 72 |
num_tokens = self.count_tokens(question)
|
|
|
|
| 5 |
import openai
|
| 6 |
import tiktoken
|
| 7 |
|
| 8 |
+
import logger
|
| 9 |
+
|
| 10 |
class LLM:
|
| 11 |
def __init__(self, context_length, api_endpoint, max_output_tokens):
|
| 12 |
self.context_length = context_length
|
|
|
|
| 67 |
def __init__(self):
|
| 68 |
super().__init__(context_length=128000, api_endpoint="https://api.openai.com/v1/chat/completions", max_output_tokens=4096)
|
| 69 |
api_key = os.environ.get("OPENAI_API_KEY")
|
| 70 |
+
logger.info(f"Using OpenAI key {api_key[-4:]}")
|
| 71 |
self.client = openai.OpenAI(api_key = api_key)
|
| 72 |
+
logger.info(f"Created OpenAI client")
|
| 73 |
|
| 74 |
def send_question(self, question):
|
| 75 |
num_tokens = self.count_tokens(question)
|
logger.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def info(message):
|
| 2 |
+
print(message)
|
parse.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
from bs4 import BeautifulSoup, Comment
|
| 2 |
|
|
|
|
|
|
|
| 3 |
def cleanup(soup):
|
| 4 |
|
| 5 |
# Remove all HTML comments
|
|
@@ -35,7 +37,7 @@ def cleanup(soup):
|
|
| 35 |
|
| 36 |
def parse(filepath):
|
| 37 |
soup = cleanup(BeautifulSoup(open(filepath).read(), 'html.parser'))
|
| 38 |
-
|
| 39 |
return soup
|
| 40 |
|
| 41 |
|
|
|
|
| 1 |
from bs4 import BeautifulSoup, Comment
|
| 2 |
|
| 3 |
+
import logger
|
| 4 |
+
|
| 5 |
def cleanup(soup):
|
| 6 |
|
| 7 |
# Remove all HTML comments
|
|
|
|
| 37 |
|
| 38 |
def parse(filepath):
|
| 39 |
soup = cleanup(BeautifulSoup(open(filepath).read(), 'html.parser'))
|
| 40 |
+
logger.info(f"Parsed {filepath}")
|
| 41 |
return soup
|
| 42 |
|
| 43 |
|