Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baby Steps #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/
cover/


code/test.py
code/test_2.py
code/api_test.py
416 changes: 92 additions & 324 deletions README.md

Large diffs are not rendered by default.

Empty file added __init__.py
Empty file.
Binary file added blog.docx
Binary file not shown.
Empty file added code/__init__.py
Empty file.
1,306 changes: 1,306 additions & 0 deletions code/agriculture_data.json

Large diffs are not rendered by default.

1,403 changes: 1,403 additions & 0 deletions code/agriculture_data.txt

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions code/api_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import requests
import json

#this should send the api a get request then saves the result data to the anime_data.json file
def anime_data_pull(size):

#size is an integer, the last value for size was 100. Size indicates how many entities to load up
url = "https://anime-db.p.rapidapi.com/anime"

querystring = {"page": "1", "size": size, "sortBy": "ranking", "sortOrder": "asc"}

headers = {
"x-rapidapi-key": "135634c5bcmsh9ebfb79c20e98f8p15bdf9jsn7fb31eef00ef",
"x-rapidapi-host": "anime-db.p.rapidapi.com"
}

response = requests.get(url, headers=headers, params=querystring)

if response.status_code == 200: #if fetch was successful
data = response.json()
with open('data_source/anime_data/anime_data.json', 'w') as json_file:
json.dump(data, json_file, indent=4) # indent=4 is used for pretty-printing the JSON
print("JSON data saved to 'data.json'")
else :
print(f"Request failed with status code {response.status_code}")


#this will format the anime_data.json file into raw text and put it in the anime_list file
def update_anime_list():

with open('data_source/anime_data/anime_data.json', 'r', encoding='utf-8') as json_file:
data = json.load(json_file)
data = data['data']

with open('data_source/anime_data/anime_list.txt', 'w', encoding='utf-8') as file:
for anime in data:
for key, value in anime.items():
if type(value) != list:
file.write(f"{key}: {value}")
else:
file.write(f"{key}: ")
for i in value:
file.write(f"{i}, ")
file.write("\n")
file.write('-' * 100)

4 changes: 4 additions & 0 deletions code/chatui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import uvicorn

import remote_data_access as rda #for api get requests

def parse_args() -> argparse.Namespace:
"""Parse command-line arguments for the program.
Expand Down Expand Up @@ -129,4 +130,7 @@ def parse_args() -> argparse.Namespace:
proxy_prefix = os.environ.get("PROXY_PREFIX")
blocks = pages.converse.build_page(client)
blocks.queue(max_size=10)

rda.main() #May slow down the program when running especially at the start, pulls data from the api links and updates their storage

blocks.launch(server_name="0.0.0.0", server_port=8080, root_path=proxy_prefix)
4 changes: 3 additions & 1 deletion code/chatui/assets/kaizen-theme.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.tabitem {
.tabitem, .tab, .tab-container {
background-color: var(--block-background-fill);
align-items: center;
justify-content: center;
}

.gradio-container {
Expand Down
2 changes: 1 addition & 1 deletion code/chatui/pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"""This module contains definitions for all the chatui pages."""
from chatui.pages import converse, kb

__all__ = ["converse", "kb"]
__all__ = ["converse", "kb"]
831 changes: 476 additions & 355 deletions code/chatui/pages/converse.py

Large diffs are not rendered by default.

Loading