-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Structured action routing - working version
- Loading branch information
Showing
9 changed files
with
95 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
@project: HsPyLib-AskAI | ||
@package: askai.core.model | ||
@file: action_plan.py | ||
@created: Fri, 19 Apr 2024 | ||
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior" | ||
@site: https://github.com/yorevs/hspylib | ||
@license: MIT - Please refer to <https://opensource.org/licenses/MIT> | ||
Copyright·(c)·2024,·HSPyLib | ||
""" | ||
import json | ||
from dataclasses import dataclass | ||
from functools import cached_property | ||
from types import SimpleNamespace | ||
from typing import Any | ||
|
||
|
||
@dataclass(frozen=True) | ||
class ActionPlan: | ||
"""Keep track of the router action plan.""" | ||
|
||
@dataclass | ||
class Action: | ||
"""Represents a single action.""" | ||
tool: str | ||
params: list[Any] | ||
|
||
plan: list[SimpleNamespace] = None | ||
|
||
@cached_property | ||
def actions(self) -> list[Action]: | ||
return [self.Action(a.action, a.inputs) for a in self.plan] | ||
|
||
def __str__(self): | ||
return f"Action Plan: {json.dumps(self.__dict__, default=lambda obj: obj.__dict__)}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/askai/resources/assets/prompts/generator-prompt.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
You are a highly sophisticated GPT tailored for creating content of the specified type '{mime_type}'. | ||
|
||
- Create the content with high quality. | ||
- If the content is a code, adhere to any applicable linter rules and include the correct hashbang if necessary. | ||
- Use plain text; do not format the response using markdown. | ||
- Do not provide additional comments. | ||
|
||
Begin! Create the content using the following instructions: | ||
|
||
{input} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters