Skip to content

Commit ef32ced

Browse files
authored
Merge pull request #264 from gukoff/comments-to-docstrings
Turn class comments into class docstrings
2 parents da099fa + 34e8cd4 commit ef32ced

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

app/backend/approaches/chatreadretrieveread.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
from approaches.approach import Approach
77
from text import nonewlines
88

9-
# Simple retrieve-then-read implementation, using the Cognitive Search and OpenAI APIs directly. It first retrieves
10-
# top documents from search, then constructs a prompt with them, and then uses OpenAI to generate an completion
11-
# (answer) with that prompt.
129
class ChatReadRetrieveReadApproach(Approach):
10+
"""
11+
Simple retrieve-then-read implementation, using the Cognitive Search and OpenAI APIs directly. It first retrieves
12+
top documents from search, then constructs a prompt with them, and then uses OpenAI to generate an completion
13+
(answer) with that prompt.
14+
"""
15+
1316
prompt_prefix = """<|im_start|>system
1417
Assistant helps the company employees with their healthcare plan questions, and questions about the employee handbook. Be brief in your answers.
1518
Answer ONLY with the facts listed in the list of sources below. If there isn't enough information below, say you don't know. Do not generate answers that don't use the sources below. If asking a clarifying question to the user would help, ask the question.

app/backend/approaches/readretrieveread.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
from lookuptool import CsvLookupTool
1212
from typing import Any
1313

14-
# Attempt to answer questions by iteratively evaluating the question to see what information is missing, and once all information
15-
# is present then formulate an answer. Each iteration consists of two parts: first use GPT to see if we need more information,
16-
# second if more data is needed use the requested "tool" to retrieve it. The last call to GPT answers the actual question.
17-
# This is inspired by the MKRL paper[1] and applied here using the implementation in Langchain.
18-
# [1] E. Karpas, et al. arXiv:2205.00445
1914
class ReadRetrieveReadApproach(Approach):
15+
"""
16+
Attempt to answer questions by iteratively evaluating the question to see what information is missing, and once all information
17+
is present then formulate an answer. Each iteration consists of two parts:
18+
1. use GPT to see if we need more information
19+
2. if more data is needed, use the requested "tool" to retrieve it.
20+
The last call to GPT answers the actual question.
21+
This is inspired by the MKRL paper[1] and applied here using the implementation in Langchain.
22+
23+
[1] E. Karpas, et al. arXiv:2205.00445
24+
"""
2025

2126
template_prefix = \
2227
"You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. " \

app/backend/approaches/retrievethenread.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
from text import nonewlines
66
from typing import Any
77

8-
# Simple retrieve-then-read implementation, using the Cognitive Search and OpenAI APIs directly. It first retrieves
9-
# top documents from search, then constructs a prompt with them, and then uses OpenAI to generate an completion
10-
# (answer) with that prompt.
8+
119
class RetrieveThenReadApproach(Approach):
10+
"""
11+
Simple retrieve-then-read implementation, using the Cognitive Search and OpenAI APIs directly. It first retrieves
12+
top documents from search, then constructs a prompt with them, and then uses OpenAI to generate an completion
13+
(answer) with that prompt.
14+
"""
1215

1316
template = \
1417
"You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. " + \

0 commit comments

Comments
 (0)