Full memory storing and retrieval for conversation agent. Update gral prompts. Add custom inference model.

This commit is contained in:
Shivering Ocelot committed 2025-06-28 00:59:56 -05:00
1 parent 3c3febb92d
commit e9ebb1378a
5 files changed
+196 -50

No files matched your search

+10 -9
View File
@@ -1,14 +1,15 @@
from inference import LlamaMessage, replicate_llama_completion
from inference import LlamaMessage, replicate_llama_completion, Models
import re
message_format_section = """
When suggesting code to the user, keep the code as small snippets.
If the update is meant to be applied to a file, include a line linking the file immediately before the code block like this: "[filename.txt]
You have the capability to update files in your current environment with file tags before your code suggestions.
If the update is meant to be applied on a file, include a file tag line immediately before the code block like this: "[filename.txt]
```
updated segment
```"
Omit the file link when the block is not related to a known file
Code blocks must be under 30 lines. Assistant responses MUST NOT contain horizontal rules.
Omit the file link when the block is not related to a known file,
Code blocks must be under 30 lines. Your responses MUST NOT contain horizontal rules.
When suggesting bash code meant to be directly executed, use the same syntax as above but marking the code block with "[eval]" instead.
"""
@@ -27,9 +28,9 @@ async def gral_message(app, system_prompt, message_history: list, file_map: dict
if file_parts:
file_lines = [
"This message contains all files relevant to the prompt: each file section in this message starts with a horizontal rule, followed by the file name in square brackets, followed by the file content.",
"Only this message contains horizontal rules, assistant responses must not include them.",
"The prompt and conversation start in the next message after this."
"This message contains all files relevant to the prompt: each file in this message is separated with horizontal rules \"---\", followed by the file name in square brackets, followed by the file content.",
"Only this message contains horizontal rules, your responses never has them.",
"Conversation start in the message following this one."
]
file_lines.extend(file_parts)
messages.append(
@@ -38,7 +39,7 @@ async def gral_message(app, system_prompt, message_history: list, file_map: dict
messages.extend([LlamaMessage(msg['role'], msg['content']) for msg in message_history])
response = await replicate_llama_completion(app, messages)
response = await replicate_llama_completion(app, messages, Models.llama_70b)
return response
async def gral_update_file(app, system_prompt, message_history: list, filepath: str, file_content: str):
@@ -57,7 +58,7 @@ async def gral_update_file(app, system_prompt, message_history: list, filepath:
# Main Instruction Message
message_lines = [
f"Write the updated contents of the file: {filepath}, as concluded in the conversation above.",
f"The raw file contents of the file {filepath} are included following the horizontal rule below."
f"The current content of the file {filepath} is pasted after the horizontal rule below."
"\n---\n",
file_content,
]