Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
fix(compogen): wrong bracket direction in substitution (#184)
Browse files Browse the repository at this point in the history
Because

- Some components contain a JSON object in their definition and weren't
properly rendered.

![CleanShot 2024-06-27 at 23 43
03@2x](https://github.com/instill-ai/component/assets/3977183/aa40b37d-e786-4011-8293-7090c0d5948b)

This commit

- Adds saner version to `compogen` command.
- Fixes wrong direction in bracket: `{` -> `}`.
  • Loading branch information
jvallesm authored Jun 28, 2024
1 parent 6299b1f commit dfe8306
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ai/anthropic/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Provide text outputs in response to text inputs.
| System message | `system-message` | string | The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model’s behavior is using a generic message as "You are a helpful assistant." |
| Extra Parameters | `extra-params` | object | Extra Parameters |
| Prompt Images | `prompt-images` | array[string] | The prompt images (Note: The prompt images will be injected in the order they are provided to the 'prompt' message. Anthropic doesn't support sending images via image-url, use this field instead) |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\{. |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\}. |
| Seed | `seed` | integer | The seed (Note: Not supported by Anthropic Models) |
| Temperature | `temperature` | number | The temperature for sampling |
| Top K | `top-k` | integer | Top k for sampling |
Expand Down
6 changes: 3 additions & 3 deletions ai/instill/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Generate texts from input text prompts.
| System message | `system-message` | string | The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model’s behavior is using a generic message as "You are a helpful assistant." |
| Extra Parameters | `extra-params` | object | Extra Parameters |
| Prompt Images | `prompt-images` | array[string] | The prompt images |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\{. |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\}. |
| Seed | `seed` | integer | The seed |
| Temperature | `temperature` | number | The temperature for sampling |
| Top K | `top-k` | integer | Top k for sampling |
Expand Down Expand Up @@ -214,7 +214,7 @@ Generate texts from input text prompts and chat history.
| System message | `system-message` | string | The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model’s behavior is using a generic message as "You are a helpful assistant." |
| Extra Parameters | `extra-params` | object | Extra Parameters |
| Prompt Images | `prompt-images` | array[string] | The prompt images |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\{. |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\}. |
| Seed | `seed` | integer | The seed |
| Temperature | `temperature` | number | The temperature for sampling |
| Top K | `top-k` | integer | Top k for sampling |
Expand Down Expand Up @@ -271,7 +271,7 @@ Answer questions based on a prompt and an image.
| System message | `system-message` | string | The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model’s behavior is using a generic message as "You are a helpful assistant." |
| Extra Parameters | `extra-params` | object | Extra Parameters |
| Prompt Images (required) | `prompt-images` | array[string] | The prompt images |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\{. |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\}. |
| Seed | `seed` | integer | The seed |
| Temperature | `temperature` | number | The temperature for sampling |
| Top K | `top-k` | integer | Top k for sampling |
Expand Down
2 changes: 1 addition & 1 deletion ai/openai/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Provide text outputs in response to their inputs.
| Prompt (required) | `prompt` | string | The prompt text |
| System message | `system-message` | string | The system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model’s behavior is using a generic message as "You are a helpful assistant." |
| Image | `images` | array[string] | The images |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\{. |
| Chat history | `chat-history` | array[object] | Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format \{"role": "The message role, i.e. 'system', 'user' or 'assistant'", "content": "message content"\}. |
| Temperature | `temperature` | number | What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. |
| N | `n` | integer | How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. |
| Max Tokens | `max-tokens` | integer | The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. |
Expand Down
4 changes: 2 additions & 2 deletions ai/openai/v0/config/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@
"instillUIOrder": 0,
"properties": {
"chat-history": {
"description": "Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : {\"role\": \"The message role, i.e. 'system', 'user' or 'assistant'\", \"content\": \"message content\"}.",
"description": "Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format {\"role\": \"The message role, i.e. 'system', 'user' or 'assistant'\", \"content\": \"message content\"}.",
"instillAcceptFormats": [
"structured/chat-messages"
],
"instillShortDescription": "Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should adhere to the format: : {\"role\": \"The message role, i.e. 'system', 'user' or 'assistant'\", \"content\": \"message content\"}.",
"instillShortDescription": "Incorporate external chat history, specifically previous messages within the conversation. Please note that System Message will be ignored and will not have any effect when this field is populated. Each message should be an ojbect adhere to the format: {\"role\": \"The message role, i.e. 'system', 'user' or 'assistant'\", \"content\": \"message content\"}.",
"instillUIOrder": 4,
"instillUpstreamTypes": [
"value",
Expand Down
1 change: 1 addition & 0 deletions tools/compogen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ compogen readme path/to/component/config path/to/component/README.mdx \
arrays and objects (currently the type doesn't support nesting).
- If task definitions contain examples for the (required) input and output
fields, generate param samples as in https://github.com/instill-ai/instill.tech/blob/main/docs/component/ai/openai.en.mdx
- Automate command module version.

## Next steps

Expand Down
2 changes: 1 addition & 1 deletion tools/compogen/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var rootCmd = &cobra.Command{
Use: "compogen",
Short: "compogen is the Instill AI component schema generation tool",
Long: "compogen is the Instill AI component schema generation tool",
Version: "1.1.0",
Version: "0.1.1",
// We print errors ourselves rather than letting Cobra do it.
// This lets us print usage information selectively.
SilenceErrors: true,
Expand Down
4 changes: 2 additions & 2 deletions tools/compogen/cmd/testdata/readme-operator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ cmp pkg/dummy/README.mdx want-readme.mdx
"title": "Meta"
},
"atem": {
"description": "Donec ac atem tempor orci dapibus ultrices in",
"description": "This object should comply witht he format {\"tortor\": \"something\", \"arcu\": \"something else\"}",
"instillUIOrder": 1,
"title": "Atem",
"type": "object",
Expand Down Expand Up @@ -233,7 +233,7 @@ This task is dummier than `TASK_DUMMY`.
| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Elementum | `elementum` | string | Tellus elementum sagittis vitae et |
| Atem | `atem` | object | Donec ac atem tempor orci dapibus ultrices in |
| Atem | `atem` | object | This object should comply witht he format \{"tortor": "something", "arcu": "something else"\} |
| Nullam non | `nullam_non` | number | Id faucibus nisl tincidunt eget nullam non |
| Errors (optional) | `errors` | array[string] | Error messages, if any, during the dummy process |
| Meta (optional) | `context` | any | Free-form metadata |
Expand Down
2 changes: 1 addition & 1 deletion tools/compogen/cmd/testdata/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cmp stdout want-help
cmp stderr want-usage

-- want-version --
compogen version 1.1.0
compogen version 0.1.1
-- want-usage --
Error: unknown flag: --unknown
Run 'compogen --help' for usage.
Expand Down
2 changes: 1 addition & 1 deletion tools/compogen/pkg/gen/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func parseResourceProperties(o *objectSchema) []resourceProperty {
}
prop.Description = strings.ReplaceAll(prop.Description, "\n", " ")
prop.Description = strings.ReplaceAll(prop.Description, "{", "\\{")
prop.Description = strings.ReplaceAll(prop.Description, "}", "\\{")
prop.Description = strings.ReplaceAll(prop.Description, "}", "\\}")

propMap[k] = prop
}
Expand Down

0 comments on commit dfe8306

Please sign in to comment.