Skip to content

Commit

Permalink
fix : ai 검색 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
maie421 committed Jan 3, 2024
1 parent 8a07388 commit 1839c1c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 65 deletions.
5 changes: 1 addition & 4 deletions web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ def getCategory():

@app.route('/search', methods=['GET'])
def getSearchProduct():
if request.args.get('type') == 'default':
return product.getDefulatSearchProduct(request.args.get('keyword'), int(request.args.get('page')))
else:
return product.getAiSearchProduct(request.args.get('keyword'))
return product.getDefulatSearchProduct(request.args.get('keyword'), int(request.args.get('page')))

@app.route("/product/similar", methods=['GET'])
def getSimilarProducts():
Expand Down
55 changes: 1 addition & 54 deletions web/controller/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,57 +199,4 @@ def getDefulatSearchProduct(self, keyword, paging):
page={
'total_count': int(total_count),
'size': math.ceil(page_size)
},
type="default")



def getAiSearchProduct(self, keyword):
# cursor = self.db_conn.cursor()
#
# client = OpenAI(
# api_key="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",
# )
#
# datafile_path = "file/product_test_embedding.csv"
# product_text = ""
# name = ""
#
# df = pd.read_csv(datafile_path)
# print(keyword)
# results = search_products(df, keyword, n=1)
# for index, row in results.iterrows():
# try:
# name = row['name']
#
# model_id = "ft:gpt-3.5-turbo-0613:personal::8aZbTg6m"
# completion = client.chat.completions.create(
# model=model_id,
# messages=[
# {"role": "system", "content": "You are a friendly woman in your twenties."},
# {"role": "user", "content": name}
# ]
# )
#
# except Exception as e:
# print(f"An error occurred: {e}")
# break
#
# product_text = completion.choices[0].message.content
#
# category_select_sql = f"SELECT product_id, image, name, price, avg_price FROM track_price_changes.products WHERE name = '{name}'"
# print(category_select_sql)
# cursor.execute(category_select_sql)
# data = cursor.fetchall()
#
# df = pd.DataFrame(data, columns=['product_id', 'image', 'name', 'price', 'avg_price'])
#
# df['discount_rate'] = (df.avg_price - df.price) / df.avg_price * 100
# df['increase_rate'] = (df.price - df.avg_price) / df.avg_price * 100


return render_template('aiSearch.html',
# products=df.to_dict('records'),
# text=product_text,
# type="ai"
)
})
8 changes: 1 addition & 7 deletions web/templates/common/search.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
<section>
<form action="/search" method="get">
<div class="search px-4 px-lg-5 my-5 container d-flex">
<select name="type">
<option value="default"{% if type=="default" %} selected="selected"{% endif %}>기본</option>
<option value="ai"{% if type=="ai" %} selected="selected"{% endif %}>AI</option>
</select>
<input type="text" name="keyword"
value="{% if request.args.get('keyword') %}{{ request.args.get('keyword') }}{% endif %}"
placeholder="제품을 검색해 보세요" required>
{% if type != "ai" %}
<input type="text" name="page" value="1" style="display: none">
{% endif %}
<input type="text" name="page" value="1" style="display: none">
<button type="submit">검색</button>
</div>
</form>
Expand Down

0 comments on commit 1839c1c

Please sign in to comment.