Skip to content

Commit

Permalink
Fix fail to cache issue
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelthwan committed Mar 11, 2023
1 parent f4a89e4 commit f9b3fe3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/SearchGPTService.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from pathlib import Path

import pandas as pd
import yaml
Expand All @@ -8,7 +7,7 @@
from LLMService import LLMServiceFactory
from SemanticSearchService import BatchOpenAISemanticSearchService
from SourceService import SourceService
from Util import setup_logger, get_project_root
from Util import setup_logger, get_project_root, storage_cached

logger = setup_logger('SearchGPTService')

Expand Down Expand Up @@ -68,9 +67,8 @@ def validate_config(self):
if self.config['llm_service']['provider'] == 'openai':
assert self.config['llm_service']['openai_api']['api_key'], 'openai_api_key is required'

@storage_cached('web', 'search_text')
def query_and_get_answer(self, search_text):
cache_path = Path(self.config.get('cache').get('path')) # TODO: hide cache logic in main entrance

source_module = SourceService(self.config)
bing_text_df = source_module.extract_bing_text_df(search_text)
doc_text_df = source_module.extract_doc_text_df(bing_text_df)
Expand Down
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
search_text = 'the source of dark energy'

search_gpt_service = SearchGPTService()
response_text, source_text, data_json = search_gpt_service.query_and_get_answer(search_text)
response_text, source_text, data_json = search_gpt_service.query_and_get_answer(search_text=search_text)
print()

2 changes: 1 addition & 1 deletion src/website/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="container text-center">
<div class="row">
<div class="col-lg-12">
<p class="text-muted small mb-0">SearchGPT 20230311 Version (
<p class="text-muted small mb-0">SearchGPT 20230311_2 Version (
<a href="https://github.com/michaelthwan/searchGPT"><i class="fa fa-github"></i> Github</a>
). Your feedback will help us to improve</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def index_page():

if search_text is not None:
search_gpt_service = SearchGPTService(ui_overriden_config)
_, _, data_json = search_gpt_service.query_and_get_answer(search_text)
_, _, data_json = search_gpt_service.query_and_get_answer(search_text=search_text)
except Exception as e:
error = str(e)

Expand Down

0 comments on commit f9b3fe3

Please sign in to comment.