Skip to content

Commit 972a4de

Browse files
committed
First agent template
1 parent aa824d1 commit 972a4de

File tree

6 files changed

+87
-5
lines changed

6 files changed

+87
-5
lines changed

llmstack/apps/schemas.py

+4
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@ class Processor(BaseModel):
5050
"""
5151
id: str = Field(
5252
None, description='Unique identifier for the processor in the app run graph')
53+
name: str = Field(None, description='Name of the processor')
54+
description: str = Field(None, description='Description of the processor')
5355
provider_slug: str = Field(
5456
None, description='Slug of the processor provider')
5557
processor_slug: str = Field(None, description='Slug of the processor')
5658
# TODO: Validate input and config against backing processor's schemas
5759
input: dict = Field(None, description='Input for the processor')
5860
config: dict = Field(None, description='Configuration for the processor')
61+
output_template: dict = Field(
62+
None, description='Output template for the processor')
5963

6064

6165
class App(BaseModel):

llmstack/client/src/components/apps/AppTemplate.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ function SavedAppActions(props) {
129129
<Button
130130
sx={{ textTransform: "none" }}
131131
onClick={() => navigate(`/apps/${app.uuid}/integrations/twilio`)}
132-
>
132+
>
133133
Twilio
134-
</Button>
134+
</Button>
135135
</ButtonGroup>
136136
</Stack>
137137
</Box>
@@ -195,6 +195,7 @@ export function AppTemplate(props) {
195195
key={index}
196196
appData={app?.data}
197197
setAppData={(appData) => {
198+
console.log({ data: { ...app?.data, ...appData } });
198199
setApp({ data: { ...app?.data, ...appData } });
199200
}}
200201
page={index === activeStep ? page : null}

llmstack/client/src/components/apps/AppTemplatesList.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function AppTemplatesList() {
2323

2424
setAppName(template.name);
2525

26-
if (template.app) {
26+
if (template.app && template.app.processors) {
2727
setAppTemplate(template);
2828
} else {
2929
axios()

llmstack/client/src/pages/AppEdit.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ export default function AppEditPage(props) {
274274
id: `_inputs${index + 1}`,
275275
name: processor.name || processor.api_backend?.name,
276276
description:
277-
processor.description || processor.api_backend?.description,
277+
app?.data?.processors[index]?.description ||
278+
processor.description ||
279+
processor.api_backend?.description,
278280
provider_slug:
279281
processor.api_backend?.api_provider?.slug ||
280282
processor.provider_slug,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "Chatbot with Internet"
2+
slug: "chatbot-with-internet"
3+
category_slugs: ["chatbot"]
4+
description: "A chatbot that can answer user's questions based on your own content. Searches internet if it cannot find answer in your data."
5+
provider_slug: "promptly"
6+
pages:
7+
- title: "Data"
8+
description: "Provide data for your Chatbot"
9+
input_fields:
10+
- name: "datasource"
11+
title: "Datasource"
12+
type: "datasource"
13+
description: "Select the data for the chatbot to answer from. Click on the icon to the right to add new data"
14+
path: "processors[0].config.datasource"
15+
- name: "description"
16+
title: "Datasource Description"
17+
type: "textarea"
18+
description: "Describe the datasource"
19+
path: "processors[0].description"
20+
default: "Responds to questions about Promptly"
21+
app:
22+
name: "Chatbot with Internet"
23+
slug: "chatbot-with-internet"
24+
description: "A chatbot that can answer user's questions based on your own content. Searches internet if it cannot find answer in your data"
25+
type_slug: "agent"
26+
input_fields:
27+
- name: "task"
28+
title: "Question"
29+
type: "string"
30+
description: "Enter your question here"
31+
output_template:
32+
markdown: |
33+
{{agent}}
34+
processors:
35+
- id: "_inputs1"
36+
name: "Datasource"
37+
description: "Datasource to search for answers"
38+
provider_slug: "promptly"
39+
processor_slug: "text_chat"
40+
input: { "question": "" }
41+
config:
42+
{
43+
"k": 8,
44+
"model": "gpt-3.5-turbo",
45+
"datasource": [],
46+
"temperature": 0.7,
47+
"instructions": "You are a chatbot that uses the provided context to answer the user's question.\nIf you cannot answer the question based on the provided context, say you don't know the answer.\nNo answer should go out of the provided input. If the provided input is empty, return saying you don't know the answer.\nKeep the answers terse.",
48+
"chat_history_limit": 20,
49+
"system_message_prefix": "You are a helpful chat assistant",
50+
"use_azure_if_available": true,
51+
"chat_history_in_doc_search": 0,
52+
}
53+
output_template:
54+
markdown: |
55+
{{_inputs1.answer}}
56+
- id: _inputs2
57+
name: Web Search
58+
description: Search the web for answers
59+
provider_slug: promptly
60+
processor_slug: web_search
61+
config:
62+
search_engine: Google
63+
k: 5
64+
input:
65+
query: ""
66+
output_template:
67+
markdown: |
68+
{% for result in _inputs2.results %}
69+
70+
Result: {{ result.text }}
71+
72+
URL: {{ result.source }}
73+
74+
{% endfor %}

llmstack/processors/providers/promptly/text_chat.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def process(self) -> dict:
288288
output = output_stream.finalize()
289289

290290
self._chat_history.append(
291-
{'role': 'assistant', 'content': output.answer},
291+
{'role': 'assistant', 'content': output['answer'] if type(
292+
output) is dict else output.answer},
292293
)
293294

294295
return output

0 commit comments

Comments
 (0)