Skip to content

Commit

Permalink
Add eval module for generating docs directory, with test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
luandro committed May 8, 2024
1 parent 029bdba commit b878122
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PRODUCTION=false
LOCAL_MODE=false
CHECK=true
CACHE_DIR=/tmp/rag_cache
DOCS_DIR=./docs

# LANGFUSE
# If using cloud, get keys from https://cloud.langfuse.com
Expand Down
25 changes: 25 additions & 0 deletions app/eval/gen_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import tempfile

import requests
from bs4 import BeautifulSoup

documents_directory = None
test_size = None
# Check if TEST environment variable is set to true
if os.getenv("TEST", "false").lower() == "true":
print("Running in test mode")
test_size = 1
# Use a temporary directory
documents_directory = tempfile.mkdtemp()
# Fetch a random wiki page content
wiki_random_url = "https://en.wikipedia.org/wiki/Special:Random"
response = requests.get(wiki_random_url)
soup = BeautifulSoup(response.content, "html.parser")
wiki_content = soup.get_text()
# Write the content to a txt file in the temporary directory
with open(os.path.join(documents_directory, "random_wiki_page.txt"), "w") as file:
file.write(wiki_content)
else:
documents_directory = os.getenv("DOCS_DIR", "./docs")
test_size = 10

0 comments on commit b878122

Please sign in to comment.