Skip to content

Commit

Permalink
feat: change names for better self-explained code, handle error
Browse files Browse the repository at this point in the history
  • Loading branch information
rodonguyen committed Mar 23, 2024
1 parent a24cf32 commit 773b222
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ dmypy.json
# Cython debug symbols
cython_debug/

bin
local_sandbox
# folder containing temporary test files
cache

# litellm auto generated files
litellm_uuid.txt
Empty file removed pdffiles/.file
Empty file.
50 changes: 30 additions & 20 deletions src/discord_bot/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,37 @@


async def review_resume(model: str, url: str, server_url: str) -> list[str]:
# Download PDF, handle errors
# Parse PDF
# Send to LLM
# Return response

output_path = f"pdffiles/{time.time()}.pdf"
## Some how calling gdown inside this function lead to 100% memory utilization
# gdown.download(url, output_path, fuzzy=True)

os.system(f"poetry run gdown -O {output_path} --fuzzy {url}")

docs = fitz.open(output_path)
out_text_list = []
for page in docs:
out_text_list.append(page.get_text())
out_text = "\n\n".join(out_text_list)

# remove the downloaded file
os.remove(output_path)
try:
# Download PDF
output_path = f"cache/{time.time()}.pdf"
os.system(f"poetry run gdown -O {output_path} --fuzzy {url}")
## Some how calling gdown inside this function lead to 100% memory utilization
# gdown.download(url, output_path, fuzzy=True)

# Parse PDF
downloaded_file = fitz.open(output_path)
text = []
for page in downloaded_file:
text.append(page.get_text())
text = "\n\n".join(text)
os.remove(output_path) # Remove the downloaded file

print(f"Parsed content: {text}")


# Send to LLM
#
# Your implementation here
#
#
#
#


return ["NOT IMPLEMENTED YET"]
except Exception as e:
return split(f"Error: {e}")

return [f"Parsed content: {out_text[:1000]}"]


async def answer_question(model: str, question: str, server_url: str) -> list[str]:
Expand Down

0 comments on commit 773b222

Please sign in to comment.