Skip to content

Commit d23e4f9

Browse files
committed
Create LLM Agents with task processor
1 parent 33de9aa commit d23e4f9

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

bindings/ceylon/examples/llm/app.py bindings/ceylon/examples/llm/process_llm_app.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from ceylon.llm.agent import LLMConfig, LLMAgent
44
from ceylon.llm.models.ollama import OllamaModel
5-
from ceylon.processor.agent import ProcessWorker, ProcessRequest, ProcessResponse
5+
from ceylon.processor.agent import ProcessRequest, ProcessResponse
66
from ceylon.processor.playground import ProcessPlayGround
77

88

@@ -46,3 +46,4 @@ async def main():
4646

4747
if __name__ == "__main__":
4848
asyncio.run(main())
49+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import asyncio
2+
3+
from ceylon.llm.agent import LLMConfig, LLMAgent
4+
from ceylon.llm.models.ollama import OllamaModel
5+
from ceylon.processor.agent import ProcessRequest, ProcessResponse
6+
from ceylon.processor.playground import ProcessPlayGround
7+
from ceylon.task.data import Task, TaskResult
8+
from ceylon.task.playground import TaskProcessingPlayground
9+
10+
11+
async def main():
12+
# Create playground and worker
13+
playground = TaskProcessingPlayground()
14+
llm_model = OllamaModel(
15+
model_name="deepseek-r1:8b",
16+
base_url="http://localhost:11434"
17+
)
18+
19+
# Configure LLM agent
20+
llm_config = LLMConfig(
21+
system_prompt=(
22+
"You are an expert content writer specializing in technology topics. "
23+
),
24+
temperature=0.7,
25+
max_tokens=1000,
26+
retry_attempts=1
27+
)
28+
29+
# Create LLM agent
30+
llm_agent = LLMAgent(
31+
name="writer_1",
32+
llm_model=llm_model,
33+
config=llm_config,
34+
role="writer"
35+
)
36+
37+
# Start the system
38+
async with playground.play(workers=[llm_agent]) as active_playground:
39+
active_playground: TaskProcessingPlayground = active_playground
40+
# Send some test requests
41+
response: TaskResult = await active_playground.add_and_execute_task(
42+
Task(
43+
name="Process Data 1",
44+
processor="writer",
45+
input_data={"request": "A Simple title for a blog post about AI"}
46+
)
47+
)
48+
print(f"Response received: {response.output}")
49+
50+
51+
if __name__ == "__main__":
52+
asyncio.run(main())

0 commit comments

Comments
 (0)