-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding chatops aliases, unit tests, misc corrections
- Loading branch information
Showing
9 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
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,16 @@ | ||
# This is a comment. | ||
# Each line is a file pattern followed by one or more owners. | ||
|
||
# These owners will be the default owners for everything in | ||
# the repo. Unless a later match takes precedence, users and | ||
# teams which are put in owners will be requested for review | ||
# when someone opens a pull request. | ||
|
||
# This is base configuration. These owners could review the | ||
# whole file in this repository. | ||
* @dalarsen @StackStorm-Exchange/tsc @floatingstatic | ||
|
||
# CI configuration files should be reviewed by specific owners | ||
# who are more responsible for ensuring the quality of this pack | ||
# or orchestrate StackStorm-Exchanges. | ||
.circleci/** @StackStorm-Exchange/tsc |
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,5 @@ | ||
# Changelog | ||
|
||
## v0.1.0 | ||
|
||
* Initial release |
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,21 @@ | ||
--- | ||
name: openai_chat_completion | ||
action_ref: openai.chat_completion | ||
description: Make a chat completion query to the OpenAI API | ||
formats: | ||
- "ask chatgpt {{query}}" | ||
ack: | ||
format: "Sending your ChatGPT chat completion query now, please wait..." | ||
enabled: true | ||
result: | ||
format: | | ||
Response from OpenAI for the ChatGPT chat completion query {{execution.parameters.question}}: | ||
{% if execution.status == 'succeeded' %} | ||
{% for choice in execution.result.result.choices %} | ||
----- | ||
{{ choice.message.content }} | ||
{% endfor %} | ||
{% else %} | ||
Query to OpenAI failed: {{execution}} | ||
{% endif %} |
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,18 @@ | ||
--- | ||
name: openai_image_generation | ||
action_ref: openai.image_generation | ||
description: Make an image generation query to the OpenAI API | ||
formats: | ||
- "ask dall-e {{query}}" | ||
ack: | ||
format: "Sending your DALL-E image generation query now, please wait..." | ||
enabled: true | ||
result: | ||
format: | | ||
Response from OpenAI for the DALL-E image generation query {{execution.parameters.question}}: | ||
{% if execution.status == 'succeeded' %} | ||
{{ execution.result.result.data }} | ||
{% else %} | ||
Query to OpenAI failed: {{execution}} | ||
{% endif %} |
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,3 @@ | ||
--- | ||
openai_token: 'abcdefghikjl1234567890' | ||
openai_org: 'nobody_org' |
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 |
---|---|---|
@@ -1 +1 @@ | ||
openai | ||
openai == 0.27.8 |
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,20 @@ | ||
from st2tests.base import BaseActionTestCase | ||
from openai.openai_object import OpenAIObject | ||
|
||
import chat_completion | ||
import mock | ||
|
||
__all__ = ["TestChatCompletion"] | ||
|
||
|
||
class TestChatCompletion(BaseActionTestCase): | ||
action_cls = chat_completion.ChatCompletion | ||
|
||
@mock.patch("chat_completion.openai.ChatCompletion.create") | ||
def test_chat_completion_makes_valid_chat_completion_request(self, mock_openai): | ||
mock_openai.return_value = OpenAIObject() | ||
action = self.get_action_instance() | ||
action.run("fake query", "mock_model") | ||
mock_openai.assert_called_with( | ||
model="mock_model", messages=[{"role": "user", "content": "fake query"}] | ||
) |
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,18 @@ | ||
from st2tests.base import BaseActionTestCase | ||
from openai.openai_object import OpenAIObject | ||
|
||
import image_generation | ||
import mock | ||
|
||
__all__ = ["TestChatCompletion"] | ||
|
||
|
||
class TestChatCompletion(BaseActionTestCase): | ||
action_cls = image_generation.ImageGeneration | ||
|
||
@mock.patch("chat_completion.openai.Image.create") | ||
def test_image_generation_makes_valid_image_generation_request(self, mock_openai): | ||
mock_openai.return_value = OpenAIObject() | ||
action = self.get_action_instance() | ||
action.run("fake query", "512x512") | ||
mock_openai.assert_called_with(prompt="fake query", size="512x512") |