Compare commits

..

3 Commits

5 changed files with 59 additions and 17 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ wheels/
# Virtual environments
.venv
/workspace/tools/
.aider*

View File

@ -68,6 +68,7 @@ Key Python libraries used:
* `mlx` / `mlx-lm`: Likely used for efficient model inference, especially on Apple Silicon.
* `mcp`: For integrating external tools via the Multi-Agent Collaboration Protocol.
* `python-dotenv`: For managing environment variables (e.g., API keys).
* `rich`: For beautiful terminal formatting and progress indicators.
See `pyproject.toml` for the full list of dependencies.
@ -77,4 +78,4 @@ This an architectural spike, I welcome your feedback through `qwan.eu/contact`.
## License
Apache 2.0
Apache 2.0

View File

@ -1,11 +1,12 @@
import json # Import the json module
import json
from rich.console import Console
from rich.spinner import Spinner
from qwen_agent.agents import Assistant
# Define LLM
llm_cfg = {
'model': 'hf.co/unsloth/Qwen3-30B-A3B-GGUF:Q5_K_M',
# 'model': 'qwen3:32b',
'model': 'hf.co/unsloth/Qwen3-30B-A3B-GGUF:Q5_K_M',
# 'model': 'qwen3:32b',
# Use a custom endpoint compatible with OpenAI API:
'model_server': 'http://localhost:11434/v1', # api_base
@ -41,28 +42,30 @@ tools = [
# Define Agent
bot = Assistant(llm=llm_cfg, function_list=tools)
console = Console()
# Streaming generation
messages = [{'role': 'user',
'content':
""""- ***Research** What is enshittification, and who came up with it?
-- **Analyze** Developments around enshittification in the last five years, and related concepts.
-- **Answer** What is enshittification, and what does it mean for society?"""}]
""""
- ***Research** Parsing CLI commands and options in python code.
-- **Analyze** Clean separation of concerns between parsing commands and options and execution of the commands.
-- **Answer** What is the best way to parse CLI commands and options in python code?"""}]
final_responses = None
# Consider adding error handling around bot.run
try:
for responses in bot.run(messages=messages, enable_thinking=True, max_tokens=30000):
print(".", end="", flush=True)
final_responses = responses.pop()
with console.status("[bold blue]Thinking...", spinner="dots") as status:
for responses in bot.run(messages=messages, enable_thinking=True, max_tokens=30000):
final_responses = responses.pop()
except Exception as e:
print(f"An error occurred during agent execution: {e}")
console.print(f"[bold red]An error occurred during agent execution:[/] {e}")
# Pretty-print the final response object
if final_responses:
print("--- Full Response Object ---")
print(json.dumps(final_responses, indent=2)) # Use indent=2 (or 4) for pretty printing
print("\n--- Extracted Content ---")
print(final_responses.get('content', 'No content found in response.')) # Use .get for safer access
console.print("\n[bold green]--- Full Response Object ---[/]")
console.print(json.dumps(final_responses, indent=2))
console.print("\n[bold green]--- Extracted Content ---[/]")
console.print(final_responses.get('content', 'No content found in response.'))
else:
print("No final response received from the agent.")
console.print("[bold red]No final response received from the agent.[/]")

View File

@ -11,4 +11,5 @@ dependencies = [
"python-dateutil>=2.9.0.post0",
"python-dotenv>=1.1.0",
"qwen-agent[code-interpreter]>=0.0.20",
"rich>=13.7.0",
]

36
uv.lock generated
View File

@ -1016,6 +1016,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/4c/fa/be89a49c640930180657482a74970cdcf6f7072c8d2471e1babe17a222dc/kiwisolver-1.4.8-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:be4816dc51c8a471749d664161b434912eee82f2ea66bd7628bd14583a833e85", size = 2349213 },
]
[[package]]
name = "markdown-it-py"
version = "3.0.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "mdurl" },
]
sdist = { url = "https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb", size = 74596 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/42/d7/1ec15b46af6af88f19b8e5ffea08fa375d433c998b8a7639e76935c14f1f/markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", size = 87528 },
]
[[package]]
name = "markupsafe"
version = "3.0.2"
@ -1106,6 +1118,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/10/30/20a7f33b0b884a9d14dd3aa94ff1ac9da1479fe2ad66dd9e2736075d2506/mcp-1.6.0-py3-none-any.whl", hash = "sha256:7bd24c6ea042dbec44c754f100984d186620d8b841ec30f1b19eda9b93a634d0", size = 76077 },
]
[[package]]
name = "mdurl"
version = "0.1.2"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979 },
]
[[package]]
name = "mistune"
version = "3.1.3"
@ -1791,6 +1812,7 @@ dependencies = [
{ name = "python-dateutil" },
{ name = "python-dotenv" },
{ name = "qwen-agent", extra = ["code-interpreter"] },
{ name = "rich" },
]
[package.metadata]
@ -1801,6 +1823,7 @@ requires-dist = [
{ name = "python-dateutil", specifier = ">=2.9.0.post0" },
{ name = "python-dotenv", specifier = ">=1.1.0" },
{ name = "qwen-agent", extras = ["code-interpreter"], specifier = ">=0.0.20" },
{ name = "rich", specifier = ">=13.7.0" },
]
[[package]]
@ -1875,6 +1898,19 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/9e/51/17023c0f8f1869d8806b979a2bffa3f861f26a3f1a66b094288323fba52f/rfc3986_validator-0.1.1-py2.py3-none-any.whl", hash = "sha256:2f235c432ef459970b4306369336b9d5dbdda31b510ca1e327636e01f528bfa9", size = 4242 },
]
[[package]]
name = "rich"
version = "14.0.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "markdown-it-py" },
{ name = "pygments" },
]
sdist = { url = "https://files.pythonhosted.org/packages/a1/53/830aa4c3066a8ab0ae9a9955976fb770fe9c6102117c8ec4ab3ea62d89e8/rich-14.0.0.tar.gz", hash = "sha256:82f1bc23a6a21ebca4ae0c45af9bdbc492ed20231dcb63f297d6d1021a9d5725", size = 224078 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/0d/9b/63f4c7ebc259242c89b3acafdb37b41d1185c07ff0011164674e9076b491/rich-14.0.0-py3-none-any.whl", hash = "sha256:1c9491e1951aac09caffd42f448ee3d04e58923ffe14993f6e83068dc395d7e0", size = 243229 },
]
[[package]]
name = "rpds-py"
version = "0.24.0"