Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ParisNeo committed Dec 15, 2024
1 parent 48cbd7b commit 310cc40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lollms/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,18 +1092,20 @@ def prepare_query(self, client_id: str, message_id: int = -1, is_continue: bool
self.personality.step_start("Building vector store query")
q = f"{self.separator_template}".join([
"make a RAG vector database query from the last user prompt given this discussion.",
f"{self.system_custom_header('discussion')}",
"---",
"--- discussion --",
f"{discussion[-2048:]}",
"---",
])
template = """{
"query": "[the rag query deduced from the last user prompt]"
"query": "[the rag query deduced from the last messgae in the discussion]"
}
"""
query = self.personality.generate_code(q, self.personality.image_files, template, callback=self.personality.sink)
query = json.loads(query)
query = query["query"]
if query is None:
query = current_message.content
else:
query = json.loads(query)
query = query["query"]
self.personality.step_end("Building vector store query")
ASCIIColors.magenta(f"Query: {query}")
self.personality.step(f"Query: {query}")
Expand Down
9 changes: 9 additions & 0 deletions lollms/personality.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ def generate_code(
{template}
```
{"Make sure you fill all fields and to use the exact same keys as the template." if language in ["json","yaml","xml"] else ""}
The code tag is mandatory.
Don't forget encapsulate the code inside a markdown code tag. This is mandatory.
"""
elif code_tag_format=="html":
Expand All @@ -819,17 +820,25 @@ def generate_code(
{template}
</code>
{"Make sure you fill all fields and to use the exact same keys as the template." if language in ["json","yaml","xml"] else ""}
The code tag is mandatory.
Don't forget encapsulate the code inside a html code tag. This is mandatory.
"""

full_prompt += self.ai_custom_header("assistant")
if debug:
ASCIIColors.yellow("Prompt")
ASCIIColors.yellow(full_prompt)

if len(self.image_files)>0:
response = self.generate_with_images(full_prompt, self.image_files, max_size, temperature, top_k, top_p, repeat_penalty, repeat_last_n, callback, debug=debug)
elif len(images)>0:
response = self.generate_with_images(full_prompt, images, max_size, temperature, top_k, top_p, repeat_penalty, repeat_last_n, callback, debug=debug)
else:
response = self.generate(full_prompt, max_size, temperature, top_k, top_p, repeat_penalty, repeat_last_n, callback, debug=debug)
response_full += response
if debug:
ASCIIColors.green("Response")
ASCIIColors.green(response_full)
codes = self.extract_code_blocks(response)
if len(codes)==0 and accept_all_if_no_code_tags_is_present:
if return_full_generated_code:
Expand Down

0 comments on commit 310cc40

Please sign in to comment.