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

Commit

Permalink
fix(compogen): fix json format (#364)
Browse files Browse the repository at this point in the history
Because

- the json format is wrong in mdx

This commit

- fix json format
  • Loading branch information
chuang8511 authored Sep 24, 2024
1 parent e743e89 commit e6619ce
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ai/anthropic/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Anthropic's text generation models (often called generative pre-trained transfor

<h4 id="text-generation-chat-chat-history">Chat History</h4>

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"}.
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"\}.

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
Expand Down
2 changes: 1 addition & 1 deletion ai/cohere/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Cohere's text generation models (often called generative pre-trained transformer

<h4 id="text-generation-chat-chat-history">Chat History</h4>

Incorporate external chat history, specifically previous messages within the conversation. Each message should adhere to the format: : {"role": "The message role, i.e. 'USER' or 'CHATBOT'", "content": "message content"}.
Incorporate external chat history, specifically previous messages within the conversation. Each message should adhere to the format: : \{"role": "The message role, i.e. 'USER' or 'CHATBOT'", "content": "message content"\}.

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
Expand Down
2 changes: 1 addition & 1 deletion ai/fireworksai/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Fireworks AI's text generation models (often called generative pre-trained trans

<h4 id="text-generation-chat-chat-history">Chat History</h4>

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"}
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"\}

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
Expand Down
2 changes: 1 addition & 1 deletion ai/groq/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Groq serves open source text generation models (often called generative pre-trai

<h4 id="text-generation-chat-chat-history">Chat History</h4>

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"}
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"\}

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
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 @@ -287,7 +287,7 @@ Generate texts from input text prompts and chat history.

<h4 id="text-generation-chat-chat-history">Chat History</h4>

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"}.
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"\}.

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
Expand Down Expand Up @@ -360,7 +360,7 @@ Answer questions based on a prompt and an image.

<h4 id="visual-question-answering-chat-history">Chat History</h4>

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"}.
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"\}.

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
Expand Down Expand Up @@ -411,7 +411,7 @@ Generate texts from input text prompts and chat history.

<h4 id="chat-chat-history">Chat History</h4>

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"}.
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"\}.

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
Expand Down
2 changes: 1 addition & 1 deletion ai/mistralai/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Mistral AI's text generation models (often called generative pre-trained transfo

<h4 id="text-generation-chat-chat-history">Chat History</h4>

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"}
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"\}

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
Expand Down
2 changes: 1 addition & 1 deletion ai/ollama/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Open-source large language models (OSS LLMs) are artificial intelligence models

<h4 id="text-generation-chat-chat-history">Chat History</h4>

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"}.
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"\}.

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
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 @@ -66,7 +66,7 @@ OpenAI's text generation models (often called generative pre-trained transformer

<h4 id="text-generation-chat-history">Chat History</h4>

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"}.
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"\}.

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
Expand Down
12 changes: 9 additions & 3 deletions tools/compogen/pkg/gen/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ func parseResourceProperties(o *objectSchema) []resourceProperty {
case "":
prop.Type = "any"
}
prop.Description = strings.ReplaceAll(prop.Description, "\n", " ")
prop.Description = strings.ReplaceAll(prop.Description, "{", "\\{")
prop.Description = strings.ReplaceAll(prop.Description, "}", "\\}")
prop.replaceDescription()

propMap[k] = prop
}
Expand Down Expand Up @@ -389,6 +387,8 @@ func (rt *readmeTask) parseObjectProperties(properties map[string]property, isIn
continue
}

op.replaceDescription()

if op.Type == "object" {

if isInput {
Expand Down Expand Up @@ -679,3 +679,9 @@ func insertHeaderByConstValue(option objectSchema, taskOrString interface{}) str
}
return ""
}

func (prop *property) replaceDescription() {
prop.Description = strings.ReplaceAll(prop.Description, "\n", " ")
prop.Description = strings.ReplaceAll(prop.Description, "{", "\\{")
prop.Description = strings.ReplaceAll(prop.Description, "}", "\\}")
}

0 comments on commit e6619ce

Please sign in to comment.