Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- src/agent.py +3 -3
- src/main.py +3 -3
src/agent.py
CHANGED
@@ -10,7 +10,7 @@ from src.prompts import Prompts # Import system prompts
|
|
10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
11 |
|
12 |
class Agent:
|
13 |
-
def __init__(self, llm: Llama, db_path: str, system_prompt: str = "", max_tokens: int =
|
14 |
self.llm = llm
|
15 |
self.memory = MemoryManager(db_path)
|
16 |
self.prompts = {
|
@@ -122,7 +122,7 @@ class Agent:
|
|
122 |
full_context = " ".join([memory['description'] for memory, _, _ in all_memories])
|
123 |
|
124 |
# Truncate the context if it exceeds the token limit
|
125 |
-
max_context_length =
|
126 |
if len(full_context) > max_context_length:
|
127 |
full_context = full_context[:max_context_length]
|
128 |
logging.info(f"Truncated full context to {max_context_length} characters.")
|
@@ -147,7 +147,7 @@ class Agent:
|
|
147 |
combined_context = f"Initial Response: {initial_response}\nHigh-Level Summary: {high_level_summary}"
|
148 |
|
149 |
# Truncate the combined context to fit within the model's context window
|
150 |
-
max_context_length =
|
151 |
if len(combined_context) > max_context_length:
|
152 |
combined_context = combined_context[:max_context_length]
|
153 |
logging.info(f"Truncated combined context to {max_context_length} characters.")
|
|
|
10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
11 |
|
12 |
class Agent:
|
13 |
+
def __init__(self, llm: Llama, db_path: str, system_prompt: str = "", max_tokens: int = 500, temperature: float = 0.7, top_p: float = 0.95):
|
14 |
self.llm = llm
|
15 |
self.memory = MemoryManager(db_path)
|
16 |
self.prompts = {
|
|
|
122 |
full_context = " ".join([memory['description'] for memory, _, _ in all_memories])
|
123 |
|
124 |
# Truncate the context if it exceeds the token limit
|
125 |
+
max_context_length = 500 # Adjust this based on your LLM's token limit
|
126 |
if len(full_context) > max_context_length:
|
127 |
full_context = full_context[:max_context_length]
|
128 |
logging.info(f"Truncated full context to {max_context_length} characters.")
|
|
|
147 |
combined_context = f"Initial Response: {initial_response}\nHigh-Level Summary: {high_level_summary}"
|
148 |
|
149 |
# Truncate the combined context to fit within the model's context window
|
150 |
+
max_context_length = 500 # Adjust this based on your LLM's token limit
|
151 |
if len(combined_context) > max_context_length:
|
152 |
combined_context = combined_context[:max_context_length]
|
153 |
logging.info(f"Truncated combined context to {max_context_length} characters.")
|
src/main.py
CHANGED
@@ -34,13 +34,13 @@ def download_model(repo_id, filename, save_path):
|
|
34 |
|
35 |
# Download the model if it doesn't exist
|
36 |
if not os.path.exists(model_path):
|
37 |
-
download_model("
|
38 |
|
39 |
def main():
|
40 |
model_path = "models/unsloth.Q4_K_M.gguf" # Path to the downloaded model
|
41 |
db_path = "agent.db"
|
42 |
system_prompt = "Vous êtes l'assistant intelligent de Les Chronique MTC. Votre rôle est d'aider les visiteurs en expliquant le contenu des Chroniques, Flash Infos et Chronique-FAQ de Michel Thomas. Utilisez le contexte fourni pour améliorer vos réponses et veillez à ce qu'elles soient précises et pertinentes."
|
43 |
-
max_tokens =
|
44 |
temperature = 0.7
|
45 |
top_p = 0.95
|
46 |
|
@@ -53,7 +53,7 @@ def main():
|
|
53 |
# Load the model
|
54 |
llm = Llama(
|
55 |
model_path=model_path,
|
56 |
-
n_ctx=
|
57 |
max_tokens=max_tokens # Control the maximum number of tokens generated in the response
|
58 |
)
|
59 |
|
|
|
34 |
|
35 |
# Download the model if it doesn't exist
|
36 |
if not os.path.exists(model_path):
|
37 |
+
download_model("adeptusnull/llama3.2-1b-wizardml-vicuna-uncensored-finetune-test", filename, model_path)
|
38 |
|
39 |
def main():
|
40 |
model_path = "models/unsloth.Q4_K_M.gguf" # Path to the downloaded model
|
41 |
db_path = "agent.db"
|
42 |
system_prompt = "Vous êtes l'assistant intelligent de Les Chronique MTC. Votre rôle est d'aider les visiteurs en expliquant le contenu des Chroniques, Flash Infos et Chronique-FAQ de Michel Thomas. Utilisez le contexte fourni pour améliorer vos réponses et veillez à ce qu'elles soient précises et pertinentes."
|
43 |
+
max_tokens = 500
|
44 |
temperature = 0.7
|
45 |
top_p = 0.95
|
46 |
|
|
|
53 |
# Load the model
|
54 |
llm = Llama(
|
55 |
model_path=model_path,
|
56 |
+
n_ctx=572, # Set the maximum context length
|
57 |
max_tokens=max_tokens # Control the maximum number of tokens generated in the response
|
58 |
)
|
59 |
|