Skip to content

Commit

Permalink
browsing update
Browse files Browse the repository at this point in the history
  • Loading branch information
c0sogi committed Jun 15, 2023
1 parent 4049014 commit 90da1ee
Show file tree
Hide file tree
Showing 15 changed files with 1,142 additions and 967 deletions.
4 changes: 4 additions & 0 deletions app/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ class ChatConfig:
EMBEDDING_TOKEN_CHUNK_OVERLAP # number of tokens to overlap between chunks
)
summarization_chunk_size: int = 2048
query_context_token_limit: int = 2048
scrolling_chunk_size_when_browsing: int = 1024
scrolling_overlap_when_browsing: int = 256
vectorstore_n_results_limit: int = 3
global_prefix: Optional[str] = GLOBAL_PREFIX # prefix for global chat
global_suffix: Optional[str] = GLOBAL_SUFFIX # suffix for global chat

Expand Down
23 changes: 16 additions & 7 deletions app/models/openai_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ class OpenAIFunctions:
],
required=["link"],
).to_dict()
ANSWERABLE_OR_NOT: dict = OpenAIFunction(
name="answerable_or_not",
description="Determine if you can answer the user's question.",
CONTROL_WEB_PAGE: dict = OpenAIFunction(
name="control_web_page",
description=(
"Control the web page to read more information or stop reading. You have to gather suffici"
"ent information answer the user's question."
),
parameters=[
OpenAIFunctionParameter(
name="answerable",
type=bool,
enum=[True, False],
name="action",
type=str,
description=(
"Whether to scroll down, go back, or finish browsing. Select `scroll_down` if you"
"must scroll down to read more information. Select `go_back` if you need to g"
"o back to the previous page to read other information. Select `finish_browsing` "
"if you can answer the user's question with given information."
),
enum=["scroll_down", "go_back", "finish_browsing"],
),
],
required=["answerable"],
required=["action"],
).to_dict()
WEB_BROWSING: dict = OpenAIFunction(
name="web_browsing",
Expand Down
8 changes: 4 additions & 4 deletions app/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Shared(metaclass=SingletonMetaClass):
browsing_llm: CustomChatOpenAI = field(init=False)
web_search_llm: CustomChatOpenAI = field(init=False)
vectorstore_search_llm: CustomChatOpenAI = field(init=False)
answerable_or_not_llm: CustomChatOpenAI = field(init=False)
control_web_page_llm: CustomChatOpenAI = field(init=False)
map_reduce_summarize_chain: MapReduceDocumentsChain = field(init=False)
stuff_summarize_chain: StuffDocumentsChain = field(init=False)
token_text_splitter: CustomTokenTextSplitter = field(
Expand Down Expand Up @@ -69,10 +69,10 @@ def __post_init__(self):
},
**common_llm_kwargs,
)
self.answerable_or_not_llm = CustomChatOpenAI(
self.control_web_page_llm = CustomChatOpenAI(
model_kwargs={
"functions": [OpenAIFunctions.ANSWERABLE_OR_NOT],
"function_call": OpenAIFunctions.ANSWERABLE_OR_NOT,
"functions": [OpenAIFunctions.CONTROL_WEB_PAGE],
"function_call": OpenAIFunctions.CONTROL_WEB_PAGE,
},
**common_llm_kwargs,
)
Expand Down
Loading

0 comments on commit 90da1ee

Please sign in to comment.