Skip to content

Commit c79f4af

Browse files
authored
Fix app templates (#29)
1 parent e84ea9e commit c79f4af

8 files changed

+23
-12
lines changed

apps/serializers.py

+11
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ class Meta:
250250
class AppTemplateSerializer(serializers.ModelSerializer):
251251
class AppTemplateAppSerializer(serializers.ModelSerializer):
252252
processors = serializers.SerializerMethodField()
253+
input_fields = serializers.SerializerMethodField()
253254

254255
def get_processors(self, obj):
255256
processors = []
@@ -267,6 +268,8 @@ def get_processors(self, obj):
267268
'input': node.input,
268269
'config': node.config,
269270
'api_backend': ApiBackendSerializer(instance=node.api_backend).data,
271+
'processor_slug': node.api_backend.slug,
272+
'provider_slug': node.api_backend.api_provider.slug,
270273
'endpoint': str(node.uuid),
271274
})
272275
node_to_find = node
@@ -280,11 +283,19 @@ def get_processors(self, obj):
280283
node = edge.exit_endpoint if edge else None
281284
return processors
282285

286+
def get_input_fields(self, obj):
287+
app_data = AppData.objects.filter(
288+
app_uuid=obj.uuid).order_by('-created_at').first()
289+
if app_data:
290+
return app_data.data.get('input_fields', [])
291+
return []
292+
283293
class Meta:
284294
model = App
285295
fields = [
286296
'config', 'input_schema', 'type',
287297
'input_ui_schema', 'output_template', 'processors',
298+
'input_fields'
288299
]
289300

290301
app = serializers.SerializerMethodField()

apps/templates/ai_writing_assistant.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ class VocabularyEnum(str, Enum):
3535

3636
class AIWritingAssistantSetting(BaseSchema):
3737
formality: FomalityEnum = Field(
38-
description='Formality of the text', path='input_schema.properties.formality.default',
38+
description='Formality of the text', path='input_fields[1].default',
3939
)
4040

4141
tone: ToneEnum = Field(
4242
description='Tone of the text',
43-
path='input_schema.properties.tone.default',
43+
path='input_fields[2].default',
4444
)
4545

4646
vocabulary: VocabularyEnum = Field(
4747
description='Vocabulary of the text',
48-
path='input_schema.properties.vocabulary.default',
48+
path='input_fields[3].default',
4949
)
5050

5151
profession: str = Field(
5252
description='Profession of the writer',
53-
path='input_schema.properties.profession.default',
53+
path='input_fields[4].default',
5454
)
5555

5656

apps/templates/character_chatbot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CharacterChatbotBasicSchema(BaseSchema):
1919
description='Avatar to use for your character', path='config.assistant_image',
2020
)
2121
question_description: str = Field(
22-
title='Question help text', path='input_schema.properties.question.description', description='Help text to show below the question input box',
22+
title='Question help text', path='input_fields[0].description', description='Help text to show below the question input box',
2323
)
2424
character_behavior_message: str = Field(
2525
title='Character definition', widget='textarea', path='processors[0].input.system_message',

apps/templates/file_chatbot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class FileChatbotBasicSchema(BaseSchema):
1919
description='Avatar to use for your chatbot', path='config.assistant_image',
2020
)
2121
question_description: str = Field(
22-
title='Question help text', path='input_schema.properties.question.description', description='Help text to show below the question input box',
22+
title='Question help text', path='input_fields[1].description', description='Help text to show below the question input box',
2323
)
2424

2525

apps/templates/language_translator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
class LanguageTranslatorSchema(BaseSchema):
99
input_language: str = Field(
10-
title='Input language', description='Default value for the user input language', path='input_schema.properties.input_language.default',
10+
title='Input language', description='Default value for the user input language', path='input_fields[1].default',
1111
)
1212
output_language: str = Field(
13-
title='Output language', description='Default value for expected output language', path='input_schema.properties.output_language.default',
13+
title='Output language', description='Default value for expected output language', path='input_fields[2].default',
1414
)
1515

1616

contrib/apps/templates/character_chatbot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pages:
2626
title: "Question help text"
2727
type: "string"
2828
description: "Help text to show below the question input box"
29-
path: "input_schema.properties.question.description"
29+
path: "input_fields[0].description"
3030
- name: "character_behavior_message"
3131
title: "Character definition"
3232
type: "text"

contrib/apps/templates/file_chatbot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pages:
2727
title: "Question help text"
2828
type: "string"
2929
description: "Help text to show below the question input box"
30-
path: "input_schema.properties.question.description"
30+
path: "input_fields[1].description"
3131
app:
3232
name: "File Chatbot"
3333
slug: "file-chatbot"

contrib/apps/templates/language_translator.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ pages:
1111
title: "Input language"
1212
type: "string"
1313
description: "Default value for the user input language"
14-
path: "input_schema.properties.input_language.default"
14+
path: "input_fields[1].default"
1515
- name: "output_language"
1616
title: "Output language"
1717
type: "string"
1818
description: "Default value for expected output language"
19-
path: "input_schema.properties.output_language.default"
19+
path: "input_fields[2].default"
2020
app:
2121
name: "Language Translator"
2222
slug: "language-translator"

0 commit comments

Comments
 (0)