Design Guide to designate Understandable Comprehensive Change of Passals with Ai Agent Agent

In this lesson, we use a pipe in Age agent using ParslInclude its main functional skills to activate the many computational activities such as independent Python applications. We prepare the TexpooleCutor local Cronercut, Describe specialized tools such as Fibonacci Complication, keyword calculation, linking unparcons using the goal of using work. The results from all tasks are compiled and transferred by the Peak Text-Generation Face to produce a unified, personal summary. Look Full codes here.
!pip install -q parsl transformers accelerate
import math, json, time, random
from typing import List, Dict, Any
import parsl
from parsl.config import Config
from parsl.executors import ThreadPoolExecutor
from parsl import python_app
parsl.load(Config(executors=[ThreadPoolExecutor(label="local", max_threads=8)]))
We start by installing the required libraries and invites all the required modules to travel our work. We are preparing for parsl with a texpooleolecommutor for fleeing jobs and downloading this program so that we can activate our Python apps. Look Full codes here.
@python_app
def calc_fibonacci(n: int) -> Dict[str, Any]:
def fib(k):
a, b = 0, 1
for _ in range(k): a, b = b, a + b
return a
t0 = time.time(); val = fib(n); dt = time.time() - t0
return {"task": "fibonacci", "n": n, "value": val, "secs": round(dt, 4)}
@python_app
def extract_keywords(text: str, k: int = 8) -> Dict[str, Any]:
import re, collections
words = [w.lower() for w in re.findall(r"[a-zA-Z][a-zA-Z0-9-]+", text)]
stop = set("the a an and or to of is are was were be been in on for with as by from at this that it its if then else not no".split())
cand = [w for w in words if w not in stop and len(w) > 3]
freq = collections.Counter(cand)
scored = sorted(freq.items(), key=lambda x: (x[1], len(x[0])), reverse=True)[:k]
return {"task":"keywords","keywords":[w for w,_ in scored]}
@python_app
def simulate_tool(name: str, payload: Dict[str, Any]) -> Dict[str, Any]:
time.sleep(0.3 + random.random()*0.5)
return {"task": name, "payload": payload, "status": "ok", "timestamp": time.time()}
It describes four of the four jobs of parsl @python_app running asynchronous as part of the spill of our agent. We create a Prime-counting process, the extractor from the text-related kitchen, and a manufactured tool except APIs with random delay. These modular apps have let us make various skills alike, forming the building blocks of our Ai-Tool-tooler Ai. Look Full codes here.
def tiny_llm_summary(bullets: List[str]) -> str:
from transformers import pipeline
gen = pipeline("text-generation", model="sshleifer/tiny-gpt2")
prompt = "Summarize these agent results clearly:n- " + "n- ".join(bullets) + "nConclusion:"
out = gen(prompt, max_length=160, do_sample=False)[0]["generated_text"]
return out.split("Conclusion:", 1)[-1].strip()
We use little tiny_llm_summary function using Sugging and SletheightweightWeight / Tiny-GPT2 model to generate brief effects of our agent's consequences. Forma Collected Results results such as letters, dense “conclusion: see Full codes here.
def plan(user_goal: str) -> List[Dict[str, Any]]:
intents = []
if "fibonacci" in user_goal.lower():
intents.append({"tool":"calc_fibonacci", "args":{"n":35}})
if "primes" in user_goal.lower():
intents.append({"tool":"count_primes", "args":{"limit":100_000}})
intents += [
{"tool":"simulate_tool", "args":{"name":"vector_db_search","payload":{"q":user_goal}}},
{"tool":"simulate_tool", "args":{"name":"metrics_fetch","payload":{"kpi":"latency_ms"}}},
{"tool":"extract_keywords", "args":{"text":user_goal}}
]
return intents
We explain the program's function to map the user's goal in the formal list of the tool. Checking the “Fibonacci” Guide or “Primes”. Look Full codes here.
def run_agent(user_goal: str) -> Dict[str, Any]:
tasks = plan(user_goal)
futures = []
for t in tasks:
if t["tool"]=="calc_fibonacci": futures.append(calc_fibonacci(**t["args"]))
elif t["tool"]=="count_primes": futures.append(count_primes(**t["args"]))
elif t["tool"]=="extract_keywords": futures.append(extract_keywords(**t["args"]))
elif t["tool"]=="simulate_tool": futures.append(simulate_tool(**t["args"]))
raw = [f.result() for f in futures]
bullets = []
for r in raw:
if r["task"]=="fibonacci":
bullets.append(f"Fibonacci({r['n']}) = {r['value']} computed in {r['secs']}s.")
elif r["task"]=="count_primes":
bullets.append(f"{r['count']} primes found ≤ {r['limit']}.")
elif r["task"]=="keywords":
bullets.append("Top keywords: " + ", ".join(r["keywords"]))
else:
bullets.append(f"Tool {r['task']} responded with status={r['status']}.")
narrative = tiny_llm_summary(bullets)
return {"goal": user_goal, "bullets": bullets, "summary": narrative, "raw": raw}
In the work of the run_agent, we remove the full work flow by the work program from the user guide, and send each tool as a PARSL app to run the same. When all the future is finished, we change their results into clear points with letters and to feed our little_llm_Summary work to create a brief account. The work returns the first vaccine containing the original policy, details with the details of the letters, a LLM summary, and the results of green tools. Look Full codes here.
if __name__ == "__main__":
goal = ("Analyze fibonacci(35) performance, count primes under 100k, "
"and prepare a concise executive summary highlighting insights for planning.")
result = run_agent(goal)
print("n=== Agent Bullets ===")
for b in result["bullets"]: print("•", b)
print("n=== LLM Summary ===n", result["summary"])
print("n=== Raw JSON ===n", json.dumps(result["raw"], indent=2)[:800], "...")
In the Main Explousion Block, we define the mission of the sample that includes the compilation of numbers, the good count, and a summary generation. We run a agent for this purpose, print produced points view, show the phrases of the llm-crafted summary, and view the JSON's green outputs.
In conclusion, this implementation shows that the asynlrononous app model can properly affect the responsibilities of various functions alignment. By combining the luxurious phase, it changes the formal effects into natural language, indicating that the combination of AI can be integrated to create responsive, growing activities.
Look Full codes here. Feel free to look our GITHUB page for tutorials, codes and letters of writing. Also, feel free to follow it Sane and don't forget to join ours 100K + ml subreddit Then sign up for Our newspaper.
Asphazzaq is a Markteach Media Inc. According to a View Business and Developer, Asifi is committed to integrating a good social intelligence. His latest attempt is launched by the launch of the chemistrylife plan for an intelligence, MarktechPost, a devastating intimate practice of a machine learning and deep learning issues that are clearly and easily understood. The platform is adhering to more than two million moon visits, indicating its popularity between the audience.



