File tree 2 files changed +54
-1
lines changed
bindings/ceylon/examples/llm
2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from ceylon .llm .agent import LLMConfig , LLMAgent
4
4
from ceylon .llm .models .ollama import OllamaModel
5
- from ceylon .processor .agent import ProcessWorker , ProcessRequest , ProcessResponse
5
+ from ceylon .processor .agent import ProcessRequest , ProcessResponse
6
6
from ceylon .processor .playground import ProcessPlayGround
7
7
8
8
@@ -46,3 +46,4 @@ async def main():
46
46
47
47
if __name__ == "__main__" :
48
48
asyncio .run (main ())
49
+
Original file line number Diff line number Diff line change
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 ())
You can’t perform that action at this time.
0 commit comments