yonikremer commited on
Commit
dfa084c
1 Parent(s): dbafbbf

moved default number of web results to prompt engineering file

Browse files
Files changed (2) hide show
  1. hanlde_form_submit.py +5 -5
  2. prompt_engeneering.py +4 -2
hanlde_form_submit.py CHANGED
@@ -34,12 +34,12 @@ def generate_text(
34
  ) -> str:
35
  """
36
  Generates text using the given pipeline.
37
- :param pipeline: The pipeline to use.
38
- :param prompt: The prompt to use.
39
- :param output_length: The size of the groups to use.
40
- :return: The generated text.
41
  """
42
- better_prompt = rewrite_prompt(prompt, 5)
43
  return pipeline(
44
  prompt_s=better_prompt,
45
  max_new_tokens=output_length,
 
34
  ) -> str:
35
  """
36
  Generates text using the given pipeline.
37
+ :param pipeline: The pipeline to use. GroupedSamplingPipeLine.
38
+ :param prompt: The prompt to use. str.
39
+ :param output_length: The size of the text to generate in tokens. int > 0.
40
+ :return: The generated text. str.
41
  """
42
+ better_prompt = rewrite_prompt(prompt)
43
  return pipeline(
44
  prompt_s=better_prompt,
45
  max_new_tokens=output_length,
prompt_engeneering.py CHANGED
@@ -49,10 +49,12 @@ def format_search_result(search_result: Generator[SearchResult, None, None]) ->
49
 
50
  def rewrite_prompt(
51
  prompt: str,
52
- num_results: int,
53
  ) -> str:
54
  """Rewrites the prompt by adding web search results to it."""
55
- raw_results = get_web_search_results(prompt, num_results)
 
 
 
56
  formatted_results = "Web search results: " + format_search_result(raw_results)
57
  formatted_date = "Current date: " + datetime.now().strftime("%d/%m/%Y")
58
  formatted_prompt = f"Query: {prompt}"
 
49
 
50
  def rewrite_prompt(
51
  prompt: str,
 
52
  ) -> str:
53
  """Rewrites the prompt by adding web search results to it."""
54
+ raw_results = get_web_search_results(
55
+ prompt=prompt,
56
+ num_results=5,
57
+ )
58
  formatted_results = "Web search results: " + format_search_result(raw_results)
59
  formatted_date = "Current date: " + datetime.now().strftime("%d/%m/%Y")
60
  formatted_prompt = f"Query: {prompt}"