Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,26 +29,25 @@ end_sequence = "I hope that helps!"
|
|
29 |
|
30 |
def generate_key_points(text):
|
31 |
prompt = f"""
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
"""
|
52 |
return llm_client.text_generation(prompt, max_new_tokens=2000, stream=True, stop_sequences=[end_sequence])
|
53 |
|
54 |
|
@@ -173,11 +172,11 @@ def run_display(text):
|
|
173 |
current_output = ""
|
174 |
for output in generate_key_points(text):
|
175 |
current_output += output
|
176 |
-
yield None, "```
|
177 |
current_output = current_output.replace("</s>", "")
|
178 |
dataframe, _ = parse_llm_output(current_output)
|
179 |
map = create_map_from_markers(dataframe)
|
180 |
-
yield map, "```
|
181 |
|
182 |
|
183 |
def select_example(df, data: gr.SelectData):
|
|
|
29 |
|
30 |
def generate_key_points(text):
|
31 |
prompt = f"""
|
32 |
+
Please generate a set of key geographical points for the following description: {text}, as a json list of less than 10 dictionnaries with the following keys: 'name', 'description'.
|
33 |
+
Precise the full location in the 'name' if there is a possible ambiguity: for instance given that there are Chinatowns in several US cities, give the city name to disambiguate.
|
34 |
+
Generally try to minimize the distance between locations. Always think of the transportation means that you want to use, and the timing: morning, afternoon, where to sleep.
|
35 |
+
Only generate two sections: 'Thought:' provides your rationale for generating the points, then you list the locations in 'Key points:'.
|
36 |
+
Then generate '{end_sequence}' to indicate the end of the response.
|
37 |
+
|
38 |
+
For instance:
|
39 |
+
Description: {description_sf}
|
40 |
+
Thought: {output_example_sf}
|
41 |
+
{end_sequence}
|
42 |
+
|
43 |
+
Description: {description_loire}
|
44 |
+
Thought: {output_example_loire}
|
45 |
+
{end_sequence}
|
46 |
+
|
47 |
+
Now begin. You can make the descriptions a bit more verbose than in the examples.
|
48 |
+
|
49 |
+
Description: {text}
|
50 |
+
Thought:"""
|
|
|
51 |
return llm_client.text_generation(prompt, max_new_tokens=2000, stream=True, stop_sequences=[end_sequence])
|
52 |
|
53 |
|
|
|
172 |
current_output = ""
|
173 |
for output in generate_key_points(text):
|
174 |
current_output += output
|
175 |
+
yield None, "```text\n" + current_output + "\n```"
|
176 |
current_output = current_output.replace("</s>", "")
|
177 |
dataframe, _ = parse_llm_output(current_output)
|
178 |
map = create_map_from_markers(dataframe)
|
179 |
+
yield map, "```text\n" + current_output + "\n```"
|
180 |
|
181 |
|
182 |
def select_example(df, data: gr.SelectData):
|