Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/dialog_transformer #2

Merged
merged 3 commits into from
Oct 7, 2023
Merged

feat/dialog_transformer #2

merged 3 commits into from
Oct 7, 2023

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 6, 2023

companion to OpenVoiceOS/ovos-audio#27

example prompts

@rewrite("Rewrite this as if written by H.P.Lovecraft")
def lovecraftify(text: str):
    return text

@rewrite(f'Add more "dude"ness to')
def dudeify(text: str):
    return text

@rewrite(f'Rewrite this as if being explained to a 5 year old')
def eli5(text: str):
    return text

utt = "Quantum mechanics is a branch of physics that describes the behavior of particles at the smallest scales. " \
    "It involves principles such as superposition, where particles can exist in multiple states simultaneously, " \
    "and entanglement, where particles become connected and can influence each other's properties."
print(lovecraftify(utt))
# Quantum mechanics unveils the eldritch secrets of the infinitesimal realm,
# where particles, ensnared in the web of superposition, dwell in manifold states.
# Through the dread phenomenon of entanglement, these entities intertwine,
# their very essence entwined, shaping the fabric of reality.
print(dudeify(utt))
# Quantum mechanics is like, the raddest branch of physics, dude.
# It's all about particles at the tiniest scales, doing crazy stuff like
# being in multiple states at once (superposition) and getting all connected and influencing each other (entanglement).
print(eli5(utt))
# Quantum mechanics is like a special kind of science that helps us understand really tiny things.
# It tells us that these tiny things can be in more than one place at the same time,
# and they can also be connected to each other and affect each other's behavior.

example prompts

```
@rewrite("Rewrite this as if written by H.P.Lovecraft")
def lovecraftify(text: str):
    return text

@rewrite(f'Add more "dude"ness to')
def dudeify(text: str):
    return text

@rewrite(f'Rewrite this as if being explained to a 5 year old')
def eli5(text: str):
    return text

utt = "Quantum mechanics is a branch of physics that describes the behavior of particles at the smallest scales. " \
    "It involves principles such as superposition, where particles can exist in multiple states simultaneously, " \
    "and entanglement, where particles become connected and can influence each other's properties."
print(lovecraftify(utt))
# Quantum mechanics unveils the eldritch secrets of the infinitesimal realm,
# where particles, ensnared in the web of superposition, dwell in manifold states.
# Through the dread phenomenon of entanglement, these entities intertwine,
# their very essence entwined, shaping the fabric of reality.
print(dudeify(utt))
# Quantum mechanics is like, the raddest branch of physics, dude.
# It's all about particles at the tiniest scales, doing crazy stuff like
# being in multiple states at once (superposition) and getting all connected and influencing each other (entanglement).
print(eli5(utt))
# Quantum mechanics is like a special kind of science that helps us understand really tiny things.
# It tells us that these tiny things can be in more than one place at the same time,
# and they can also be connected to each other and affect each other's behavior.
```
@mikejgray
Copy link

Is this PR missing code? Not sure where the decorators come into play with the one file updated.

@JarbasAl
Copy link
Member Author

JarbasAl commented Oct 7, 2023

Is this PR missing code? Not sure where the decorators come into play with the one file updated.

sorry, the decorators were to show the idea, not part of final code, in the other issue i left a better example, you decide the "rewrite_prompt" in the config (or later, in the Session from message.context if you want it per query)

{
	"dialog_transformers": {
		"ovos-dialog-transformer-openai": {
			"key": "xxxxx",  
			"api_url": "https://api.openai.com/v1",
			"rewrite_prompt": "Add more 'dude'ness to"
		}
	}
}

@JarbasAl JarbasAl marked this pull request as ready for review October 7, 2023 20:53
@JarbasAl JarbasAl merged commit 46c48e5 into dev Oct 7, 2023
2 checks passed
@JarbasAl JarbasAl deleted the feat/dialog_transformer branch October 7, 2023 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants