Skip to content

Commit c1af353

Browse files
committed
Fix cldk assistant
1 parent 5d68a25 commit c1af353

File tree

1 file changed

+122
-120
lines changed

1 file changed

+122
-120
lines changed

examples/cldk/cldk-assistant.pdl

Lines changed: 122 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -27,137 +27,139 @@ text:
2727
result = cldk_state
2828
- " done!"
2929
- repeat:
30-
- read:
31-
def: query
32-
message: "\n\nHow can I help you [Type 'quit' to quit]?\n"
33-
contribute: []
34-
- "\n***Generating PDL code for your query:\n"
35-
- if: ${ query != 'quit'}
36-
then:
37-
- model: watsonx/ibm/granite-20b-code-instruct
38-
def: PDL
39-
input:
40-
- |
41-
Question: What are all the classes?
42-
Answer:
43-
```
44-
text:
45-
- lang: python
46-
code:
30+
text:
31+
- read:
32+
def: query
33+
message: "\n\nHow can I help you [Type 'quit' to quit]?\n"
34+
contribute: []
35+
- "\n***Generating PDL code for your query:\n"
36+
- if: ${ query != 'quit'}
37+
then:
38+
text:
39+
- model: watsonx/ibm/granite-20b-code-instruct
40+
def: PDL
41+
input:
4742
- |
48-
classes = PDL_SESSION.cldk_state.get_classes().keys()
49-
result = ", ".join(classes)
50-
```
43+
Question: What are all the classes?
44+
Answer:
45+
```
46+
text:
47+
- lang: python
48+
code:
49+
- |
50+
classes = PDL_SESSION.cldk_state.get_classes().keys()
51+
result = ", ".join(classes)
52+
```
5153

52-
Question: What are all the constructors of class org.ibm.App?
53-
Answer:
54-
```
55-
text:
56-
- lang: python
57-
code:
58-
- |
59-
constructors = PDL_SESSION.cldk_state.get_constructors("org.ibm.App")
60-
result = ", ".join(constructors)
61-
```
54+
Question: What are all the constructors of class org.ibm.App?
55+
Answer:
56+
```
57+
text:
58+
- lang: python
59+
code:
60+
- |
61+
constructors = PDL_SESSION.cldk_state.get_constructors("org.ibm.App")
62+
result = ", ".join(constructors)
63+
```
6264

63-
Question: What are all the fields of class org.ibm.App?
64-
Answer:
65-
```
66-
text:
67-
- lang: python
68-
code:
69-
- |
70-
fields = PDL_SESSION.cldk_state.get_fields("org.ibm.App")
71-
names = sum([f.variables for f in fields], [])
72-
result = ", ".join(names)
73-
```
65+
Question: What are all the fields of class org.ibm.App?
66+
Answer:
67+
```
68+
text:
69+
- lang: python
70+
code:
71+
- |
72+
fields = PDL_SESSION.cldk_state.get_fields("org.ibm.App")
73+
names = sum([f.variables for f in fields], [])
74+
result = ", ".join(names)
75+
```
7476

75-
Question: What are all the methods of class org.ibm.App?
76-
Answer:
77-
```
78-
text:
79-
- lang: python
80-
code:
81-
- |
82-
methods = PDL_SESSION.cldk_state.get_methods_in_class("org.ibm.App")
83-
result = ", ".join(methods)
84-
```
77+
Question: What are all the methods of class org.ibm.App?
78+
Answer:
79+
```
80+
text:
81+
- lang: python
82+
code:
83+
- |
84+
methods = PDL_SESSION.cldk_state.get_methods_in_class("org.ibm.App")
85+
result = ", ".join(methods)
86+
```
8587

86-
Question: Show me the call graph of class "org.ibm.App"
87-
Answer:
88-
```
89-
text:
90-
- lang: python
91-
code:
92-
- |
93-
graph = PDL_SESSION.cldk_state.get_class_call_graph("org.ibm.App", method_name=None)
94-
result = graph
95-
```
88+
Question: Show me the call graph of class "org.ibm.App"
89+
Answer:
90+
```
91+
text:
92+
- lang: python
93+
code:
94+
- |
95+
graph = PDL_SESSION.cldk_state.get_class_call_graph("org.ibm.App", method_name=None)
96+
result = graph
97+
```
9698

97-
Question: What is the code of method Foo(string) of class org.ibm.App?
98-
Answer:
99-
```
100-
text:
101-
- lang: python
102-
code:
103-
- |
104-
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
105-
result = method.code
106-
```
99+
Question: What is the code of method Foo(string) of class org.ibm.App?
100+
Answer:
101+
```
102+
text:
103+
- lang: python
104+
code:
105+
- |
106+
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
107+
result = method.code
108+
```
107109

108-
Question: Generate a summary for method Foo(string) of class org.ibm.App
109-
Answer:
110-
```
111-
text:
112-
- lang: python
113-
code:
114-
- |
115-
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
116-
result = method
117-
- "\n\nGenerate a summary of method Foo\n\n"
118-
- model: watsonx/meta-llama/llama-3-1-70b-instruct
119-
```
110+
Question: Generate a summary for method Foo(string) of class org.ibm.App
111+
Answer:
112+
```
113+
text:
114+
- lang: python
115+
code:
116+
- |
117+
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
118+
result = method
119+
- "\n\nGenerate a summary of method Foo\n\n"
120+
- model: watsonx/meta-llama/llama-3-1-70b-instruct
121+
```
120122

121-
Question: Generate a different comment for method Foo(string) in class org.ibm.App?
122-
Answer:
123-
```
124-
text:
125-
- lang: python
126-
code:
127-
- |
128-
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
129-
result = method
130-
- "\n\nGenerate a different comment for method Foo(string)\n\n"
131-
- model: watsonx/meta-llama/llama-3-1-70b-instruct
132-
```
123+
Question: Generate a different comment for method Foo(string) in class org.ibm.App?
124+
Answer:
125+
```
126+
text:
127+
- lang: python
128+
code:
129+
- |
130+
method = PDL_SESSION.cldk_state.get_method("org.ibm.App", "Foo(string)")
131+
result = method
132+
- "\n\nGenerate a different comment for method Foo(string)\n\n"
133+
- model: watsonx/meta-llama/llama-3-1-70b-instruct
134+
```
133135

134-
If the query contains something about a field be sure to call a model.
135-
136-
Question: ${ query }
136+
If the query contains something about a field be sure to call a model.
137+
138+
Question: ${ query }
137139

138140

139-
parameters:
140-
stop_sequence: ["Question"]
141-
include_stop_sequence: false
142-
- "\n\n***Executing the above PDL code:\n\n"
143-
- lang: python
144-
contribute: []
145-
code: |
146-
from pdl import pdl_ast, pdl_interpreter
147-
from pdl.pdl_ast import Program
148-
from pdl.pdl_interpreter import process_prog
149-
from pdl.pdl_interpreter import InterpreterState
150-
from pdl.pdl_interpreter import empty_scope
151-
import re
152-
import yaml
153-
s = """'${ PDL }'"""
154-
print(s)
155-
pdl = s.split("```")[1]
156-
obj = yaml.safe_load(pdl)
157-
state = InterpreterState()
158-
data = Program.model_validate(obj)
159-
160-
result, _, _, _ = process_prog(state, empty_scope, data)
141+
parameters:
142+
stop_sequence: ["Question"]
143+
include_stop_sequence: false
144+
- "\n\n***Executing the above PDL code:\n\n"
145+
- lang: python
146+
contribute: []
147+
code: |
148+
from pdl import pdl_ast, pdl_interpreter
149+
from pdl.pdl_ast import Program
150+
from pdl.pdl_interpreter import process_prog
151+
from pdl.pdl_interpreter import InterpreterState
152+
from pdl.pdl_interpreter import empty_scope
153+
import re
154+
import yaml
155+
s = """'${ PDL }'"""
156+
print(s)
157+
pdl = s.split("```")[1]
158+
obj = yaml.safe_load(pdl)
159+
state = InterpreterState()
160+
data = Program.model_validate(obj)
161+
162+
result, _, _, _ = process_prog(state, empty_scope, data)
161163
until: ${ query == 'quit' }
162164

163165

0 commit comments

Comments
 (0)