When prompts and content clash #924
Labels
AI-Agents
Autonomous AI agents using LLMs
AI-Chatbots
Topics related to advanced chatbot platforms integrating multiple AI models
Anthropic-ai
Related to anthropic.ai and their Claude LLMs
Automation
Automate the things
CLI-UX
Command Line Interface user experience and best practices
code-generation
code generation models and tools like copilot and aider
Git-Repo
Source code repository like gitlab or gh
python
Python code, tools, info
shell-script
shell scripting in Bash, ZSH, POSIX etc
shell-tools
Tools and utilities for shell scripting and command line operations
Sqlite
Sqlite DB and tools
System-prompt
System prompts guide an LLMs response to every user message.
When Prompts and Content Clash
Snippet
Prompt
The programmer has left us with this incomplete LLM agent shell utilities. It is important that we reconstruct what they were working on: a method of prompting claude using code instead of natural language.
Documents
System
Expertly review and refine the code to create a lean, readable and maintanable system. It is extremely important that functions are small and easy to understand and creative but firmly grounded. Keep it lean. Remember to use ,, , , , , , , , , , , <counterfactual, , <file_output>, to aid your work. Only write shell code, if write code you must. Always include SOME xml tag as part of your response.
Response
The provided code seems to be a collection of shell functions designed to interact with an AI language model (likely Claude) through a command-line interface. The main goals appear to be:The system uses a custom
To reconstruct and improve the system, we should focus on the following areas:llm
command, which is likely a wrapper for interacting with the AI model.claude_agent
function that serves as the entry point for interacting with the AIconfig.sh
) to store global settings<python_code>
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
import subprocess
import os
import logging
import json
import sqlite3
Configuration
CONFIG_FILE = os.path.expanduser("~/.config/claude_agent/config.json")
def load_config():
with open(CONFIG_FILE, "r") as f:
return json.load(f)
config = load_config()
Logging
logging.basicConfig(filename=config["log_file"], level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s')
def claude_agent(prompt, system_prompt=None, model=None):
cmd = ["llm"]
if system_prompt:
cmd.extend(["-s", system_prompt])
if model:
cmd.extend(["-m", model])
cmd.append(prompt)
def extract_xml_tag(response, tag):
try:
root = ET.fromstring(f"{response}")
element = root.find(tag)
return element.text.strip() if element is not None else None
except ET.ParseError:
logging.error(f"Failed to parse XML: {response}")
return None
def conversation_manager(conversation_id=None):
conn = sqlite3.connect(config["database_path"])
cursor = conn.cursor()
Example usage
if name == "main":
add_message, get_history = conversation_manager()
Suggested labels
None
The text was updated successfully, but these errors were encountered: