added ability to select iterations of research steps

This commit is contained in:
assafelovic
2023-11-16 13:18:01 +02:00
parent deeaaf2887
commit 31737ac599
3 changed files with 5 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ class Config:
self.memory_backend = "local"
self.total_words = 1000
self.report_format = "apa"
self.max_iterations = 1
self.max_iterations = 3
self.load_config_file()

View File

@@ -76,11 +76,12 @@ async def get_sub_queries(query, agent_role_prompt, cfg):
sub_queries: List of sub queries
"""
max_research_iterations = cfg.max_iterations if cfg.max_iterations else 1
response = await create_chat_completion(
model=cfg.smart_llm_model,
messages=[
{"role": "system", "content": f"{agent_role_prompt}"},
{"role": "user", "content": generate_search_queries_prompt(query)}],
{"role": "user", "content": generate_search_queries_prompt(query, max_iterations=max_research_iterations)}],
temperature=0,
llm_provider=cfg.llm_provider
)

View File

@@ -1,13 +1,13 @@
from datetime import datetime
def generate_search_queries_prompt(question):
def generate_search_queries_prompt(question, max_iterations=3):
""" Generates the search queries prompt for the given question.
Args: question (str): The question to generate the search queries prompt for
Returns: str: The search queries prompt for the given question
"""
return f'Write 3 google search queries to search online that form an objective opinion from the following: "{question}"' \
return f'Write {max_iterations} google search queries to search online that form an objective opinion from the following: "{question}"' \
f'Use the current date if needed: {datetime.now().strftime("%B %d, %Y")}.\n' \
f'You must respond with a list of strings in the following format: ["query 1", "query 2", "query 3"].'