tea-phan-y
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -75,7 +75,7 @@ def generate_response(user_query, relevant_segment):
|
|
75 |
response = openai.ChatCompletion.create(
|
76 |
model="gpt-4o",
|
77 |
messages=messages,
|
78 |
-
max_tokens=
|
79 |
temperature=0.2,
|
80 |
top_p=1,
|
81 |
frequency_penalty=0.5,
|
@@ -96,12 +96,12 @@ def generate_response(user_query, relevant_segment):
|
|
96 |
|
97 |
def query_model(question):
|
98 |
"""
|
99 |
-
Process a question, find relevant information, and generate a response.
|
100 |
"""
|
101 |
if question == "":
|
102 |
return "Welcome to LitBot! Ask me anything about literature, book themes, and the historical context behind your book."
|
103 |
relevant_segment = find_relevant_segment(question, segments)
|
104 |
-
if not relevant_segment:
|
105 |
return "Could not find specific information. Please refine your question."
|
106 |
response = generate_response(question, relevant_segment)
|
107 |
return response
|
|
|
75 |
response = openai.ChatCompletion.create(
|
76 |
model="gpt-4o",
|
77 |
messages=messages,
|
78 |
+
max_tokens=500,
|
79 |
temperature=0.2,
|
80 |
top_p=1,
|
81 |
frequency_penalty=0.5,
|
|
|
96 |
|
97 |
def query_model(question):
|
98 |
"""
|
99 |
+
Process a question, find relevant information, and generate a response. If no book title is given, return not relevant_segment.
|
100 |
"""
|
101 |
if question == "":
|
102 |
return "Welcome to LitBot! Ask me anything about literature, book themes, and the historical context behind your book."
|
103 |
relevant_segment = find_relevant_segment(question, segments)
|
104 |
+
if not relevant_segment:
|
105 |
return "Could not find specific information. Please refine your question."
|
106 |
response = generate_response(question, relevant_segment)
|
107 |
return response
|